
Batch Editing Vector Data Interactively
Uncomment the following line to install leafmap if needed.
| # %pip install -U leafmap
|
| from leafmap import leafmap
|
Edit points
| 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.
Save the edits to a new file. Choose any of the supported formats by GeoPandas, such as GeoJSON, Shapefile, or GeoPackage.
| m.save_edits("cities.geojson")
|
Edit lines
| 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
|
| m.save_edits("nyc_roads.geojson")
|
Edit polygons
| 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
|
| m.save_edits("nyc_buildings.geojson")
|