Search code examples
overpass-api

Extract building geometry with overpass


I need to extract building geometry by coordinates I have this, but as I use around it selects the nearest buildings too. Is there a way to select only one? the building that includes the coordinates

[out:json][timeout:25];
// adjust the search radius (in meters) here

// gather results
(
  // query part for: “building=*”
  way["building"](around:5,37.780495290046375,-122.47132010628351);
);
// print results
out body;
>;
out skel qt;

Solution

  • I cannot find anything about selecting only one building (or more generally: the best match only) in the Overpass API documentation, although I do surmise it should be possible.

    A workaround would be to compare the coordinates of your matches with the desired coordinates, and only retain the match with smallest distance in radial coordinates.