I am trying to figure out how to detect if lat/lng pair is inside a building polygon. So far I have something like this: http://overpass-turbo.eu/s/ocv This code gets me the nearest but it also gets me the closest buildings, which I don't want - to avoid that I have made the around parameter as small as possible. Is there a better solution ? asked 07 Apr '17, 22:38 krizzz |
There is a solution using Python and gis_geometrics [1]. Then create your Python file in the same directory as gis_geometrics.py:
First you need to get your building polygon in gis_geometrics. There are several methods for this: Either you use an Overpass answer. Execute the Overpass query in Python using overpy. Then create a buildings dict with Overpass.getBuildingNodes() and pass each element of its items to the constructor of OSM_Polygon. Or you prefer to get the building using it's way id (e.g. WAY_ID=265258282):
See also alternative methods to find a building (Overpass.getBuildingByRelationId, Overpass.getBuildingsByBB, OSM_Polygon.getPolygonByCoords). Then you can do awesome operations on the building:
[1] https://github.com/timojuez/home/blob/master/mylib/gis_geometrics.py answered 17 Jul '17, 11:02 timojuez |
And how to do it efficiently for a lot of points? https://help.openstreetmap.org/questions/74372/how-to-check-efficiently-if-thousands-of-points-are-located-inside-a-building-polygon-using-overpass