1

I know there are several post already on how to convert OSM to GeoJson, e.g., How do you convert OSM XML to geojson?.

Nevertheless, I tried the mentioned tools, but I always end up with the same problem. Whenever I load the converted GeoJson (http://tyrasd.github.io/osmtogeojson/) or load the OSM data directly (using geojson.io -> Open), I receive an invalid shape:

http://bl.ocks.org/d/5fc3e8038fa1101cdcd51ad3d0404b47

With http://geojsonlint.com/ I receive different errors using the result of the conversion (e.g., the first and last positions in a LinearRing of coordinates must be the same or Polygons and MultiPolygons should follow the right-hand rule). Is there any setting, tool, that may solve these problems? Or generate a valid result? Are there any tips for the OSM data, that I may apply (e.g., remove specific features, nodes, ...). The source data is shown correctly in OSM, see http://www.openstreetmap.org/relation/62780.

The complete OSM file used for conversion can be found here on my GitHub: nuernberg.osm

2

I clearly don't know where your issue is.

It's working exactly like the http://www.openstreetmap.org/relation/62780 if you use osmtogeojson. You can see a sample in action and there are no broken elements. I make a call using the Overpass API (encoded url) and then do the conversion.

If you need a "one-shot" conversion without depending on third party later e.g Overpass API, just use query-overpass (need to have Node.js installed) and do:

# To install
npm install -g query-overpass
# Put the OverPass query and transform to GeoJSON using the command line 'query-overpass'
echo '[out:json][timeout:25];(relation(62780););out body;>;out skel qt;' | query-overpass --flat-properties > osm-relation-id-62780.geojson
0

I found the problem. The boundary of the file cuts of some nodes and ways from the OSM file. So that the whole shape is not included in the file. I will try to create a complete shape (did that with smaller things and it worked).

Nevertheless, one thing is still bothering me (and if I figured that out I'll edit this answer). There is a hole in the polygon (bottom right), which is not correctly converted. The conversion includes the hole, but also some polygon, which covers the whole. I'll investigate a little more.

Sorry for the confusion.

  • can you remake your selection from overpass-turbo.eu ? It exports geojson directly. – scruss Nov 15 '16 at 23:24
  • yes I could do that, but I need to get the whole conversion to be automated (because of the amount). I have to see if overpass-turbo.eu supports such a feature. – Philipp Nov 16 '16 at 0:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.