Opened 23 months ago

Closed 23 months ago

Last modified 17 months ago

#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:


How to reproduce:

  1. Create an empty layer.
  2. Draw a closed way.
  3. Save as GeoJSON.
  4. 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 Changed 23 months ago by GerdP

Resolution: duplicate
Status: newclosed

Closed as duplicate of #17453.
You can set prefernce geojson.export.untagged-closed-is-polygon=true to force type Polygon.

Version 0, edited 23 months ago by GerdP (next)

comment:2 Changed 23 months ago by GerdP

Setting natural=water should also work as long as your map style renders it as an area.

comment:3 Changed 23 months ago by Zverikk

Thanks for the tip. Double-checking the styling panel and enabling one that shows natural=water as an area helps.


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 Changed 23 months ago by GerdP

I don't know the reasons, I didn't code it. See my thoughts in ticket:17453#comment:8 and below

comment:5 Changed 23 months ago by GerdP

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 Changed 23 months ago by Zverikk

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:7 Changed 23 months ago by GerdP

You can try, I have no idea how many users there are.

comment:8 Changed 17 months ago by anonymous

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 Changed 17 months ago by GerdP

If your (closed) way is tagged you have to make sure that the mapstyle renders it as area.

Modify Ticket

Change Properties
Set your email in Preferences
as closed The owner will remain team.
as The resolution will be set.
The resolution will be deleted.

Add Comment

E-mail address and name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.