Skip to content

image image image

Batch Editing Vector Data Interactively

Uncomment the following line to install leafmap if needed.

1
# %pip install -U leafmap
1
from leafmap import leafmap

Edit points

1
2
3
4
5
m = leafmap.Map(center=[40, -100], zoom=4)
# Load any vector dataset that can be loaded by GeoPandas
geojson_url = "https://github.com/opengeos/datasets/releases/download/us/cities.geojson"
m.batch_edit_points(geojson_url, zoom_to_layer=False)
m

The changed data can be accessed via the Map._geojson_data attribute.

1
# m._geojson_data

Save the edits to a new file. Choose any of the supported formats by GeoPandas, such as GeoJSON, Shapefile, or GeoPackage.

1
m.save_edits("cities.geojson")

Edit lines

1
2
3
4
5
6
7
8
m = leafmap.Map()
# Load any vector dataset that can be loaded by GeoPandas
geojson_url = (
    "https://github.com/opengeos/datasets/releases/download/places/nyc_roads.geojson"
)
highlight_style = {"color": "#3388ff", "weight": 5}
m.batch_edit_lines(geojson_url, highlight_style=highlight_style)
m
1
m.save_edits("nyc_roads.geojson")

Edit polygons

1
2
3
4
5
m = leafmap.Map()
# Load any vector dataset that can be loaded by GeoPandas
geojson_url = "https://github.com/opengeos/datasets/releases/download/places/nyc_buildings.geojson"
m.batch_edit_polygons(geojson_url)
m
1
m.save_edits("nyc_buildings.geojson")