Thanks! Follow up below.<br><br><div class="gmail_quote">On Fri, Apr 20, 2012 at 10:12 AM, Markus Metz <span dir="ltr"><<a href="mailto:markus.metz.giswork@googlemail.com">markus.metz.giswork@googlemail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">On Fri, Apr 20, 2012 at 4:47 PM, Eric Momsen <<a href="mailto:eric.momsen@ndsu.edu">eric.momsen@ndsu.edu</a>> wrote:<br>
> Hi,<br>
><br>
> I've been using GRASS and R for a few months now, and just ran into a snag.<br>
> We added some new attribute columns to our vector file in GRASS, and now<br>
> when I try to move the data into R the transfer fails.<br>
><br>
> The original vector map in grass was imported from a shapefile. I then used<br>
> v.db.addcol and v.rast.stats to add more attributes to the vector map.<br>
><br>
> I first thought it had to do with null values, so I tried adding a column<br>
> filled with a constant value. This didn't help.<br>
><br>
> I tried to reproduce the error in SPEARFISH, columns added with v.rast.stats<br>
> were fine, but v.db.addcol wouldn't execute.<br>
><br>
><br>
> I don't know why the installation let me add columns in one location and not<br>
> another, maybe this is the root cause or another issue all together?<br>
><br>
> v.db.addcolumn --verbose map=landuse@PERMANENT layer=1 columns=test<br>
><br>
> Adding column <test> to the table<br>
> DBMI-DBF driver error:<br>
> SQL parser error (syntax error, unexpected $end processing<br>
> '') in statement:<br>
> ALTER TABLE landuse ADD COLUMN test<br>
<br>
</div>I think the column type is missing. Try e.g.<br>
v.db.addcolumn --verbose map=landuse@PERMANENT layer=1 columns='test<br>
double precision'<br>
<div class="im"><br></div></blockquote><div>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.</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">
> Unable to execute statement.<br>
> ERROR: Error while executing: 'ALTER TABLE landuse ADD COLUMN test'<br>
> ERROR: Unable to add column <test>.<br>
><br>
><br>
> Any ideas for what I'm missing, or a workaround to get the data to R? (I<br>
> was supposed to get an R data file ready today for others to work with that<br>
> aren't used to GRASS...I had previously done the GRASS->R transfer via a<br>
> script a number of times, and didn't expect any problems!)<br>
><br>
> Here are the R messages:<br>
><br>
>> source("/home/emomsen/Documents/loaddata.R")<br>
><br>
> first command in file:<br>
> field2007<-readVECT6("ACSC_2007_Field_Boundary")<br>
><br>
> Loading required package: rgdal<br>
> Geospatial Data Abstraction Library extensions to R successfully loaded<br>
> Loaded GDAL runtime: GDAL 1.9.0, released 2011/12/29<br>
> Path to GDAL shared files: /usr/local/share/gdal<br>
> Loaded PROJ.4 runtime: Rel. 4.8.0, 6 March 2012, [PJ_VERSION: 480]<br>
> Path to PROJ.4 shared files: (autodetected)<br>
> Available OGR Drivers:<br>
> Warning 1: Field COUNTY of width 1000 truncated to 255.<br>
> ....snip... these are OK<br>
> ERROR 6: Failed to add field named 'HARVEST_DAY'<br>
> ERROR 6: Failed to add field named 'NDVI_04_B_DAY'<br>
> ....snip...These were added with v.db.addcol<br>
> ERROR 6: Failed to add field named 'NDVI_04_B_mean'<br>
<br>
</div>The column name is probably too long for the OGR dbf driver, the max<br>
length is 10 I think. That is, NDVI_04_B_DAY becomes truncated to<br>
NDVI_04_B_ and NDVI_04_B_mean also becomes truncated to NDVI_04_B_,<br>
resulting in duplicate column names. You could try a shorter column<br>
prefix with v.rast.stats.<br>
<br></blockquote><div><br></div><div>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.</div>
<div><br></div><div>I'm both embarrassed and happy that this was an easy solution.</div><div><br></div><div>Thanks for the quick response!</div><div>-Eric</div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Markus M<br>
<div><div class="h5"><br>
> ...snip,... there are about 100 of these, extended statistics for 10<br>
> rasters.<br>
><br>
><br>
> The import does finish, all of the "original" columns for the shapefile are<br>
> imported to R. v.db.select shows most of the attribute columns together<br>
> (the last ones are lost from the line length), and querying the map gives<br>
> all the attributes.<br>
><br>
> Thanks for any help!<br>
><br>
> Eric<br>
><br>
>> sessionInfo()<br>
> R version 2.14.1 (2011-12-22)<br>
> Platform: x86_64-pc-linux-gnu (64-bit)<br>
><br>
> locale:<br>
> [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C<br>
> [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8<br>
> [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8<br>
> [7] LC_PAPER=C LC_NAME=C<br>
> [9] LC_ADDRESS=C LC_TELEPHONE=C<br>
> [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C<br>
><br>
> attached base packages:<br>
> [1] stats graphics grDevices utils datasets methods base<br>
><br>
> other attached packages:<br>
> [1] rgdal_0.7-8 spgrass6_0.7-10 XML_3.9-4 sp_0.9-98<br>
><br>
> loaded via a namespace (and not attached):<br>
> [1] grid_2.14.1 lattice_0.20-0<br>
><br>
><br>
> g.gisenv -n<br>
><br>
> LANG=en_US.UTF-8<br>
> GRASS_ADDON_PATH=/home/emomsen/v.krige<br>
> GISDBASE=/home/shared/research/GRASSDATA<br>
> LOCATION_NAME=transferField<br>
> ADDON_PATH=/home/emomsen/v.krige<br>
> GUI=wxpython<br>
> MAPSET=PERMANENT<br>
><br>
><br>
</div></div>> _______________________________________________<br>
> grass-stats mailing list<br>
> <a href="mailto:grass-stats@lists.osgeo.org">grass-stats@lists.osgeo.org</a><br>
> <a href="http://lists.osgeo.org/mailman/listinfo/grass-stats" target="_blank">http://lists.osgeo.org/mailman/listinfo/grass-stats</a><br>
><br>
</blockquote></div><br>