Open loicdtx opened 5 years ago
Is not clear why in dict called mapping a value of POLYGON
in https://github.com/CONABIO/antares3/blob/ubuntubionic/madmex/management/commands/init.py#L90 still works when GeometryField
is being used here: https://github.com/CONABIO/antares3/blob/ubuntubionic/madmex/models.py#L16
With this changes ingesting from GADM administrative boundaries still a MultiPolygon object is loaded when doing:
region = 'Jalisco'
region_geom = Region.objects.get(name=region).the_geom
region_geom
<MultiPolygon object at 0x7f7d4aa2ea28>
(because GADM administrative boundaries are multipolygons)
Also have in mind This note from https://docs.djangoproject.com/es/2.1/ref/contrib/gis/tutorial/:
....Unfortunately, the shapefile data format does not allow for greater specificity with regards to geometry types. This shapefile, like many others, actually includes MultiPolygon geometries, not Polygons. It’s important to use a more general field type in models: a GeoDjango MultiPolygonField will accept a Polygon geometry, but a PolygonField will not accept a MultiPolygon type geometry. This is why the WorldBorder model defined above uses a MultiPolygonField.
How can we change a multipolygon to a polygon geometry...? certainly with this change would make things easier...
In
madmex/models.py
usingGeometryField
instead of enforcingMultiPolygonField
for Country and Region tables would make things easier. Otherwise region that are not multipolygons have to be coerced to multipolygons.