The PostGIS query would be:
select * from gis.zipcodes where ST_Contains(geom, ST_GeomFromText('POINT(-74.0863037109375 40.704586878965245)', 4269));
where geom is the multipolygon geometry column. I tried this by doing:
pnt = GEOSGeometry('SRID=4269;POINT(-74.0863037109375 40.704586878965245)')
Zipcode.objects.filter(geom__contains=pnt)
but received the error "No function matches the given name and argument types. You might need to add explicit type casts." I then tried making a raw query like:
Zipcode.objects.raw("select * from gis.zipcodes where ST_Contains(geom, ST_GeomFromText('POINT(-74.0863037109 40.704586879)', 4269))")
Other, non-spatial queries work fine. My guess is that Django isn't recognizing the PostGIS extensions but I'm not sure why. I have:
I've also tried running the query Zipcode.objects.raw("select postgis_full_version()") which fails in a similar fashion.
File "/Library/Python/2.7/site-packages/django/core/handlers/base.py", line 111, in get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/Library/Python/2.7/site-packages/django/views/decorators/csrf.py", line 57, in wrapped_view
return view_func(*args, **kwargs)
File "/Library/Python/2.7/site-packages/django/views/generic/base.py", line 69, in view
return self.dispatch(request, *args, **kwargs)
File "/Library/Python/2.7/site-packages/rest_framework/views.py", line 403, in dispatch
response = self.handle_exception(exc)
File "/Library/Python/2.7/site-packages/rest_framework/views.py", line 400, in dispatch
response = handler(request, *args, **kwargs)
File "/Library/Python/2.7/site-packages/rest_framework/decorators.py", line 50, in handler
return func(*args, **kwargs)
File "/data/django-apis/hcpro/proapp/views.py", line 47, in zipcode_from_coord
print raw_qs[0]
File "/Library/Python/2.7/site-packages/django/db/models/query.py", line 1598, in __getitem__
return list(self)[k]
File "/Library/Python/2.7/site-packages/django/db/models/query.py", line 1535, in __iter__
query = iter(self.query)
File "/Library/Python/2.7/site-packages/django/db/models/sql/query.py", line 76, in __iter__
self._execute_query()
File "/Library/Python/2.7/site-packages/django/db/models/sql/query.py", line 90, in _execute_query
self.cursor.execute(self.sql, self.params)
File "/Library/Python/2.7/site-packages/django/db/backends/utils.py", line 81, in execute
return super(CursorDebugWrapper, self).execute(sql, params)
File "/Library/Python/2.7/site-packages/django/db/backends/utils.py", line 65, in execute
return self.cursor.execute(sql, params)
File "/Library/Python/2.7/site-packages/django/db/utils.py", line 94, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/Library/Python/2.7/site-packages/django/db/backends/utils.py", line 65, in execute
return self.cursor.execute(sql, params)
ProgrammingError: function st_geomfromtext(unknown, integer) does not exist
LINE 1: ...elect * from gis.zipcodes where ST_Contains(geom, ST_GeomFro...
^
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
--
You received this message because you are subscribed to the Google Groups "geodjango" group.
To unsubscribe from this group and stop receiving emails from it, send an email to geodjango+...@googlegroups.com.
To post to this group, send email to geod...@googlegroups.com.
Visit this group at http://groups.google.com/group/geodjango.
For more options, visit https://groups.google.com/d/optout.