NOTICE: help.openstreetmap.org is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum

I'm converting an extracted chunk of OSM data to GeoJSON. We can use GDL ogr2ogr commands like:

ogr2ogr -f GeoJSON tmp_lines.geojson tmp_osm-solar-withreferenced.pbf lines
ogr2ogr -f GeoJSON tmp_mpoly.geojson tmp_osm-solar-withreferenced.pbf multipolygons

By default, ogr2ogr doesn't automatically convert all closed ways into polygons, only ones with certain tags which can be defined in osmconf.ini. The default is:

closed_ways_are_polygons=aeroway,amenity,boundary,building,craft,geological,historic,landuse,leisure,military,natural,office,place,shop,sport,tourism,highway=platform,public_transport=platform

How can I tell ogr2ogr that I want ALL closed ways to be treated as polygons? I know it's not always advisable in general, but in my case it's what I want, and especially I want un-tagged ways to handled like this. The closed_ways_are_polygons flag only seems to accept an explicit list.

asked 29 Apr '20, 09:27

mcld's gravatar image

mcld
81349
accept rate: 0%


It looks like you can't (the implementation just explicitly checks the listed keys):

https://github.com/OSGeo/gdal/blob/5870c3fc8ccc05ead6b9c8a5dd9fad76969fd890/gdal/ogr/ogrsf_frmts/osm/ogrosmdatasource.cpp#L1895

I imagine post processing the GeoJSON is going to be the easiest way to get what you want.

permanent link

answered 29 Apr '20, 12:22

maxerickson's gravatar image

maxerickson
12.7k1083176
accept rate: 32%

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×36
×4
×3

question asked: 29 Apr '20, 09:27

question was seen: 2,291 times

last updated: 29 Apr '20, 12:22

NOTICE: help.openstreetmap.org is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum