pyrosm icon indicating copy to clipboard operation
pyrosm copied to clipboard

Broken boundaries when using `OSM.get_boundaries()`

Open Zigur opened this issue 3 years ago • 6 comments

If I get the boundaries of an English county and plot them, there are some weird straight lines that do not belong to administrative divisions.

For instance, if I plot the Oxfordshire map:

fp = get_data("oxfordshire")
osm = OSM(fp)
boundaries = osm.get_boundaries()
boundaries.plot(
    facecolor="none",
    edgecolor="gray",
    figsize=(8, 8)
)

I get this map with some straight random lines:

image

Getting only the border named "Oxfordshire" from the administrative_level corresponding to counties does not help either.

oxon_boundaries = osm.get_boundaries(name="Oxfordshire")
oxon_boundaries = oxon_boundaries[oxon_boundaries.admin_level == '6']
oxon_boundaries.plot(facecolor="none", edgecolor="gray")

image

Zigur avatar Nov 11 '21 17:11 Zigur

@Zigur Thanks! I will look into this 👍🏻

HTenkanen avatar Nov 11 '21 17:11 HTenkanen

I have the same problem. After uploading the geo data was corrupted. image

folt avatar Jul 26 '22 20:07 folt

Me too

acmeguy avatar Nov 15 '22 00:11 acmeguy

at least for me these seem to be broken where a boundary touches or intersects the boundary of the respective osm.pbf file. The following would be german county boundaries but any boundary that touches the extent of the osm.pbf file gets connected in ways that create odd self intersecting polygons: image

Chwiggy avatar Dec 17 '23 14:12 Chwiggy

Hi @HTenkanen, i encountered same issue that the incomplete boundaries connected to Andorra

Screenshot from 2024-02-16 16-04-03

and i also investigated the issue, and found misalignment between roles (outer, inner, center) and masks (inner and outer). I try to fix it in this way, and here is my result. I made the incomplete boundaries as line strings, and see this screenshot Patch: boundary-issue.patch.gz

Screenshot from 2024-02-16 15-58-41

Cheers, Sam

samsun-tomtom avatar Feb 16 '24 08:02 samsun-tomtom

Hi @HTenkanen,

I also found the bug in multiploygon geometry creation in the code, while i used it for my analysis. As you can see the protected area next to Andorra which is a multipolygon geometry, and rings are not assemble properly. image

I also fixed the issue, but i didn't optimize it yet.

Here is the results and patch. Hope this patch helps. boundaries-multipolygon-display-issue.patch.gz

image

samsun-tomtom avatar Feb 21 '24 07:02 samsun-tomtom