geocode_to_gdf¶

Retrieve place(s) by name or ID from the Nominatim API as a GeoDataFrame.

In [ ]:
# OSMnx: New Methods for Acquiring, Constructing, Analyzing, and Visualizing Complex Street Networks
import osmnx as ox

ox.config(use_cache=True, log_console=False)
ox.__version__
Out[ ]:
'1.1.2'

country¶

In [ ]:
query = '대한민국'

# Retrieve place(s) by name or ID from the Nominatim API as a GeoDataFrame.
gdf = ox.geocoder.geocode_to_gdf(query, which_result=None, by_osmid=False, buffer_dist=None)

# Project a GeoDataFrame from its current CRS to another.
proj = ox.project_gdf(gdf)

# Plot a graph.
ax = proj.plot(); _ = ax.axis('off')
/Users/junhyun/.pyenv/versions/3.8.5/envs/openstreetmap/lib/python3.8/site-packages/osmnx/geocoder.py:110: FutureWarning: The frame.append method is deprecated and will be removed from pandas in a future version. Use pandas.concat instead.
  gdf = gdf.append(_geocode_query_to_gdf(q, wr, by_osmid))

city¶

In [ ]:
query = '서울특별시, 대한민국'

# Retrieve place(s) by name or ID from the Nominatim API as a GeoDataFrame.
gdf = ox.geocoder.geocode_to_gdf(query, which_result=None, by_osmid=False, buffer_dist=None)

# Project a GeoDataFrame from its current CRS to another.
proj = ox.project_gdf(gdf)

# Plot a graph.
ax = proj.plot(); _ = ax.axis('off')
/Users/junhyun/.pyenv/versions/3.8.5/envs/openstreetmap/lib/python3.8/site-packages/osmnx/geocoder.py:110: FutureWarning: The frame.append method is deprecated and will be removed from pandas in a future version. Use pandas.concat instead.
  gdf = gdf.append(_geocode_query_to_gdf(q, wr, by_osmid))

gu¶

In [ ]:
query = '중구, 서울특별시, 대한민국'

# Retrieve place(s) by name or ID from the Nominatim API as a GeoDataFrame.
gdf = ox.geocoder.geocode_to_gdf(query, which_result=None, by_osmid=False, buffer_dist=None)

# Project a GeoDataFrame from its current CRS to another.
proj = ox.project_gdf(gdf)

# Plot a graph.
ax = proj.plot(); _ = ax.axis('off')
/Users/junhyun/.pyenv/versions/3.8.5/envs/openstreetmap/lib/python3.8/site-packages/osmnx/geocoder.py:110: FutureWarning: The frame.append method is deprecated and will be removed from pandas in a future version. Use pandas.concat instead.
  gdf = gdf.append(_geocode_query_to_gdf(q, wr, by_osmid))

multi query¶

In [ ]:
query1 = '중구, 서울특별시, 대한민국'
query2 = '종로구, 서울특별시, 대한민국'
query3 = '성북구, 서울특별시, 대한민국'

# Retrieve place(s) by name or ID from the Nominatim API as a GeoDataFrame.
gdf = ox.geocoder.geocode_to_gdf(
    [query1, query2, query3], 
    which_result=None, 
    by_osmid=False, 
    buffer_dist=None
)

# Project a GeoDataFrame from its current CRS to another.
proj = ox.project_gdf(gdf)

# Plot a graph.
ax = proj.plot(); _ = ax.axis('off')
/Users/junhyun/.pyenv/versions/3.8.5/envs/openstreetmap/lib/python3.8/site-packages/osmnx/geocoder.py:110: FutureWarning: The frame.append method is deprecated and will be removed from pandas in a future version. Use pandas.concat instead.
  gdf = gdf.append(_geocode_query_to_gdf(q, wr, by_osmid))
/Users/junhyun/.pyenv/versions/3.8.5/envs/openstreetmap/lib/python3.8/site-packages/osmnx/geocoder.py:110: FutureWarning: The frame.append method is deprecated and will be removed from pandas in a future version. Use pandas.concat instead.
  gdf = gdf.append(_geocode_query_to_gdf(q, wr, by_osmid))
/Users/junhyun/.pyenv/versions/3.8.5/envs/openstreetmap/lib/python3.8/site-packages/osmnx/geocoder.py:110: FutureWarning: The frame.append method is deprecated and will be removed from pandas in a future version. Use pandas.concat instead.
  gdf = gdf.append(_geocode_query_to_gdf(q, wr, by_osmid))