[GIS] Find parent place using nominatim

nominatimopenstreetmapreverse-geocoding

I have a locally hosted Nominatim service. I'm trying to reverse geocode a lat, lon to a place hierarchy.

E.g.
https://nominatim.openstreetmap.org/search.php?q=30.284780%2C+-97.738831&viewbox=-126.57%2C51.68%2C126.57%2C-51.68

which returns https://nominatim.openstreetmap.org/details.php?place_id=93023332

How do I travel up the place hierarchy from http://www.openstreetmap.org/way/150732423 to http://www.openstreetmap.org/relation/1701848#map=12/30.3361/-97.7536 ?

Best Answer

I guess the relationship is a bit tricky to discover. In fact i guess there is no relationship in the sense of OSM: I mean your building is not referenced as a member of the University of texas relation.

In a reproducible perspective, what you can do I such a case could be to perform an overpass query, based on the attribute fetched from the Nominatim reverse geocoding query. E.g. here Nominatim tells you that this building has university for value ? So lets perform a query to know which university it is :

[out:json];
(
  relation["amenity"="university"](around:5000,30.2814,-97.73883);
);
out body;
>;
out skel qt;

Request result on overpass turbo

Or you can perform a new Nominatim query, as previously, based on relevant attributes fetched from the first query (like University, Austin, Texas) and see if there is something interesting: Result on Nominatim