0

How can I call PostGIS's ST_Simplify function?

postgres=# SELECT ST_Simplify( geom, 0.1 ) FROM mains;

ERROR:  function st_simplify(geography, numeric) does not exist
LINE 1: SELECT ST_Simplify( geom, 0.1 ) FROM mains;
               ^
HINT:  No function matches the given name and argument types. You might need to add explicit type casts.

The function does exist:

postgres=# \df st_simplify
                                  List of functions
 Schema |    Name     | Result data type |         Argument data types         | Type
--------+-------------+------------------+-------------------------------------+------
 public | st_simplify | geometry         | geometry, double precision          | func
 public | st_simplify | geometry         | geometry, double precision, boolean | func
(2 rows)

And my column type seems correct:

postgres=# \d my_table;

geom | geography(MultiLineString,4326) 

My PostGIS version:

postgres=# SELECT PostGIS_full_version();

POSTGIS="3.1.4 3.1.4" [EXTENSION] PGSQL="140" GEOS="3.9.1-CAPI-1.14.1" PROJ="7.1.1" LIBXML="2.9.9" LIBJSON="0.12" LIBPROTOBUF="1.2.1" WAGYU="0.5.0 (Internal)" (core procs from "3.2.1 3.2.1" need upgrade)

Could the problem be the final message, core procs from "3.2.1 3.2.1" need upgrade? If so, where would be the best source of a Windows binary?

2
  • 2
    It seems like ST_Simplify allows only geometry type, not geography?
    – RainForest
    Jul 15 at 7:23
  • Many thanks - hadn't noticed that geom had changed type in my many varied efforts to import data! Jul 15 at 9:35

1 Answer 1

5

As S.Chernyshov comments and you note in your question ST_Simplify only works on geometry objects not geography ones.

You will need to cast your geom to a geometry

SELECT ST_Simplify( geom::geometry, 0.1 ) FROM mains;

will be syntactically correct but probably not really a good idea as this sort of operation should really be carried out in a planar coordinate system not a geographic one.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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