GEODJANGO Problem/Question

125 views
Skip to first unread message

Steve Watts

unread,
May 11, 2022, 1:49:35 AM5/11/22
to Django users
I am running a LayerMapping on a set of ShapeFiles acquired from a County GIS Department. I've done a quite a bit of this, and this is the first time I"ve seen such an issue. As LayerMapping is proceeding through the file saving model instances, it encounters one that it can't handle:

"GDAL_ERROR 1: b'Geometry of polygon of fid 5572 cannot be translated to Simple Geometry. All polygons will be contained in a multipolygon.'"
"GDAL_ERROR 1: b'organizePolygons() received an unexpected geometry.  Either a polygon with interior rings, or a polygon with less than 4 points, or a non-Polygon geometry.  Return arguments as a collection.'"
"GEOS_ERROR: IllegalArgumentException: Invalid number of points in LinearRing found 3 - must be 0 or >= 4"
"Failed to save the feature (id: 5572) into the model with the keyword arguments:"
And the final Exception:
"GEOSException: Error encountered checking Geometry returned from GEOS C function "GEOSWKTReader_read_r"."

The best description of the issue I can find is https://github.com/r-spatial/sf/issues/1589. In this help thread, and a related one, they talk about a utility called "MakeValid" to resolve this LinearRing issue.

It appears I need to either add a point to any of these "LinearRing" instances, or somehow otherwise fix these items.

I'm not sure that sending the ShapeFiles back to the County to "fix" would be productive.

Does anyone have anything to contribute as far as how I might best move forward with this set of ShapeFiles?

Is there another forum where I should be addressing this issue? Need more information?

Thanks!

Steve Watts

Steve Watts

unread,
May 11, 2022, 3:51:10 AM5/11/22
to Django users
Update - I did manage to get the vast majority of the features to load - still missing 7,000/1,462,918 that showed errors during the LayerMapping process. I see a lot of "An error occurred in the current transaction. You can't execute queries until the end of the 'atomic' block." so I suspect there are fewer than 7,000 errors. I had "Step" set to 1,000. I imagine I can figure out how many errors there really are by setting "Step" to 1, This will get me started, but I am still very interested in further insight regarding my original question.

Thanks,

Steve Watts
Reply all
Reply to author
Forward
0 new messages