[GIS] PostGIS 2.0 “No function matches the given name and argument types”

postgis

After a lot of research, I figured out how to build PostGIS 2.0 from source on a Turnkey Linux LAPP (Postgres 8.4) server. The main draw of PostGIS 2.0 for me is the ST_ConcaveHull function, aka "shrink wrap".

Now that I have a functioning PostGIS 2.0, I'm trying to implement these functions.

I'm working with the NWS Shapefiles for States and Forecast Zones. Most if not all of the geometries I'm dealing with are multipolygons.

I've figured out how to draw these polygons, and this is the query I use to request data in the GeoJSON format:

SELECT ST_AsGeoJSON(geom) as geom FROM states WHERE id = 5;

Unfortounately, because I'm working with State sized data, some of the requests are HUGE! The GeoJSON for New Jersey is 2mb! I know PostGIS has some great functions to reduce the complexity of the geometries, but I'm having trouble implementing them.

The functions I want to use are:

  • ST_Simplify
  • ST_Union
  • ST_ConcaveHull

Unfortunately, I'm getting some very unhelpful error messages when I run queries using these functions.

SELECT ST_AsGeoJson(ST_Simplify(geom)) as geom FROM states WHERE id = 5;

Error: SQLSTATE[42883]: Undefined function: 7 ERROR: function st_simplify(geometry)     
does not exist LINE 1: SELECT ST_AsGeoJson(ST_Simplify(geom)) as geom FROM states W... 
^ HINT: No function matches the given name and argument types. You might need to add 
explicit type casts.

I went through a LOT of time and effort to make sure that I had PostGIS 2.0 instead of 1.5 for the explicit purpose of using things like ST_ConcaveHull and ST_Simplify, and now Postgre is telling me they don't exist!

I found another post on here that gave me a query listing all global functions available to Postgre:

SELECT  proname, proargnames, prosrc 
FROM    pg_catalog.pg_namespace n
JOIN    pg_catalog.pg_proc p
ON      pronamespace = n.oid
WHERE   nspname = 'public'

Listed in the results are:

  • st_union {geom1,geom2} geomunion
  • st_union pgis_union_geometry_array
  • st_union aggregate_dummy
  • st_concavehull {param_geom,param_pctconvex,param_allow_holes}
  • st_simplify LWGEOM_simplify2d
  • st_simplifypreservetopology topologypreservesimplify

So I'm kind of stuck and confused at this point. The query results say the function doesn't exist, but the output of the above query says they DO exist.

Can anybody shed some light on this for me? What am I doing wrong?

Best Answer

The error says it all

ERROR: function st_simplify(geometry) does not exist

because according to the docs, simplify needs a second parameter for the tolerance, see http://www.postgis.org/docs/ST_Simplify.html

geometry ST_Simplify(geometry geomA, float tolerance);
Related Question