2👍
Each polygon of a MultiPolygon should still form a closed linestring. Your data is probably malformed or corrupted.
You can try to fix this by using ST_MakeValid.
UPDATE aeroway_polygon
SET geom = ST_Multi(ST_CollectionExtract(ST_Makevalid(geom), 3))
WHERE ST_IsValid(geom) = false;
Note that I didn’t test this query, I found it here on gis.stackexchange.
1👍
Polygons
by definition are closed geometries, which means that the first and last Point
must be the same exact Point
.
For Multipolygons
the same principle exists, hence every Polygon
of a Multipolygon
must be closed and there must not be “free” edges inside the geometry.
If you check your dataset you will find that some of those LineStrings
are not closing.
@AntoinePinsard gives a good PostGIS solution.
In GeoDjango version >= 1.10, MakeValid
exists as a database function and we can use it on queries:
AerowayPolygon.objects.all().update(geom=MakeValid('geom'))
If your Django version < 1.10, I have a set of answers on how to create a custom database function and use it as in the example above:
- How to make/use a custom database function in Django
- Equivalent of PostGIS ST_MakeValid in Django GEOS:
from django.contrib.gis.db.models.functions import GeoFunc class MyMakeValid(GeoFunc): function='ST_MakeValid' AerowayPolygon.objects.all().update(geom=MyMakeValid('geom'))
- [Django]-Updating django models with multiprocessing pool locks up database
- [Django]-What are the cons of using Django compared to (ASP.net MVC,NHibernate and Spark View Engine)?