I know the geometry is valid because it can be created via `GEOSGeometry`.
Example:
{{{
from django.contrib.gis.geos import Point, Polygon, MultiPoint,
MultiPolygon, MultiLineString, LineString
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".
ls1 = LineString((0, 0), (1, 1))
ls2 = LineString((2, 2), (3, 3))
mls = MultiLineString(ls1, ls2)
>>> GEOSException: Error encountered checking Geometry returned from GEOS
C function "GEOSGeom_createCollection_r".
MultiPoint(Point(0, 0), Point(1, 1))
>>> GEOSException: Error encountered checking Geometry returned from GEOS
C function "GEOSGeom_createCollection_r".
}}}
More of the error stack trace below:
{{{
geos/factories.py:18: in <module>
p = Polygon(
../venv39/lib/python3.9/site-
packages/django/contrib/gis/geos/polygon.py:46: in __init__
polygon = self._create_polygon(n_holes + 1, [ext_ring, *init_holes])
../venv39/lib/python3.9/site-
packages/django/contrib/gis/geos/polygon.py:93: in _create_polygon
return capi.create_polygon(shell, holes_param, c_uint(n_holes))
../venv39/lib/python3.9/site-
packages/django/contrib/gis/geos/libgeos.py:152: in __call__
return self.func(*args)
../venv39/lib/python3.9/site-
packages/django/contrib/gis/geos/prototypes/threadsafe.py:47: in __call__
return self.cfunc(self.thread_context.handle.ptr, *args)
../venv39/lib/python3.9/site-
packages/django/contrib/gis/geos/prototypes/errcheck.py:32: in check_geom
raise GEOSException('Error encountered checking Geometry returned from
GEOS C function "%s".' % func.__name__)
E django.contrib.gis.geos.error.GEOSException: Error encountered
checking Geometry returned from GEOS C function
"GEOSGeom_createPolygon_r".
}}}
----
Operating System & other info:
- MacOS Monterey 12.4, M1 chip
- gdal installed via homebrew (3.5.1)
- Python 3.8.12, Django 3.2
- also have geos and proj 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 as well as reinstalling all related brew
packages.
--
Ticket URL: <https://code.djangoproject.com/ticket/33840>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* status: new => closed
* resolution: => duplicate
Comment:
Duplicate of #32600.
--
Ticket URL: <https://code.djangoproject.com/ticket/33840#comment:1>