Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OSM: Support center #11886

Open
Cj-Malone opened this issue Feb 26, 2025 · 3 comments
Open

OSM: Support center #11886

Cj-Malone opened this issue Feb 26, 2025 · 3 comments

Comments

@Cj-Malone
Copy link

Feature description

Strictly speaking this isn't part of the OSM XML format, but it is part of Overpass output, a massive tool in the OSM world. And it massively simplifies working with OSM data.

Sometimes you don't actually care about the HD geometry in OSM, you just want the centroid. Overpass supports outputting the center of an object with out center;. eg:

(
  node(id:1);
  way(id:1324215931);
  relation(id:12357726);
);
out center;

Outputs:

<?xml version="1.0" encoding="UTF-8"?>
<osm version="0.6" generator="Overpass API 0.7.62.5 1bd436f1">
<note>The data included in this document is from www.openstreetmap.org. The data is made available under ODbL.</note>
<meta osm_base="2025-02-26T09:51:01Z"/>

  <node id="1" lat="42.7957187" lon="13.5690032">
    <tag k="communication:microwave" v="yes"/>
    <tag k="communication:radio" v="fm"/>
    <tag k="description" v="Radio Subasio"/>
    <tag k="frequency" v="105.5 MHz"/>
    <tag k="man_made" v="mast"/>
    <tag k="name" v="Monte Piselli - San Giacomo"/>
    <tag k="note" v="This is the very first node on OpenStreetMap."/>
    <tag k="tower:construction" v="lattice"/>
    <tag k="tower:type" v="communication"/>
  </node>
  <way id="1324215931">
    <center lat="33.1643506" lon="-95.2185702"/>
    <nd ref="12253775940"/>
    <nd ref="12253775939"/>
    <nd ref="12253775938"/>
    <nd ref="12253775935"/>
    <nd ref="12253775937"/>
    <nd ref="12253775936"/>
    <nd ref="12253775940"/>
    <tag k="brand" v="Love's"/>
    <tag k="brand:wikidata" v="Q1872496"/>
    <tag k="hgv" v="yes"/>
    <tag k="highway" v="services"/>
    <tag k="name" v="Love's Travel Stop"/>
    <tag k="website" v="https://www.loves.com/locations/279"/>
  </way>
  <relation id="12357726">
    <center lat="49.0068815" lon="8.4023387"/>
    <member type="way" ref="910369169" role="outer"/>
    <member type="way" ref="910369181" role="outer"/>
    <tag k="amenity" v="fast_food"/>
    <tag k="cuisine" v="pizza"/>
    <tag k="level" v="1"/>
    <tag k="name" v="La Pizza"/>
    <tag k="toilets:wheelchair" v="yes"/>
    <tag k="type" v="multipolygon"/>
    <tag k="wheelchair" v="yes"/>
    <tag k="wheelchair:description" v="Toiletten im Einkaufszentrum, Schlüssel nötig, gibt es für die, die (noch) keinen selbst haben, gegen Pfand bei der Information (Erdgeschoss)."/>
  </relation>

</osm>

Notice the members and nodes aren't included, with only this file, it's not possible to build the OSM geometry. However instead we get center, where supported this means we don't have to mess around with multiple layers and multiple files.

I would like it if the OSM driver could read center.

Additional context

No response

@jratike80
Copy link
Collaborator

It seems to be possible to export GeoJSON from the site https://overpass-turbo.eu/ and GDAL can naturally read it. If I understand it right overpass-turbo does not support natively GeoJSON output but some external library is used.

https://github.com/mediasuitenz/Overpass2Geojson
https://github.com/tyrasd/osmtogeojson

I suggest using that route if you are in a hurry.

@Cj-Malone
Copy link
Author

I am not in a hurry.

My slight ulterior motive here is to be able to automate this easily, not using the Overpass Turbo website, just the api.

$ curl https://overpass-api.de/api/interpreter -d "data=(%0A++node(id%3A1)%3B%0A++way(id%3A1324215931)%3B%0A++relation(id%3A12357726)%3B%0A)%3B%0Aout+center%3B" | ogr2ogr -of geojson out.geojson -overwrite /vsistdin/

@jratike80
Copy link
Collaborator

It may be best to read the "no hurry" to mean that it will not happen within the regular GDAL maintenance work. Pull Requests and contracted development could be an option, but myself I would consider integrating osmtogeojson into your workflow https://tyrasd.github.io/[osmtogeojson](https://tyrasd.github.io/osmtogeojson/)/. It seems to work fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants