<div dir="ltr">This is what i got: <br><br><pre tabindex="0" class="" id="rstudio_console_output" style="font-family:"Lucida Console";font-size:10pt!important;outline:medium none;border:medium none;margin:0px;white-space:pre-wrap!important;line-height:15px;color:rgb(0,0,0);font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-indent:0px;text-transform:none;word-spacing:0px;background-color:rgb(255,255,255)"><span class="" style="color:blue;white-space:pre">> </span><span class="" style="color:blue">vinfo0 <- execGRASS("<a href="http://v.info">v.info</a>", flags="c", map=zm.gnrl)
</span>INTEGER|cat
INTEGER|ID
INTEGER|GRIDCODE
Displaying column types/names for database connection of layer <1>:<br></pre><br>And trying to read back the original polygon (without v.clean):<br><br><pre tabindex="0" class="" id="rstudio_console_output" style="font-family:"Lucida Console";font-size:10pt!important;outline:medium none;border:medium none;margin:0px;white-space:pre-wrap!important;line-height:15px;color:rgb(0,0,0);font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-indent:0px;text-transform:none;word-spacing:0px;background-color:rgb(255,255,255)"><span class="" style="color:blue;white-space:pre">> </span><span class="" style="color:blue">zm.fnl <- readVECT(zm.pol)
</span><span class="" style="color:rgb(197,6,11)">Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings,  : 
  line 4 did not have 2 elements</span></pre><br><br><br></div><div class="gmail_extra"><br><div class="gmail_quote">2015-10-10 13:12 GMT-03:00 Roger Bivand <span dir="ltr"><<a href="mailto:Roger.Bivand@nhh.no" target="_blank">Roger.Bivand@nhh.no</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On Sat, 10 Oct 2015, Eduardo Diez wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Apparently "<a href="http://v.info" rel="noreferrer" target="_blank">v.info</a>" through execGRASS is expecting the "layer" argument to<br>
be a string rather than an integer.<br>
</blockquote>
<br></span>
Yes, please re-run with "1"; this resulted from GRASS6 to GRASS7 over-enthusiastic changing everything just for fun - this isn't the problem. Run (assuming that zm.gnrl contains a character string):<br>
<br>
vinfo0 <- execGRASS("<a href="http://v.info" rel="noreferrer" target="_blank">v.info</a>", flags="c", map=zm.gnrl)<br>
<br>
My guess is that <a href="http://v.info" rel="noreferrer" target="_blank">v.info</a> is saying that this map is broken, or suffering from something that vColumns does not know about.<br>
<br>
<a href="http://v.info" rel="noreferrer" target="_blank">v.info</a> -c map=<br>
<br>
should simply respond with "<storage type>|<name>" lines for the fields in the layer. Here, its fourth line (unlike the first three) does not have two elements (the type/name pairs).<br>
<br>
Does readVECT() work if you do not use v.clean? Is v.clean having a side effect of causing <a href="http://v.info" rel="noreferrer" target="_blank">v.info</a> -c to "say" something else? How should the input columns of the object to be cleaned be turned into output columns (simply copy across the retained areas?)?<br>
<br>
Roger<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
zm.fnl <- readVECT(zm.gnrl)Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings,  :<br>
</blockquote><span class="">
 line 4 did not have 2 elements> vinfo0 <- execGRASS("<a href="http://v.info" rel="noreferrer" target="_blank">v.info</a>",<br></span>
flags="c", map=zm.gnrl, layer=1L,+ intern=TRUE)Error in doGRASS(cmd,<span class=""><br>
flags = flags, ..., parameters = parameters, echoCmd = echoCmd,  :<br>
 Parameter <layer> does not have string value><br></span>
parseGRASS("<a href="http://v.info" rel="noreferrer" target="_blank">v.info</a>")Command: <a href="http://v.info" rel="noreferrer" target="_blank">v.info</a><div><div class="h5"><br>
Extension: .exe<br>
Description: Outputs basic information about a vector map.<br>
Keywords: vector, metadata, topology, extent, history, attribute columns<br>
Parameters:<br>
 name: map, type: string, required: yes, multiple: no<br>
 keydesc: name, keydesc_count: 1<br>
[Or data source for direct OGR access]<br>
 name: layer, type: string, required: no, multiple: no<br>
 default: 1<br>
[Vector features can have category values in different layers. This<br>
number determines which layer to use. When used with direct OGR access<br>
this is the layer name.]<br>
Flags:<br>
 name: h [Print history instead of info and exit] {FALSE}<br>
 name: c [Print types/names of table columns for specified layer<br>
instead of info and exit] {FALSE}<br>
 name: g [Print region info in shell script style] {FALSE}<br>
 name: e [Print extended metadata info in shell script style] {FALSE}<br>
 name: t [Print topology info in shell script style] {FALSE}<br>
 name: help [Print usage summary] {FALSE}<br>
 name: verbose [Verbose module output] {FALSE}<br>
 name: quiet [Quiet module output] {FALSE}<br>
<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
</blockquote>
<br>
2015-10-10 10:56 GMT-03:00 Roger Bivand <<a href="mailto:Roger.Bivand@nhh.no" target="_blank">Roger.Bivand@nhh.no</a>>:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
OK, thanks. So the failure is in:<br>
<br>
vinfo0 <- execGRASS("<a href="http://v.info" rel="noreferrer" target="_blank">v.info</a>", flags="c", map="<name>", layer=1L,<br>
  intern=TRUE)<br>
<br>
used to return the column/field names. Please repeat with that.<br>
<br>
Roger<br>
<br>
<br>
On Fri, 9 Oct 2015, Eduardo Diez wrote:<br>
<br>
Here are the traceback and the vInfo(zm.gnrl). The latter seems to work<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
fine.<br>
<br>
zm.fnl <- readVECT(zm.gnrl)<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
</blockquote>
Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings,<br>
:<br>
 line 4 did not have 2 elements<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
traceback()<br>
<br>
</blockquote>
8: scan(file = file, what = what, sep = sep, quote = quote, dec = dec,<br>
      nmax = nrows, skip = 0, na.strings = na.strings, quiet = TRUE,<br>
      fill = fill, strip.white = strip.white, blank.lines.skip =<br>
blank.lines.skip,<br>
      multi.line = FALSE, comment.char = comment.char, allowEscapes =<br>
allowEscapes,<br>
      flush = flush, encoding = encoding, skipNul = skipNul)<br>
7: read.table(con, header = FALSE, sep = "|")<br>
6: vColumns(vname)<br>
5: nchar(as.character(vColumns(vname)$name))<br>
4: .read_vect_non_plugin(vname = vname, layer = layer, type = type,<br>
      remove.duplicates = remove.duplicates, ignore.stderr =<br>
ignore.stderr,<br>
      pointDropZ = pointDropZ, driver = driver, with_prj = with_prj,<br>
      with_c = with_c)<br>
3: tryCatchList(expr, classes, parentenv, handlers)<br>
2: tryCatch({<br>
      stopifnot(is.logical(plugin) || is.null(plugin))<br>
      stopifnot(is.logical(ignore.stderr))<br>
      if (missing(layer))<br>
          layer <- 1L<br>
      layer <- as.character(layer)<br>
      stopifnot(is.logical(with_c))<br>
      if (!is.null(driver) && driver == "GRASS")<br>
          plugin <- TRUE<br>
      if (!requireNamespace("rgdal", quietly = TRUE)) {<br>
          stop("rgdal not available")<br>
      }<br>
      if (is.null(plugin)) {<br>
          ogrD <- rgdal::ogrDrivers()$name<br>
          plugin <- "GRASS" %in% ogrD<br>
      }<br>
      if (plugin) {<br>
          res <- .read_vect_plugin(vname = vname, layer = layer,<br>
              type = type, ignore.stderr = ignore.stderr, pointDropZ =<br>
pointDropZ,<br>
              mapset = mapset)<br>
      }<br>
      else {<br>
          res <- .read_vect_non_plugin(vname = vname, layer = layer,<br>
              type = type, remove.duplicates = remove.duplicates,<br>
              ignore.stderr = ignore.stderr, pointDropZ = pointDropZ,<br>
              driver = driver, with_prj = with_prj, with_c = with_c)<br>
      }<br>
  }, finally = {<br>
      if (get.suppressEchoCmdInFuncOption()) {<br>
          tull <- set.echoCmdOption(inEchoCmd)<br>
      }<br>
  })<br>
1: readVECT(zm.gnrl)<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
vInfo(zm.gnrl)<br>
<br>
</blockquote>
    nodes     points      lines boundaries  centroids      areas<br>
islands primitives      map3d<br>
      274          0          0        302         31         31<br>
3        333          0<br>
<br>
Thanks<br>
<br>
<br>
2015-10-09 11:36 GMT-03:00 Roger Bivand <<a href="mailto:Roger.Bivand@nhh.no" target="_blank">Roger.Bivand@nhh.no</a>>:<br>
<br>
If it is the <a href="http://v.info" rel="noreferrer" target="_blank">v.info</a> call, please run:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
res <- execGRASS("<a href="http://v.info" rel="noreferrer" target="_blank">v.info</a>", flags="t", map="zm.gnrl", layer=1L,<br>
intern=TRUE)<br>
<br>
and report the output of:<br>
<br>
print(res)<br>
<br>
and maybe send me offlist the output of<br>
<br>
save(res, file="vinfo_odd_output.RData")<br>
<br>
Roger<br>
<br>
--<br>
Roger Bivand<br>
Norwegian School of Economics<br>
Helleveien 30, 5045 Bergen, Norway<br>
<a href="mailto:Roger.Bivand@nhh.no" target="_blank">Roger.Bivand@nhh.no</a><br>
<br>
<br>
________________________________________<br>
Fra: grass-stats [<a href="mailto:grass-stats-bounces@lists.osgeo.org" target="_blank">grass-stats-bounces@lists.osgeo.org</a>] p&#229; vegne av<br>
Roger Bivand [<a href="mailto:Roger.Bivand@nhh.no" target="_blank">Roger.Bivand@nhh.no</a>]<br>
Sendt: 9. oktober 2015 4:27<br>
Til: Eduardo Diez<br>
Kopi: <a href="mailto:grass-stats@lists.osgeo.org" target="_blank">grass-stats@lists.osgeo.org</a><br>
Emne: Re: [GRASS-stats] rgrass7 read/write SpatialPolygonsDataFrames<br>
errors<br>
<br>
OK, please provide the output of traceback() run immediately after the<br>
failing readVECT(). That will show which command invokes scan(). Also try<br>
to run vInfo(zm.gnrl) - I think the failure is in:<br>
<br>
execGRASS("<a href="http://v.info" rel="noreferrer" target="_blank">v.info</a>", flags="t", map="zm.gnrl", layer=1L)<br>
<br>
not returning a structure that vInfo understands, and which ois then used<br>
in readVECT().<br>
<br>
Roger<br>
<br>
--<br>
Roger Bivand<br>
Norwegian School of Economics<br>
Helleveien 30, 5045 Bergen, Norway<br>
<a href="mailto:Roger.Bivand@nhh.no" target="_blank">Roger.Bivand@nhh.no</a><br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
Fra: <a href="mailto:diez.edu@gmail.com" target="_blank">diez.edu@gmail.com</a> [<a href="mailto:diez.edu@gmail.com" target="_blank">diez.edu@gmail.com</a>] på vegne av Eduardo Diez [<br>
<a href="mailto:eduardodiez@gmx.com" target="_blank">eduardodiez@gmx.com</a>]<br>
<br>
Sendt: 9. oktober 2015 4:04<br>
<br>
Til: Roger Bivand<br>
<br>
Kopi: <a href="mailto:grass-stats@lists.osgeo.org" target="_blank">grass-stats@lists.osgeo.org</a><br>
<br>
Emne: Re: [GRASS-stats] rgrass7 read/write SpatialPolygonsDataFrames<br>
errors<br>
<br>
<br>
<br>
<br>
<br>
<br>
Roger, with GRASS version 7.0.1 and rgrass7_0.1-3, readVECT now doesn't<br>
ask for the driver to use but gives the same error as before:<br>
<br>
<br>
<br>
<br>
writeVECT(SDF = mz.pol, vname = zm.pol, v.in.ogr_flags = "o")<br>
Over-riding projection check<br>
Check if OGR layer <q7468fb> contains polygons...<br>
<br>
<br>
<br>
Importing 205 features (OGR layer <q7468fb>)...<br>
<br>
<br>
<br>
-----------------------------------------------------<br>
Registering primitives...<br>
3924 primitives registered<br>
12866 vertices registered<br>
Number of nodes: 2884<br>
Number of primitives: 3924<br>
Number of points: 0<br>
Number of lines: 0<br>
Number of boundaries: 3924<br>
Number of centroids: 0<br>
Number of areas: -<br>
Number of isles: -<br>
-----------------------------------------------------<br>
Cleaning polygons<br>
-----------------------------------------------------<br>
Breaking polygons...<br>
Breaking polygons (pass 1: select break points)...<br>
<br>
<br>
<br>
Breaking polygons (pass 2: break at selected points)...<br>
<br>
<br>
<br>
-----------------------------------------------------<br>
Removing duplicates...<br>
<br>
<br>
<br>
-----------------------------------------------------<br>
Breaking boundaries...<br>
<br>
<br>
<br>
-----------------------------------------------------<br>
Removing duplicates...<br>
<br>
<br>
<br>
-----------------------------------------------------<br>
Cleaning boundaries at nodes...<br>
<br>
<br>
<br>
-----------------------------------------------------<br>
Merging boundaries...<br>
<br>
<br>
<br>
-----------------------------------------------------<br>
Removing dangles...<br>
<br>
<br>
<br>
-----------------------------------------------------<br>
Building areas...<br>
<br>
<br>
<br>
205 areas built<br>
13 isles built<br>
Number of nodes: 2929<br>
Number of primitives: 7268<br>
Number of points: 0<br>
Number of lines: 0<br>
Number of boundaries: 7268<br>
Number of centroids: 0<br>
Number of areas: 205<br>
Number of isles: 13<br>
-----------------------------------------------------<br>
Removing bridges...<br>
<br>
<br>
<br>
-----------------------------------------------------<br>
Registering primitives...<br>
498 primitives registered<br>
5828 vertices registered<br>
Building areas...<br>
<br>
<br>
<br>
205 areas built<br>
13 isles built<br>
Attaching islands...<br>
<br>
<br>
<br>
Number of nodes: 306<br>
Number of primitives: 498<br>
Number of points: 0<br>
Number of lines: 0<br>
Number of boundaries: 498<br>
Number of centroids: 0<br>
Number of areas: 205<br>
Number of isles: 13<br>
-----------------------------------------------------<br>
Finding centroids for OGR layer <q7468fb>...<br>
<br>
<br>
<br>
-----------------------------------------------------<br>
Writing centroids...<br>
<br>
<br>
<br>
-----------------------------------------------------<br>
205 input polygons<br>
Total area: 1.25187E+006 (205 areas)<br>
-----------------------------------------------------<br>
Copying features...<br>
<br>
<br>
<br>
WARNING: Unable to delete file<br>
<br>
<br>
 'C:/Users/ediez1/AppData/Local/Temp/Rtmpqkeay4/file480c1e5e16a7/file480c11cc233b/.tmp/unknown/vector/tmp_8308/coor'<br>
Building topology for vector map <q7468fb@file480c11cc233b>...<br>
Registering primitives...<br>
703 primitives registered<br>
6033 vertices registered<br>
Building areas...<br>
<br>
<br>
<br>
205 areas built<br>
13 isles built<br>
Attaching islands...<br>
<br>
<br>
<br>
Attaching centroids...<br>
<br>
<br>
<br>
Number of nodes: 306<br>
Number of primitives: 703<br>
Number of points: 0<br>
Number of lines: 0<br>
Number of boundaries: 498<br>
Number of centroids: 205<br>
Number of areas: 205<br>
Number of isles: 13<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
execGRASS("v.clean", flags = c("overwrite"), input = zm.pol,<br>
<br>
</blockquote>
+ output = zm.gnrl, tool = "rmarea", threshold = 3000)<br>
--------------------------------------------------<br>
Tool: Threshold<br>
Remove small areas: 3000<br>
--------------------------------------------------<br>
Copying features...<br>
<br>
<br>
<br>
Rebuilding parts of topology...<br>
Building topology for vector map <u10f44b@file480c11cc233b>...<br>
Registering primitives...<br>
703 primitives registered<br>
6033 vertices registered<br>
Building areas...<br>
<br>
<br>
<br>
205 areas built<br>
13 isles built<br>
Attaching islands...<br>
<br>
<br>
<br>
Attaching centroids...<br>
<br>
<br>
<br>
Number of nodes: 306<br>
Number of primitives: 703<br>
Number of points: 0<br>
Number of lines: 0<br>
Number of boundaries: 498<br>
Number of centroids: 205<br>
Number of areas: 205<br>
Number of isles: 13<br>
--------------------------------------------------<br>
Tool: Remove small areas<br>
<br>
<br>
<br>
174 areas of total size 50601.7 removed<br>
--------------------------------------------------<br>
Rebuilding topology for output vector map...<br>
Building topology for vector map <u10f44b@file480c11cc233b>...<br>
Registering primitives...<br>
333 primitives registered<br>
4705 vertices registered<br>
Building areas...<br>
<br>
<br>
<br>
31 areas built<br>
3 isles built<br>
Attaching islands...<br>
<br>
<br>
<br>
Attaching centroids...<br>
<br>
<br>
<br>
Number of nodes: 274<br>
Number of primitives: 333<br>
Number of points: 0<br>
Number of lines: 0<br>
Number of boundaries: 302<br>
Number of centroids: 31<br>
Number of areas: 31<br>
Number of isles: 3<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
zm.fnl <- readVECT(zm.gnrl)<br>
<br>
</blockquote>
<br>
<br>
Error in scan(file, what, nmax, sep, dec, quote, skip, nlines,<br>
na.strings,  :<br>
  line 4 did not have 2 elements<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
sessionInfo()<br>
<br>
</blockquote>
R version 3.2.2 (2015-08-14)<br>
Platform: x86_64-w64-mingw32/x64 (64-bit)<br>
Running under: Windows 7 x64 (build 7601) Service Pack 1<br>
<br>
<br>
<br>
locale:<br>
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United<br>
States.1252    LC_MONETARY=English_United States.1252<br>
[4] LC_NUMERIC=C                           LC_TIME=English_United<br>
States.1252<br>
<br>
<br>
<br>
attached base packages:<br>
[1] stats     graphics  grDevices utils     datasets  methods   base<br>
<br>
<br>
<br>
other attached packages:<br>
 [1] RPyGeo_0.9-3    RSAGA_0.94-3    plyr_1.8.3      gstat_1.0-26<br>
shapefiles_0.7  foreign_0.8-65  maptools_0.8-37 rgdal_1.0-7<br>
 classInt_0.1-23<br>
[10] raster_2.4-20   rgrass7_0.1-3   XML_3.98-1.3    sp_1.2-0<br>
<br>
<br>
<br>
loaded via a namespace (and not attached):<br>
 [1] Rcpp_0.12.1      intervals_0.15.1 lattice_0.20-33  FNN_1.1<br>
spacetime_1.1-4  class_7.3-13     zoo_1.7-12       grid_3.2.2<br>
 [9] e1071_1.6-7      xts_0.9-7        tools_3.2.2<br>
<br>
<br>
<br>
<br>
Thanks<br>
<br>
<br>
<br>
<br>
<br>
<br>
2015-10-08 18:57 GMT-03:00 Roger Bivand<br>
<<a href="mailto:Roger.Bivand@nhh.no" target="_blank">Roger.Bivand@nhh.no</a>>:<br>
<br>
<br>
Sorry this has taken a long time; please try installing the development<br>
version available from:<br>
<br>
<br>
<br>
<a href="http://win-builder.r-project.org/8Y3Ihj451Clx" rel="noreferrer" target="_blank">http://win-builder.r-project.org/8Y3Ihj451Clx</a><br>
<br>
<br>
<br>
(rgrass7_0.1-3.zip). The problem was the use of "_" instead of " " in the<br>
name of the OGR shapefile driver - in OGR and R it is "ESRI Shapefile",<br>
in<br>
GRASS it is "ESRI_Shapefile". Because the new long-name work-around<br>
worked<br>
on systems not needing to use this<br>
 driver, it wasn't properly tested - and on Windows the GRASS standalone<br>
has OGR with the SQLite driver, but the Windows rgdal binary does not<br>
have<br>
SQLite. You may wish to install the R RSQLite package to move data if you<br>
use long field/column names.<br>
<br>
<br>
<br>
Before installing this development version, and after library(rgrass7),<br>
run example(readVECT) in the basic nc location from:<br>
<br>
<br>
<br>
<a href="https://grass.osgeo.org/sampledata/north_carolina/nc_basic_spm_grass7.zip" rel="noreferrer" target="_blank">https://grass.osgeo.org/sampledata/north_carolina/nc_basic_spm_grass7.zip</a><br>
<br>
<br>
<br>
it should fail. Then restart R, install the development version of<br>
rgrass7<br>
from the first link, and repeat - it works for me and should resolve the<br>
problem.<br>
<br>
<br>
<br>
Hope this helps,<br>
<br>
<br>
<br>
Roger<br>
<br>
<br>
<br>
<br>
<br>
--<br>
<br>
Roger Bivand<br>
<br>
Norwegian School of Economics<br>
<br>
Helleveien 30, 5045 Bergen, Norway<br>
<br>
<a href="mailto:Roger.Bivand@nhh.no" target="_blank">Roger.Bivand@nhh.no</a><br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
Fra:<br>
<a href="mailto:grass-stats-bounces@lists.osgeo.org" target="_blank">grass-stats-bounces@lists.osgeo.org</a> [<a href="mailto:grass-stats-bounces@lists.osgeo.org" target="_blank">grass-stats-bounces@lists.osgeo.org</a><br>
]<br>
 på vegne av Eduardo Diez [<a href="mailto:eduardodiez@gmx.com" target="_blank">eduardodiez@gmx.com</a>]<br>
<br>
Sendt: 24. september 2015 9:11<br>
<br>
Til:<br>
<a href="mailto:grass-stats@lists.osgeo.org" target="_blank">grass-stats@lists.osgeo.org</a><br>
<br>
Emne: [GRASS-stats] rgrass7 read/write SpatialPolygonsDataFrames errors<br>
<br>
<br>
<br>
<br>
<br>
<br>
Hi, I'm a user of R mostly for spatial information processing. Besides<br>
sp,<br>
maptools, etc. i also use functions from GRASS, at first through spgrass6<br>
and then rgrass7. A few days ago, I started having trouble reading and<br>
writing SpatialPolygonsDataFrames using<br>
 readVECT and writeVECT. I tried both reinstalling both grass (6.4.4,<br>
7.0.0 and 7.0.1) and the R packages (spgrass6 0.8-6 and rgrass7 0.1-2),<br>
and<br>
also with different R objects but i kept getting the same errors.<br>
<br>
<br>
<br>
<br>
<br>
The "mult.r" object is a RasterLayer with 4 zones and the objective is to<br>
convert it to polygons and "clean" small areas with v.clean rmarea (as i<br>
don't currently know a way of doing this in plain R).<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
The first thing that came out strange was that when executing writeVECT<br>
it<br>
would ask me for the driver to use (in the way of rgdal's writeOGR, it<br>
didn't ask for it before). I figured out that object to be written should<br>
be projected (not in lat-lon, don't know<br>
 why). After doing this i could write the vector and execute v.clean. The<br>
problem came again when trying to read the cleaned polygons back to R.<br>
<br>
Below i paste an extract of my R console with the errors and some<br>
information.<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
Thanks in advance,<br>
<br>
<br>
<br>
Eduardo<br>
<br>
<br>
<br>
<br>
<br>
mult.rp <- projectRaster(mult.r, crs = prj.crs, method = "ngb")<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
</blockquote>
<br>
mult.pol <- rasterToPolygons(mult.rp, dissolve = T)<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
</blockquote>
<br>
<br>
<br>
initGRASS(gisBase = "c:/Program Files (x86)/GRASS GIS 7.0.1", home =<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
</blockquote>
tempdir(), override = T)<br>
<br>
gisdbase    C:/Users/ediez1/AppData/Local/Temp/RtmpegbyiQ<br>
<br>
location    file2f7c6dc070e6<br>
<br>
mapset      file2f7c30eb3f52<br>
<br>
rows        1<br>
<br>
columns     1<br>
<br>
north       1<br>
<br>
south       0<br>
<br>
west        0<br>
<br>
east        1<br>
<br>
nsres       1<br>
<br>
ewres       1<br>
<br>
projection  NA<br>
<br>
writeVECT(mult.pol, "pol1", v.in.ogr_flags = "o")<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
</blockquote>
<br>
Error: !is.null(driver) is not TRUE<br>
<br>
writeVECT(mult.pol, "pol1", v.in.ogr_flags = "o", driver = "ESRI<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
</blockquote>
Shapefile")<br>
<br>
<br>
<br>
Over-riding projection check<br>
<br>
Check if OGR layer <r848659> contains polygons...<br>
<br>
<br>
<br>
<br>
<br>
Importing 4 features (OGR layer <r848659>)...<br>
<br>
<br>
<br>
<br>
<br>
-----------------------------------------------------<br>
<br>
Registering primitives...<br>
<br>
3005 primitives registered<br>
<br>
15587 vertices registered<br>
<br>
Number of nodes: 2691<br>
<br>
Number of primitives: 3005<br>
<br>
Number of points: 0<br>
<br>
Number of lines: 0<br>
<br>
Number of boundaries: 3005<br>
<br>
Number of centroids: 0<br>
<br>
Number of areas: -<br>
<br>
Number of isles: -<br>
<br>
-----------------------------------------------------<br>
<br>
Cleaning polygons<br>
<br>
-----------------------------------------------------<br>
<br>
Breaking polygons...<br>
<br>
Breaking polygons (pass 1: select break points)...<br>
<br>
<br>
<br>
<br>
<br>
Breaking polygons (pass 2: break at selected points)...<br>
<br>
<br>
<br>
<br>
<br>
-----------------------------------------------------<br>
<br>
Removing duplicates...<br>
<br>
<br>
<br>
<br>
<br>
-----------------------------------------------------<br>
<br>
Breaking boundaries...<br>
<br>
<br>
<br>
<br>
<br>
-----------------------------------------------------<br>
<br>
Removing duplicates...<br>
<br>
<br>
<br>
<br>
<br>
-----------------------------------------------------<br>
<br>
Cleaning boundaries at nodes...<br>
<br>
<br>
<br>
<br>
<br>
-----------------------------------------------------<br>
<br>
Merging boundaries...<br>
<br>
<br>
<br>
<br>
<br>
-----------------------------------------------------<br>
<br>
Removing dangles...<br>
<br>
<br>
<br>
<br>
<br>
-----------------------------------------------------<br>
<br>
Building areas...<br>
<br>
<br>
<br>
<br>
<br>
95 areas built<br>
<br>
8 isles built<br>
<br>
Number of nodes: 2771<br>
<br>
Number of primitives: 7307<br>
<br>
Number of points: 0<br>
<br>
Number of lines: 0<br>
<br>
Number of boundaries: 7307<br>
<br>
Number of centroids: 0<br>
<br>
Number of areas: 95<br>
<br>
Number of isles: 8<br>
<br>
-----------------------------------------------------<br>
<br>
Removing bridges...<br>
<br>
<br>
<br>
<br>
<br>
-----------------------------------------------------<br>
<br>
Registering primitives...<br>
<br>
231 primitives registered<br>
<br>
7594 vertices registered<br>
<br>
Building areas...<br>
<br>
<br>
<br>
<br>
<br>
95 areas built<br>
<br>
8 isles built<br>
<br>
Attaching islands...<br>
<br>
<br>
<br>
<br>
<br>
Number of nodes: 144<br>
<br>
Number of primitives: 231<br>
<br>
Number of points: 0<br>
<br>
Number of lines: 0<br>
<br>
Number of boundaries: 231<br>
<br>
Number of centroids: 0<br>
<br>
Number of areas: 95<br>
<br>
Number of isles: 8<br>
<br>
-----------------------------------------------------<br>
<br>
Finding centroids for OGR layer <r848659>...<br>
<br>
<br>
<br>
<br>
<br>
-----------------------------------------------------<br>
<br>
Writing centroids...<br>
<br>
<br>
<br>
<br>
<br>
-----------------------------------------------------<br>
<br>
95 input polygons<br>
<br>
Total area: 1.28981E+006 (95 areas)<br>
<br>
-----------------------------------------------------<br>
<br>
Copying features...<br>
<br>
<br>
<br>
<br>
<br>
WARNING: Unable to delete file<br>
<br>
<br>
<br>
 'C:/Users/ediez1/AppData/Local/Temp/Rtmpg10lvi/filec2473b0126/filec24129b63ac/.tmp/unknown/vector/tmp_10484/coor'<br>
<br>
Building topology for vector map <r848659@filec24129b63ac>...<br>
<br>
Registering primitives...<br>
<br>
326 primitives registered<br>
<br>
7689 vertices registered<br>
<br>
Building areas...<br>
<br>
<br>
<br>
<br>
<br>
95 areas built<br>
<br>
8 isles built<br>
<br>
Attaching islands...<br>
<br>
<br>
<br>
<br>
<br>
Attaching centroids...<br>
<br>
<br>
<br>
<br>
<br>
Number of nodes: 144<br>
<br>
Number of primitives: 326<br>
<br>
Number of points: 0<br>
<br>
Number of lines: 0<br>
<br>
Number of boundaries: 231<br>
<br>
Number of centroids: 95<br>
<br>
Number of areas: 95<br>
<br>
Number of isles: 8<br>
<br>
<br>
<br>
<br>
<br>
execGRASS("v.clean", flags = c("overwrite"), input = "pol1",<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
</blockquote>
<br>
+ output = "clnpol", tool = "rmarea", threshold = 3000)<br>
<br>
--------------------------------------------------<br>
<br>
Tool: Threshold<br>
<br>
Remove small areas: 3000<br>
<br>
--------------------------------------------------<br>
<br>
Copying features...<br>
<br>
<br>
<br>
<br>
<br>
Rebuilding parts of topology...<br>
<br>
Building topology for vector map <k1f9f75@filec24129b63ac>...<br>
<br>
Registering primitives...<br>
<br>
326 primitives registered<br>
<br>
7689 vertices registered<br>
<br>
Building areas...<br>
<br>
<br>
<br>
<br>
<br>
95 areas built<br>
<br>
8 isles built<br>
<br>
Attaching islands...<br>
<br>
<br>
<br>
<br>
<br>
Attaching centroids...<br>
<br>
<br>
<br>
<br>
<br>
Number of nodes: 144<br>
<br>
Number of primitives: 326<br>
<br>
Number of points: 0<br>
<br>
Number of lines: 0<br>
<br>
Number of boundaries: 231<br>
<br>
Number of centroids: 95<br>
<br>
Number of areas: 95<br>
<br>
Number of isles: 8<br>
<br>
--------------------------------------------------<br>
<br>
Tool: Remove small areas<br>
<br>
<br>
<br>
<br>
<br>
55 areas of total size 29487.1 removed<br>
<br>
--------------------------------------------------<br>
<br>
Rebuilding topology for output vector map...<br>
<br>
Building topology for vector map <k1f9f75@filec24129b63ac>...<br>
<br>
Registering primitives...<br>
<br>
212 primitives registered<br>
<br>
6840 vertices registered<br>
<br>
Building areas...<br>
<br>
<br>
<br>
<br>
<br>
40 areas built<br>
<br>
4 isles built<br>
<br>
Attaching islands...<br>
<br>
<br>
<br>
<br>
<br>
Attaching centroids...<br>
<br>
<br>
<br>
<br>
<br>
Number of nodes: 136<br>
<br>
Number of primitives: 212<br>
<br>
Number of points: 0<br>
<br>
Number of lines: 0<br>
<br>
Number of boundaries: 172<br>
<br>
Number of centroids: 40<br>
<br>
Number of areas: 40<br>
<br>
Number of isles: 4<br>
<br>
cln.pol <- readVECT("clnpol")<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
</blockquote>
<br>
Error: !is.null(driver) is not TRUE<br>
<br>
cln.pol <- readVECT("clnpol", driver = "ESRI Shapefile")<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
</blockquote>
<br>
Error in scan(file, what, nmax, sep, dec, quote, skip, nlines,<br>
na.strings,  :<br>
<br>
  line 4 did not have 2 elements<br>
<br>
<br>
<br>
<br>
<br>
sessionInfo()<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
</blockquote>
<br>
R version 3.2.2 (2015-08-14)<br>
<br>
Platform: x86_64-w64-mingw32/x64 (64-bit)<br>
<br>
Running under: Windows 7 x64 (build 7601) Service Pack 1<br>
<br>
<br>
<br>
<br>
<br>
locale:<br>
<br>
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United<br>
States.1252    LC_MONETARY=English_United States.1252<br>
<br>
[4] LC_NUMERIC=C                           LC_TIME=English_United<br>
States.1252<br>
<br>
<br>
<br>
<br>
<br>
attached base packages:<br>
<br>
[1] stats     graphics  grDevices utils     datasets  methods   base<br>
<br>
<br>
<br>
<br>
<br>
other attached packages:<br>
<br>
[1] rgrass7_0.1-2   classInt_0.1-22 maptools_0.8-36 ggplot2_1.0.1<br>
 XML_3.98-1.3    raster_2.4-20   sp_1.2-0<br>
<br>
<br>
<br>
<br>
<br>
loaded via a namespace (and not attached):<br>
<br>
 [1] Rcpp_0.12.1      magrittr_1.5     MASS_7.3-43      munsell_0.4.2<br>
colorspace_1.2-6 lattice_0.20-33  stringr_1.0.0    plyr_1.8.3<br>
<br>
 [9] tools_3.2.2      parallel_3.2.2   rgdal_1.0-7      grid_3.2.2<br>
 gtable_0.1.2     e1071_1.6-7      class_7.3-13     rgeos_0.3-12<br>
<br>
[17] digest_0.6.8     reshape2_1.4.1   labeling_0.3     stringi_0.5-5<br>
scales_0.3.0     foreign_0.8-65   proto_0.3-10<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
_______________________________________________<br>
grass-stats mailing list<br>
<a href="mailto:grass-stats@lists.osgeo.org" target="_blank">grass-stats@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/grass-stats" rel="noreferrer" target="_blank">http://lists.osgeo.org/mailman/listinfo/grass-stats</a><br>
<br>
<br>
</blockquote>
<br>
</blockquote>
--<br>
Roger Bivand<br>
Department of Economics, Norwegian School of Economics,<br>
Helleveien 30, N-5045 Bergen, Norway.<br>
voice: +47 55 95 93 55; fax +47 55 95 91 00<br>
e-mail: <a href="mailto:Roger.Bivand@nhh.no" target="_blank">Roger.Bivand@nhh.no</a><br>
<br>
</blockquote>
<br>
</div></div></blockquote><div class="HOEnZb"><div class="h5">
<br>
-- <br>
Roger Bivand<br>
Department of Economics, Norwegian School of Economics,<br>
Helleveien 30, N-5045 Bergen, Norway.<br>
voice: +47 55 95 93 55; fax +47 55 95 91 00<br>
e-mail: <a href="mailto:Roger.Bivand@nhh.no" target="_blank">Roger.Bivand@nhh.no</a><br>
</div></div></blockquote></div><br></div>