I try to export geographical data from a postgis database to a shapefile with pgsql2shp.

Normally this works fine, but now I receive the following error.

Preparing table for user query... Done. 
Initializing... ZMflagQuery: ERROR:  function zmflag(geometry) does not exist
LINE 1: SELECT max(zmflag("geometrie"::geometry)) FROM "__pgsql2shp7...

The query I use is:

pgsql2shp.exe -f 'foldername' -h luna -p 5432 -u user-P pw -g geometrie dbname "select * from bag.adressen a where a.wnpcode = '3386'"

I haven't had any earlier problems with pgsql2shp.

  • You'll want to provide more information before anyone can give an informed answer. What is the output from: SELECT postgis_full_version();
    – dustymugs
    Oct 12, 2012 at 1:41
  • Output for 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 GDAL_DATA not found" LIBXML="2.7.8" LIBJSON="UNKNOWN" RASTER"
    – Stefan
    Oct 12, 2012 at 7:54

1 Answer 1


PostGIS 2.0 doesn't have the function zmflag(geometry). It is now known as st_zmflag(geometry). I'm betting that the version of pgsql2shp is from a prior version of PostGIS. You can check with

pgsql2shp -?

At the top of the output, it should list the release version. Something like...

RELEASE: 2.1.0SVN (r10420)

Your Answer

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

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