Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I hope you can help as I am tearing my hair out here. Do any of you elite geo peeps have any idea why some specific functions could be missing from my PostGIS install?

I am trying to use Mapnik with PostGIS but when I try to run queries from Python it fails with an error of:

ERROR:  function st_extent(geography) does not exist at character 73
HINT:  No function matches the given name and argument types. You might need to add explicit type casts.
STATEMENT:  SELECT ST_XMin(ext),ST_YMin(ext),ST_XMax(ext),ST_YMax(ext) FROM (SELECT ST_Extent(geom) as ext from reseller_map_core_reseller) as tmp

This is the part of the mapnik code:

shapes = mapnik.Layer('Geometry from PostGIS')
shapes.datasource = mapnik.PostGIS(host='localhost', user='user', password='password', dbname='sales_map', table='sales_map_core_sales', geometry_field='geom', srid='4326')
shapes.styles.append('My Style')
m.layers.append(shapes)

I'm just trying to overlay all of the regions from the selected table onto my mapnik generated image.

I have installed PostGIS successfully, created a spatial db using extensions and my other GeoDjango/PostGIS seems to work so far.

I have looked in the db using pgAdmin and I can see that the st_extents() is missing from the list for some reason even though the others seem to be there.

Any ideas why this specific function (and possibly others) could be missing when I have installed everything?

I am using:

  • PostGIS: 2.0.3
  • Postgresql: 9.2.3
  • Mapnik 2.10

Thanks for your help!

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

Most likely st_extent is not missing -> it is just undefined for geography types (that's what your error says).

It works on geometry types:

osm=# select st_extent('LINESTRING(1 2,3 4)'::geography);
ERROR:  function st_extent(geography) does not exist
LINE 1: select st_extent('LINESTRING(1 2,3 4)'::geography);
           ^
HINT:  No function matches the given name and argument types. You might need to add explicit type casts.


osm=# select st_extent('LINESTRING(1 2,3 4)'::geometry);
  st_extent   
--------------
 BOX(1 2,3 4)
(1 row)
share|improve this answer
    
Genius! That was it! I'm new to db functions so I didn't quite realise what the eror was telling me and then was confused because I couldn't find it in the function list when viewing the db (but obviously it's there somewhere because it's working now). Thanks! –  Ashemah Mar 22 '13 at 5:33
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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