15 openstreetmap
Downloading OpenStreetMap data with a single line of code
Uncomment the following line to install leafmap if needed.
In [1]:
Copied!
# !pip install geopandas osmnx leafmap
# !pip install geopandas osmnx leafmap
In [2]:
Copied!
import leafmap
import leafmap
Add OSM data of place(s) by name or ID to the map. Note that the leafmap custom layer control does not support GeoJSON, we need to use the ipyleaflet built-in layer control.
In [3]:
Copied!
m = leafmap.Map(toolbar_control=False, layers_control=True)
m.add_osm_from_geocode("New York City", layer_name='NYC')
m
m = leafmap.Map(toolbar_control=False, layers_control=True)
m.add_osm_from_geocode("New York City", layer_name='NYC')
m
Out[3]:
Make this Notebook Trusted to load map: File -> Trust Notebook
In [4]:
Copied!
m = leafmap.Map(toolbar_control=False, layers_control=True)
m.add_osm_from_geocode("Chicago, Illinois", layer_name='Chicago, IL')
m
m = leafmap.Map(toolbar_control=False, layers_control=True)
m.add_osm_from_geocode("Chicago, Illinois", layer_name='Chicago, IL')
m
Out[4]:
Make this Notebook Trusted to load map: File -> Trust Notebook
Add OSM entities within boundaries of geocodable place(s) to the map.
In [5]:
Copied!
m = leafmap.Map(toolbar_control=False, layers_control=True)
place = "Bunker Hill, Los Angeles, California"
tags = {"building": True}
m.add_osm_from_place(place, tags, layer_name="Los Angeles, CA")
m
m = leafmap.Map(toolbar_control=False, layers_control=True)
place = "Bunker Hill, Los Angeles, California"
tags = {"building": True}
m.add_osm_from_place(place, tags, layer_name="Los Angeles, CA")
m
Out[5]:
Make this Notebook Trusted to load map: File -> Trust Notebook
Show OSM feature tags.
In [6]:
Copied!
# leafmap.osm_tags_list()
# leafmap.osm_tags_list()
Add OSM entities within some distance N, S, E, W of address to the map.
In [7]:
Copied!
m = leafmap.Map(toolbar_control=False, layers_control=True)
m.add_osm_from_address(
address="New York City", tags={"amenity": "bar"}, dist=1500, layer_name="NYC bars"
)
m
m = leafmap.Map(toolbar_control=False, layers_control=True)
m.add_osm_from_address(
address="New York City", tags={"amenity": "bar"}, dist=1500, layer_name="NYC bars"
)
m
Out[7]:
Make this Notebook Trusted to load map: File -> Trust Notebook
In [8]:
Copied!
m = leafmap.Map(toolbar_control=False, layers_control=True)
m.add_osm_from_address(
address="New York City",
tags={"landuse": ["retail", "commercial"], "building": True},
dist=1000,
layer_name="NYC buildings",
)
m
m = leafmap.Map(toolbar_control=False, layers_control=True)
m.add_osm_from_address(
address="New York City",
tags={"landuse": ["retail", "commercial"], "building": True},
dist=1000,
layer_name="NYC buildings",
)
m
Out[8]:
Make this Notebook Trusted to load map: File -> Trust Notebook