2

I am trying to use some Geography functions, but I am getting an error that (all) functions are not existing. I have checked other Stackexchange posts (e.g. this one), but the solutions did not work for me.

Since no function is available, I assume that something is wrong with the geography tables. I am using POSTGIS 2.0.1, therefore the geography functions should be supported.

database# select postgis_full_version(); 
POSTGIS="2.0.1 r9979" GEOS="3.3.5-CAPI-1.7.5" PROJ="Rel. 4.8.0, 6 March 2012" GDAL="GDAL
1.9.1, released 2012/05/15" LIBXML="2.7.3" LIBJSON="UNKNOWN" TOPOLOGY RASTER

I can see the geography tables in the database and the database owner also owns the geography tables.

 public   | geography_columns | view     | developer
 public   | geometry_columns  | view     | developer
 public   | raster_columns    | view     | developer
 public   | raster_overviews  | view     | developer

What could cause the error below?

function st_collect(geography) does not exist
LINE 1: SELECT ST_xMin(ST_Collect(location)) AS id, ST_xMax(ST_Colle...
                       ^
HINT:  No function matches the given name and argument types. You might need to add explicit type casts.

1 Answer 1

6

According to www.postgis.net/docs/ST_Collect,

ST_Collect — Return a specified ST_Geometry value from a collection of other geometries.

(emphasis mine) but it seems your location column is of type geography.

Perhaps you need to convert the geography to a geometry via casting:

St_Collect (location::geometry) 
3
  • 1
    Indeed, only a small subset of functions are implemented for geography. For all others, just cast, as suggested here. Commented Mar 28, 2014 at 7:05
  • Thank you for your answers. The hint regarding geography vs. geometry reminded me that I put geography=True in the GeoDjango model.
    – neurix
    Commented Mar 28, 2014 at 17:56
  • If you want geography back you need to cast back. So ST_Collect(location::geometry)::geography
    – Regina Obe
    Commented Apr 5, 2014 at 4:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.