In [1]:
Copied!
# %pip install -U leafmap
# %pip install -U leafmap
In [2]:
Copied!
from leafmap import leafmap
from leafmap import leafmap
Edit points¶
In [3]:
Copied!
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
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.
In [4]:
Copied!
# m._geojson_data
# m._geojson_data
Save the edits to a new file. Choose any of the supported formats by GeoPandas, such as GeoJSON, Shapefile, or GeoPackage.
In [5]:
Copied!
m.save_edits("cities.geojson")
m.save_edits("cities.geojson")
No GeoJSON data to save.
Edit lines¶
In [6]:
Copied!
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 = 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
In [7]:
Copied!
m.save_edits("nyc_roads.geojson")
m.save_edits("nyc_roads.geojson")
Edit polygons¶
In [8]:
Copied!
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 = 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
In [9]:
Copied!
m.save_edits("nyc_buildings.geojson")
m.save_edits("nyc_buildings.geojson")