Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid Polygons extracted from shapefile #3

Open
xrotwang opened this issue Jun 2, 2021 · 1 comment
Open

Invalid Polygons extracted from shapefile #3

xrotwang opened this issue Jun 2, 2021 · 1 comment
Assignees

Comments

@xrotwang
Copy link
Member

xrotwang commented Jun 2, 2021

A couple of the GeoJSON polygons extracted from the shapefile give warnings like

INFO:shapely.geos:Ring Self-intersection at or near point 32.453069177254385 62.062804436767827

when read with shapely. It's easy enough to fix this (see

for i, poly in enumerate(f['geometry']['coordinates']):
rings = []
for ring in poly:
# Some linear rings are self-intersecting. We fix these by taking the 0-distance
# buffer around the ring instead.
p = Polygon(ring)
if not p.is_valid:
p = p.buffer(0)
assert p.is_valid
rings.append(p.__geo_interface__['coordinates'][0])
p = shape(dict(type='Polygon', coordinates=rings))

).

But maybe you'd want to fix this upstream, i.e. in the Geographic Database?

@MiinaNo
Copy link
Collaborator

MiinaNo commented Jun 3, 2021

This question is probably for @tjrant

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants