Is there an alternative way to query Los Angeles County boundary than nominatim for OSM when using geocode_to_gdf?

34 views Asked by At

I am trying to use OSMnx to query Open Street Map data for LA County. The code works fine for any county in California except Los Angeles. Is there any other way to query data for LA County (osmid)? Or is does it simply not exist in OSM?

I looked up the nominatim data and there is no boundary data for LA County, it only returns a point marker. So maybe the data just doesn't exist (which I find hard to believe).

LA County nominatim query: https://nominatim.openstreetmap.org/ui/search.html?q=los+angeles+county

Riverside county query: https://nominatim.openstreetmap.org/ui/search.html?q=riverside+county

Code:

import osmnx as ox

la_county = ox.geocode_to_gdf(
    {
        "county": "Los Angeles County",
        "state": "California",
        "country": "USA",
    }
)
type(la_county["geometry"].iloc[0])

Expected result: expected result

Actual result: actual result

1

There are 1 answers

0
gboeing On

Los Angeles County exists as a boundary on OpenStreetMap. But it does not exist in Nominatim's database:

import osmnx as ox
ox.settings.use_cache = False
gdf = ox.geocoder.geocode_to_gdf("R396479", by_osmid=True)
# InsufficientResponseError: Nominatim geocoder returned 0 results for query 'R396479'.

This was not the case in the past. It may be worth opening an issue at Nominatim's Github repo.