[GRASS-user] Error using v.in.ogr to load a shapefile: any clue?

Tom Russo russo at bogodyn.org
Mon Mar 10 12:25:33 EDT 2008


On Mon, Mar 10, 2008 at 03:52:28PM +0000, we recorded a bogon-computron collision of the <ct529 at york.ac.uk> flavor, containing:
> Dear friends,
> 
> I get this error when trying to read the Scotland.shp shape file using 
> v.in.ogr. Please, not that I have the proper permissions on the databse.
> 
>          driver: dbf
>          database: $GISDBASE/$LOCATION_NAME/$MAPSET/dbf/
> DBMI-DBF driver error:
> SQL parser error in statement:
> create table Scotland_SSSI (cat integer, AREA double precision, PERIMETER 
> double precision, SSSI_ double precision, SSSI_ID double precision, 
> CARTO_CODE varchar ( 8 ), OVERLAP_CO varchar ( 8 ), SITE_NAME varchar ( 
> 100 ), SITE_HA double precision, NOTIFIED date, COUNCIL varchar ( 100 ), TYPE 
> varchar ( 10 ), MIDAS_NUM double precision, UPDATE varchar ( 30 ))
> Error in db_execute_immediate()
> 
> ERROR: Cannot create table: create table Scotland_SSSI (cat integer, AREA
>        double precision, PERIMETER double precision, SSSI_ double
>        precision, SSSI_ID double precision, CARTO_CODE varchar ( 8 ),
>        OVERLAP_CO varchar ( 8 ), SITE_NAME varchar ( 100 ), SITE_HA double
>        precision, NOTIFIED date, COUNCIL varchar ( 100 ), TYPE varchar ( 10
>        ), MIDAS_NUM double precision, UPDATE varchar ( 30 ))
> GRASS 6.2.3 (Scotland_from_shapefile):~ >

I think the problem here is the field named "UPDATE" --- the GRASS SQL driver
cries when you try to use field names that are reserved words in SQL.  The
same happens for fields named "DATE" or "TIME" that are commonly used in 
shapefiles.  I believe that UPDATE is a reserved word.

You'll have to use the "cnames=" option of v.in.ogr to rename the columns to
get around that.

Unfortunately, cnames requires that you give a name to *all* the columns up
to the one you want to change, and your "UPDATE" field is the last one.  So
you'd have to use:
  cnames=cat,AREA,PERIMETER,SSI_,SSI_ID,CARTO_CODE,OVERLAP_CO,SITE_NAME,SITE_HA,NOTIFIED,COUNCIL,TYPE,MIDAS_NUM,whateveryouwanttocallUPDATEinstead

-- 
Tom Russo    KM5VY   SAR502   DM64ux          http://www.swcp.com/~russo/
Tijeras, NM  QRPL#1592 K2#398  SOC#236 AHTB#1 http://kevan.org/brain.cgi?DDTNM
"And, isn't sanity really just a one-trick pony anyway? I mean all you get is
 one trick, rational thinking, but when you're good and crazy, oooh, oooh,
 oooh, the sky is the limit!"  --- The Tick


More information about the grass-user mailing list