I am trying to create a Polygon with django.contrib.gis.geos.Polygon
. I know that the points are valid but I get the error:
django.contrib.gis.geos.error.GEOSException: Error encountered checking Geometry returned from GEOS C function "GEOSGeom_createPolygon_r"
If I instead use django.contrib.gis.geos.geometry.GEOSGeometry
it works just fine.
Ex:
from django.contrib.gis.geos import Polygon
from django.contrib.gis.geos.geometry import GEOSGeometry
poly = GEOSGeometry('POLYGON((4 4, 4 4, 4 4, 4 4))')
poly.coords()
>>> (((4.0, 4.0), (4.0, 4.0), (4.0, 4.0), (4.0, 4.0)),)
poly2 = Polygon(((4, 4), (4, 4), (4, 4), (4, 4)))
>>> GEOSException: Error encountered checking Geometry returned from GEOS C function "GEOSGeom_createPolygon_r".
Operating System & other info:
- MacOS Monterey, M1 chip
gdal
installed via homebrew (3.5.1)- Python 3.8.12, Django 3.2
- also have
geos
andproj
installed previously as dependencies via homebrew - Have set:
GDAL_LIBRARY_PATH="/opt/homebrew/lib/libgdal.dylib"`
GEOS_LIBRARY_PATH="/opt/homebrew/lib/libgeos_c.dylib"
Exact same code is working on an older Mac setup w/ the same environment just fine.
Have also now tried Python 3.9 and reinstalling all related brew packages. I also get the same error with other geometry types (Point
& LineString
work fine, but MultiPoint
& MultiLineString
fail).