#18902 closed defect (duplicate)
Polygons are exported to GeoJSON as linestrings
Reported by: | Zverikk | Owned by: | team |
---|---|---|---|
Priority: | normal | Milestone: | |
Component: | Core geojson | Version: | latest |
Keywords: | geojson | Cc: |
Description
How to reproduce:
- Create an empty layer.
- Draw a closed way.
- Save as GeoJSON.
- Look inside.
The feature is saved as a LineString, despite it being closed.
Adding "area=yes" or even "natural=water" does not help — although I'd prefer for polygons to be exported without any properties at all, defaulting to this type with no tags.
This would make JOSM highly useful for maintaining polygon bounds for osmium tool and such.
Attachments (0)
Change History (9)
comment:1 by , 5 years ago
Resolution: | → duplicate |
---|---|
Status: | new → closed |
comment:2 by , 5 years ago
Setting natural=water should also work as long as your map style renders it as an area.
comment:3 by , 5 years ago
Thanks for the tip. Double-checking the styling panel and enabling one that shows natural=water as an area helps.
But.
Defaulting to exporting closed ways as linestrings is really non-obvious, and having to enable expert mode, opening advanced preferences tab, searching for this long-named key and toggling it, only to make JOSM behave in an obvious way, feels broken. Using the default JOSM style disables nodes on low zooms by default, which doesn't help with drawing boundaries on a country scale. And adding OSM tags on polygons just to make JOSM produce polygons again seems extra. This essentially makes the editor unsuitable for anything besides editing actual OSM data. No editing of GeoJSON (because it would break them), no making polygon boundaries for any external tools.
Is there a reason why this was made the default?
comment:4 by , 5 years ago
I don't know the reasons, I didn't code it. See my thoughts in ticket:17453#comment:8 and below
comment:5 by , 5 years ago
If you ask why I didn't change the default with r15429 so that an untagged closed way is exported as a Polygon:
I don't know how important the old behaviour is for other users, so it seemed less dangerous to add an option.
comment:6 by , 5 years ago
Would you change it if I made a ticket for switching the default? Judging by #18903, not many people use this feature, and defaulting to polygons would be easier to understand.
comment:8 by , 4 years ago
I am currently drawing some suburb boundaries and I really need to export them as .geojson polygons. instead i get an array of linestrings. i already changes the preference mentioned in this thead but i still get the linestrings despite the fact that the paths are closed. can someone tell me the exact steps in order to export a suburb as a polygon in geojson format
comment:9 by , 4 years ago
If your (closed) way is tagged you have to make sure that the mapstyle renders it as area.
Closed as duplicate of #17453.
You can set preference geojson.export.untagged-closed-is-polygon=true to force type Polygon.