#!/usr/bin/env python # coding: utf-8 # [![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/95_edit_vector.ipynb) # [![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/docs/notebooks/95_edit_vector.ipynb) # [![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD) # # # Edit Vector Data Interactively # # Uncomment the following line to install [leafmap](https://leafmap.org) if needed. # In[ ]: # %pip install -U leafmap # In[ ]: from leafmap import leafmap # ## Edit points # In[ ]: 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.edit_points(geojson_url) m # Save the edits to a new file. Choose any of the supported formats by GeoPandas, such as GeoJSON, Shapefile, or GeoPackage. # In[ ]: m.save_edits("cities.geojson") # ## Edit lines # In[ ]: 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" ) m.edit_lines(geojson_url) m # In[ ]: m.save_edits("nyc_roads.geojson") # ## Edit polygons # In[ ]: 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.edit_polygons(geojson_url) m # In[ ]: m.save_edits("nyc_buildings.geojson") # ![image](https://github.com/user-attachments/assets/4ef42f54-d6a6-4a77-9651-743d5fe9fef9)