Untitled conversation
- User
[out:json][timeout:25]; // fetch area "Przysucha" to search in {{geocodeArea:Przysucha}}->.searchArea; // gather results ( // get all buildings way"building"; relation"building"; ); // print results out body;
; out skel qt;
Here, how can I additionally add latitude/longitude fields for each of the buildings so I could use these fields in kernel.gl? I'm using that in overpass turbo
- Assistant
To include latitude and longitude fields for each building in your Overpass Turbo query, you can modify the
outstatement to include thecenterinformation. This will add acenterobject to each building element in the JSON output, containing thelat(latitude) andlon(longitude) properties.Here's how you can adjust your query:
[out:json][timeout:25]; // Fetch area "Przysucha" to search in {{geocodeArea:Przysucha}}->.searchArea; // Gather results ( // Get all buildings as ways and relations way["building"](area.searchArea); relation["building"](area.searchArea); ); // Print results with center coordinates out center; >; out skel qt;Explanation of Changes:
-
Using
out center;:- Purpose: The
out center;statement tells Overpass to calculate the center of each way or relation and include it in the output. - Result: Each building element in the JSON output will have a
centerobject containinglatandlonproperties representing the geographical center of the building.
- Purpose: The
-
Complete Query Breakdown:
-
Area Definition:
{{geocodeArea:Przysucha}}->.searchArea;- This line defines the search area based on the name "Przysucha".
-
Fetching Buildings:
( way["building"](area.searchArea); relation["building"](area.searchArea); );- This block fetches all ways and relations tagged as buildings within the defined search area.
-
Output with Center Coordinates:
out center;- As explained, this outputs each building with its calculated center coordinates.
-
Additional Output Options:
>; out skel qt;- These lines ensure that all referenced nodes are also included in the output, which might be useful depending on how you intend to process the data further.
-
Example Output:
With the
out center;statement, a building element in the JSON might look like this:{ "type": "way", "id": 123456, "tags": { "building": "yes", "name": "Example Building" }, "center": { "lat": 51.123456, "lon": 20.654321 } }Using in
kernel.gl:If you're using this data in a visualization tool like
kernel.gl, thecenter.latandcenter.loncan be directly used as the latitude and longitude for placing markers or other geographical representations of the buildings.Additional Tips:
- Filtering Specific Buildings: If you're interested in specific types of buildings, you can refine the query by adding more tags or conditions.
- Performance: Ensure that the
[timeout:25];is sufficient for your query, especially if the area contains a large number of buildings. - Data Verification: Always verify a few entries in the output to ensure that the
centercoordinates align with the actual building locations.
By making this modification, your JSON output will include the necessary geographical coordinates, making it easier to integrate with visualization tools or perform spatial analyses.
-