[GRASS-stats] readVECT6 - ogr fails to export some columns

Markus Metz markus.metz.giswork at googlemail.com
Sun Apr 22 11:39:53 EDT 2012


Eric Momsen wrote:

[snip]

>> >
>> > v.db.addcolumn --verbose map=landuse at PERMANENT layer=1 columns=test
>> >
>> > Adding column <test> to the table
>> > DBMI-DBF driver error:
>> > SQL parser error (syntax error, unexpected $end processing
>> > '') in statement:
>> > ALTER TABLE landuse ADD COLUMN test
>>
>> I think the column type is missing. Try e.g.
>> v.db.addcolumn --verbose map=landuse at PERMANENT layer=1 columns='test
>> double precision'
>>
> OK, that worked today. Yesterday when I tried it I was getting columns named
> "test double precision".  Are those single quotes or back ticks?  From the
> GUI I put it in without any surrounding marks with column name and data
> type.

Single quotes for the command line. When using the GUI, quoting is not
necessary.

>> > Here are the R messages:
>> >
>> >> source("/home/emomsen/Documents/loaddata.R")
>> >
>> > first command in file:
>> > field2007<-readVECT6("ACSC_2007_Field_Boundary")
>> >
>> > Loading required package: rgdal
>> > Geospatial Data Abstraction Library extensions to R successfully loaded
>> > Loaded GDAL runtime: GDAL 1.9.0, released 2011/12/29
>> > Path to GDAL shared files: /usr/local/share/gdal
>> > Loaded PROJ.4 runtime: Rel. 4.8.0, 6 March 2012, [PJ_VERSION: 480]
>> > Path to PROJ.4 shared files: (autodetected)
>> > Available OGR Drivers:
>> > Warning 1: Field COUNTY of width 1000 truncated to 255.
>> > ....snip... these are OK
>> > ERROR 6: Failed to add field named 'HARVEST_DAY'
>> > ERROR 6: Failed to add field named 'NDVI_04_B_DAY'
>> > ....snip...These were added with v.db.addcol
>> > ERROR 6: Failed to add field named 'NDVI_04_B_mean'
>>
>> The column name is probably too long for the OGR dbf driver, the max
>> length is 10 I think. That is, NDVI_04_B_DAY becomes truncated to
>> NDVI_04_B_ and NDVI_04_B_mean also becomes truncated to NDVI_04_B_,
>> resulting in duplicate column names. You could try a shorter column
>> prefix with v.rast.stats.
>>
>
> Ah ha!  OK, I did v.db.renamecol to test one of them, and that one
> transfered fine.  I assume I'm OK going with renaming the existing columns,
> some of the statistics results would be too long even with a short prefix.

You could also try to use another OGR driver with the driver option of
readVECT6 that does not use DBF attribute tables, e.g. SQLite or
PostGIS if supported.

Markus M

>
> I'm both embarrassed and happy that this was an easy solution.
>
> Thanks for the quick response!
> -Eric
>
>
>>
>> Markus M
>>
>> > ...snip,... there are about 100 of these, extended statistics for 10
>> > rasters.
>> >
>> >
>> > The import does finish, all of the "original" columns for the shapefile
>> > are
>> > imported to R.  v.db.select shows most of the attribute columns together
>> > (the last ones are lost from the line length), and querying the map
>> > gives
>> > all the attributes.
>> >
>> > Thanks for any help!
>> >
>> > Eric
>> >
>> >> sessionInfo()
>> > R version 2.14.1 (2011-12-22)
>> > Platform: x86_64-pc-linux-gnu (64-bit)
>> >
>> > locale:
>> >  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C
>> >  [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8
>> >  [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8
>> >  [7] LC_PAPER=C                 LC_NAME=C
>> >  [9] LC_ADDRESS=C               LC_TELEPHONE=C
>> > [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
>> >
>> > attached base packages:
>> > [1] stats     graphics  grDevices utils     datasets  methods   base
>> >
>> > other attached packages:
>> > [1] rgdal_0.7-8     spgrass6_0.7-10 XML_3.9-4       sp_0.9-98
>> >
>> > loaded via a namespace (and not attached):
>> > [1] grid_2.14.1    lattice_0.20-0
>> >
>> >
>> > g.gisenv -n
>> >
>> > LANG=en_US.UTF-8
>> > GRASS_ADDON_PATH=/home/emomsen/v.krige
>> > GISDBASE=/home/shared/research/GRASSDATA
>> > LOCATION_NAME=transferField
>> > ADDON_PATH=/home/emomsen/v.krige
>> > GUI=wxpython
>> > MAPSET=PERMANENT
>> >
>> >
>> > _______________________________________________
>> > grass-stats mailing list
>> > grass-stats at lists.osgeo.org
>> > http://lists.osgeo.org/mailman/listinfo/grass-stats
>> >
>
>


More information about the grass-stats mailing list