[mapserver-users] postgis error "geom" deos not exit

Stephen Woodbridge woodbri at swoodbridge.com
Sun Apr 22 15:29:47 EDT 2012


The issue here has to do with what you called your geometry column in 
the database. If you loaded the data using shp2pgsql and did not specify 
a geometry column name then the default is "the_geom" and not "geom"

If you are not sure then check with psql like

psql -U postgres -h localhost delhiroads
\d asia_southern_asia_india_delhi_highway
\q

And look for the column name for the geometry type column. If you used 
mixed case names then you need to double quote the column names of the 
connection will fold the names to lowercase and you will not find the 
column.

-Steve W

On 4/22/2012 3:13 PM, Annu Anurag wrote:
> Dear everybody,
>
>                            I've been trying to get a shapefile displayed
> from my postgis database on my site. I've somehow been unable to do so.
> The site on opening says, "msDrawMap(): Image handling error. Failed to
> draw layer named 'Road'. msPostGISLayerWhichShapes(): Query error. Error
> executing query: ERROR: column "geom" does not exist LINE 1: select
> "name",encode(ST_AsBinary(ST_Force_2D("geom"),'NDR'),... ^ ". I set the
> debug variables on in my mapfile and it came up with this.
>
> [Sun Apr 22 00:23:48 2012].720775 msPostGISLayerOpen called: geom from
> asia_southern_asia_india_delhi_highway
> [Sun Apr 22 00:23:48 2012].721115 msPostGISLayerOpen: No connection in
> pool, creating a fresh one.
> [Sun Apr 22 00:23:48 2012].919149 msConnPoolRegister(Road,user=postgres
> password=***************** dbname=delhiroads host=localhost,0x91c6630)
> [Sun Apr 22 00:23:48 2012].961144 msPostGISLayerOpen: Got PostGIS
> version 10500.
> [Sun Apr 22 00:23:48 2012].961217 msPostGISLayerFreeItemInfo called.
> [Sun Apr 22 00:23:48 2012].961257 msPostGISLayerInitItemInfo called.
> [Sun Apr 22 00:23:48 2012].961293 msPostGISLayerWhichShapes called.
> [Sun Apr 22 00:23:48 2012].961335 msPostGISParseData called.
> [Sun Apr 22 00:23:48 2012].961397 msPostGISRetrievePK called.
> [Sun Apr 22 00:23:48 2012].961440 msPostGISRetrievePK: select attname
> from pg_attribute, pg_constraint, pg_class where pg_constraint.conrelid
> = pg_class.oid and pg_class.oid = pg_attribute.attrelid and
> pg_constraint.contype = 'p' and pg_constraint.conkey[1] =
> pg_attribute.attnum and pg_class.relname =
> 'asia_southern_asia_india_delhi_highway' and
> pg_table_is_visible(pg_class.oid) and pg_constraint.conkey[2] is null
> [Sun Apr 22 00:23:48 2012].970777 msPostGISParseData: unique_column=gid,
> srid=, geom_column_name=geom,
> table_name=asia_southern_asia_india_delhi_highway
> [Sun Apr 22 00:23:48 2012].970865 msPostGISBuildSQL called.
> [Sun Apr 22 00:23:48 2012].970899 msPostGISBuildSQLItems called.
> [Sun Apr 22 00:23:48 2012].970935 msPostGISBuildSQLItems: 1 items requested.
> [Sun Apr 22 00:23:48 2012].970966 msPostGISBuildSQLFrom called.
> [Sun Apr 22 00:23:48 2012].971015 msPostGISBuildSQLWhere called.
> [Sun Apr 22 00:23:48 2012].971045 msPostGISBuildSQLSRID called.
> [Sun Apr 22 00:23:48 2012].971076 msPostGISBuildSQLSRID: Building
> find_srid line.
> [Sun Apr 22 00:23:48 2012].971106 msPostGISBuildSQLSRID: Found table
> (asia_southern_asia_india_delhi_highway)
> [Sun Apr 22 00:23:48 2012].971140 msPostGISBuildSQLBox called.
> [Sun Apr 22 00:23:48 2012].971246 msPostGISLayerWhichShapes query:
> select "name",encode(ST_AsBinary(ST_Force_2D("geom"),'NDR'),'hex') as
> geom,"gid" from asia_southern_asia_india_delhi_highway where geom &&
> GeomFromText('POLYGON((76.8164150612777 28.410443,76.8164150612777
> 28.862691,77.4196089387223 28.862691,77.4196089387223
> 28.410443,76.8164150612777
> 28.410443))',find_srid('','asia_southern_asia_india_delhi_highway','geom'))
> [Sun Apr 22 00:23:48 2012].974241 msPostGISLayerWhichShapes query
> status: PGRES_FATAL_ERROR (7)
> [Sun Apr 22 00:23:48 2012].974320 Error (msPostGISLayerWhichShapes()
> ) executing query: ERROR:  column "geom" does not exist
> LINE 1: select "name",encode(ST_AsBinary(ST_Force_2D("geom"),'NDR'),...
>                                                       ^
> [Sun Apr 22 00:23:48 2012].974372 msPostGISLayerWhichShapes(): Query
> error. Error executing query: ERROR:  column "geom" does not exist
> LINE 1: select "name",encode(ST_AsBinary(ST_Force_2D("geom"),'NDR'),...
>                                                       ^
>
> [Sun Apr 22 00:23:48 2012].974411 msPostGISLayerFreeItemInfo called.
> [Sun Apr 22 00:23:48 2012].974444 msPostGISLayerClose called: geom from
> asia_southern_asia_india_delhi_highway
> [Sun Apr 22 00:23:48 2012].974478 msConnPoolRelease(Road,user=postgres
> password=Christbearers dbname=delhiroads host=localhost,0x91c6630)
> [Sun Apr 22 00:23:48 2012].974510 msConnPoolClose(user=postgres
> password=Christbearers dbname=delhiroads host=localhost,0x91c6630)
> [Sun Apr 22 00:23:48 2012].975210 msDrawMap(): Image handling error.
> Failed to draw layer named 'Road'.
> [Sun Apr 22 00:23:48 2012].976675 msPostGISLayerClose called: geom from
> asia_southern_asia_india_delhi_highway
> [Sun Apr 22 00:23:48 2012].977001 freeLayer(): freeing layer at 0x91c8538.
> [Sun Apr 22 00:23:48 2012].977060 msPostGISLayerIsOpen called.
>
>
> An additional detail is that I've recently installed pgrouting onto my
> system. I got the deb files for the latest pgrouting package available
> from the ubuntu repositories. Its installed with support for driving
> distance. When I ran my mapfile which had been running fine using bare
> shapefiles, I got an error. Here is the mapfile.
>
>
> MAP #
> /////////////////////////////////////////////////////////////MAPFILE
> BEGINS.////////////////////////////////////////////////////////////////////////////
>      NAME "First"
>      CONFIG "MS_ERRORFILE" "/var/www/tmp/ms_error.txt"
>      CONFIG "ON_MISSING_DATA" "LOG"
>      CONFIG "PROJ_LIB" "/usr/share/proj/"
>      CONFIG "PROJ_DEBUG" "ON"
>      CONFIG "CPL_DEBUG" "ON"
>      SIZE 1024 768
>      IMAGECOLOR 239 245 186
>      IMAGETYPE PNG
>      SHAPEPATH "/var/www/Delhi/"
>      FONTSET /var/www/fonts/fontset.txt
>      EXTENT 76.898503 28.410443 77.337521 28.862691
>
>           #
>          # ///////////////////////////////////////////////////////WEB
> CONSTRUCT BEGINS.
> ///////////////////////////////////////////////////////////////
>           #
>
>          WEB
>              TEMPLATE "/var/www/roadrefined.html"
>              IMAGEPATH "/var/www/tmp/"
>              IMAGEURL "/tmp/"
>          END #__________________END OF THE WEB
> CONSTRUCT._____________________########################################################################
>
>           #
>          # //////////////////////////////////////////////////////THE
> FIRST LAYER. LAYER THAT DRAWS EVERYTHING.
> ///////////////////////////////////////
>           #
>
>          LAYER
>              NAME "Road"
>              CONNECTIONTYPE postgis
>              CONNECTION "user=postgres password=**************
> dbname=delhiroads host=localhost"
>              DEBUG 5
>              STATUS DEFAULT
>              TYPE LINE
>              DATA "geom from asia_southern_asia_india_delhi_highway"
>              LABELCACHE ON
>              LABELITEM "name"
>
>               #
>              # //////////////////////////////////////////////////////THE
> CLASS THAT CLASSIFIES EVERYTHING IN IT. ////////////////////////////////
>               #
>
>              CLASS
>
>                   #
>                  #
> /////////////////////////////////////////////////////THE STYLE OF
> DRAWING THIS CLASS. ////////////////////////////////////
>                   #
>
>                  STYLE
>                      OUTLINECOLOR 0 123 0
>                      COLOR 153 205 205
>                  END #___END OF THE SYLE DECLARATION FOR THIS
> CLASS.___#####################################################################
>
>                   #
>                  #
> ////////////////////////////////////////////////////THE LABEL DISCIPLINE
> FOR THIS CLASS. ////////////////////////////////
>                   #
>
>                  LABEL
>                      MINFEATURESIZE auto
>                      COLOR 0 0 0
>                      FONT "arial"
>                      TYPE truetype
>                      ANGLE follow
>                      SIZE 12
>                      MINDISTANCE 50
>                      REPEATDISTANCE 150
>                  END #________END OF THE LABEL DISCIPLINE FOR THIS
> CLASS.________###########################################################
>
>              END #_________END OF THE CLASS THAT CLASSIFIES
> EVERYTHING.___________##############################################################
>          END #________END OF THE LAYER THAT DRAWS
> EVERYTHING._________##############################################################################
> END #_________________________________END OF THE MAPFILE,
> ATLAST.___________________________________#######################################################
>
>
>
>
> I'm stuck here for long and my project is stuck too. If anybody has any
> clue how to work this one out, please help.
>
> Anurag.
>
>
> _______________________________________________
> mapserver-users mailing list
> mapserver-users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/mapserver-users



More information about the mapserver-users mailing list