<div dir="ltr"><div style="font-size:12.8000001907349px">Hi, I'm a user of R mostly for spatial information processing. Besides sp, maptools, etc. i also use functions from GRASS, at first through spgrass6 and then rgrass7. A few days ago, I started having trouble reading and writing SpatialPolygonsDataFrames using readVECT and writeVECT. I tried both reinstalling both grass (6.4.4, 7.0.0 and 7.0.1) and the R packages (spgrass6 0.8-6 and rgrass7 0.1-2), and also with different R objects but i kept getting the same errors.</div><div style="font-size:12.8000001907349px"><br></div><div style="font-size:12.8000001907349px"><div style="font-size:12.8000001907349px"><span style="font-size:12.8000001907349px">The "mult.r" object is a RasterLayer with 4 zones and the objective is to convert it to polygons and "clean" small areas with v.clean rmarea (as i don't currently know a way of doing this in plain R).</span><br></div><div><span style="font-size:12.8000001907349px"><br></span></div></div><div style="font-size:12.8000001907349px">The first thing that came out strange was that when executing writeVECT it would ask me for the driver to use (in the way of rgdal's writeOGR, it didn't ask for it before). I figured out that object to be written should be projected (not in lat-lon, don't know why). After doing this i could write the vector and execute v.clean. The problem came again when trying to read the cleaned polygons back to R.</div><div style="font-size:12.8000001907349px"><div style="font-size:12.8000001907349px">Below i paste an extract of my R console with the errors and some information.<br></div><div><br></div></div><div style="font-size:12.8000001907349px"><span style="font-size:12.8000001907349px">Thanks in advance,</span><br></div><div style="font-size:12.8000001907349px">Eduardo</div><div style="font-size:12.8000001907349px"><br></div><div style="font-size:12.8000001907349px">> mult.rp <- projectRaster(mult.r, crs = prj.crs, method = "ngb")</div><div style="font-size:12.8000001907349px"><span style="font-size:12.8000001907349px">> mult.pol <- rasterToPolygons(mult.rp, dissolve = T)</span><br></div><div><div style="font-size:12.8000001907349px">> initGRASS(gisBase = "c:/Program Files (x86)/GRASS GIS 7.0.1", home = tempdir(), override = T)</div><div style="font-size:12.8000001907349px">gisdbase    C:/Users/ediez1/AppData/Local/Temp/RtmpegbyiQ </div><div style="font-size:12.8000001907349px">location    file2f7c6dc070e6 </div><div style="font-size:12.8000001907349px">mapset      file2f7c30eb3f52 </div><div style="font-size:12.8000001907349px">rows        1 </div><div style="font-size:12.8000001907349px">columns     1 </div><div style="font-size:12.8000001907349px">north       1 </div><div style="font-size:12.8000001907349px">south       0 </div><div style="font-size:12.8000001907349px">west        0 </div><div style="font-size:12.8000001907349px">east        1 </div><div style="font-size:12.8000001907349px">nsres       1 </div><div style="font-size:12.8000001907349px">ewres       1 </div><div style="font-size:12.8000001907349px">projection  NA </div><div><span style="font-size:12.8000001907349px">> writeVECT(mult.pol, "pol1", v.in.ogr_flags = "o")</span></div><div><span style="font-size:12.8000001907349px">Error: !is.null(driver) is not TRUE</span></div><div style="font-size:12.8000001907349px">> writeVECT(mult.pol, "pol1", v.in.ogr_flags = "o", driver = "ESRI Shapefile")<br></div><div style=""><div style=""><span style="font-size:12.8000001907349px">Over-riding projection check</span></div><div style=""><span style="font-size:12.8000001907349px">Check if OGR layer <r848659> contains polygons...</span></div><div style=""><span style="font-size:12.8000001907349px"><br></span></div><div style=""><span style="font-size:12.8000001907349px">Importing 4 features (OGR layer <r848659>)...</span></div><div style=""><span style="font-size:12.8000001907349px"><br></span></div><div style=""><span style="font-size:12.8000001907349px">-----------------------------------------------------</span></div><div style=""><span style="font-size:12.8000001907349px">Registering primitives...</span></div><div style=""><span style="font-size:12.8000001907349px">3005 primitives registered</span></div><div style=""><span style="font-size:12.8000001907349px">15587 vertices registered</span></div><div style=""><span style="font-size:12.8000001907349px">Number of nodes: 2691</span></div><div style=""><span style="font-size:12.8000001907349px">Number of primitives: 3005</span></div><div style=""><span style="font-size:12.8000001907349px">Number of points: 0</span></div><div style=""><span style="font-size:12.8000001907349px">Number of lines: 0</span></div><div style=""><span style="font-size:12.8000001907349px">Number of boundaries: 3005</span></div><div style=""><span style="font-size:12.8000001907349px">Number of centroids: 0</span></div><div style=""><span style="font-size:12.8000001907349px">Number of areas: -</span></div><div style=""><span style="font-size:12.8000001907349px">Number of isles: -</span></div><div style=""><span style="font-size:12.8000001907349px">-----------------------------------------------------</span></div><div style=""><span style="font-size:12.8000001907349px">Cleaning polygons</span></div><div style=""><span style="font-size:12.8000001907349px">-----------------------------------------------------</span></div><div style=""><span style="font-size:12.8000001907349px">Breaking polygons...</span></div><div style=""><span style="font-size:12.8000001907349px">Breaking polygons (pass 1: select break points)...</span></div><div style=""><span style="font-size:12.8000001907349px"><br></span></div><div style=""><span style="font-size:12.8000001907349px">Breaking polygons (pass 2: break at selected points)...</span></div><div style=""><span style="font-size:12.8000001907349px"><br></span></div><div style=""><span style="font-size:12.8000001907349px">-----------------------------------------------------</span></div><div style=""><span style="font-size:12.8000001907349px">Removing duplicates...</span></div><div style=""><span style="font-size:12.8000001907349px"><br></span></div><div style=""><span style="font-size:12.8000001907349px">-----------------------------------------------------</span></div><div style=""><span style="font-size:12.8000001907349px">Breaking boundaries...</span></div><div style=""><span style="font-size:12.8000001907349px"><br></span></div><div style=""><span style="font-size:12.8000001907349px">-----------------------------------------------------</span></div><div style=""><span style="font-size:12.8000001907349px">Removing duplicates...</span></div><div style=""><span style="font-size:12.8000001907349px"><br></span></div><div style=""><span style="font-size:12.8000001907349px">-----------------------------------------------------</span></div><div style=""><span style="font-size:12.8000001907349px">Cleaning boundaries at nodes...</span></div><div style=""><span style="font-size:12.8000001907349px"><br></span></div><div style=""><span style="font-size:12.8000001907349px">-----------------------------------------------------</span></div><div style=""><span style="font-size:12.8000001907349px">Merging boundaries...</span></div><div style=""><span style="font-size:12.8000001907349px"><br></span></div><div style=""><span style="font-size:12.8000001907349px">-----------------------------------------------------</span></div><div style=""><span style="font-size:12.8000001907349px">Removing dangles...</span></div><div style=""><span style="font-size:12.8000001907349px"><br></span></div><div style=""><span style="font-size:12.8000001907349px">-----------------------------------------------------</span></div><div style=""><span style="font-size:12.8000001907349px">Building areas...</span></div><div style=""><span style="font-size:12.8000001907349px"><br></span></div><div style=""><span style="font-size:12.8000001907349px">95 areas built</span></div><div style=""><span style="font-size:12.8000001907349px">8 isles built</span></div><div style=""><span style="font-size:12.8000001907349px">Number of nodes: 2771</span></div><div style=""><span style="font-size:12.8000001907349px">Number of primitives: 7307</span></div><div style=""><span style="font-size:12.8000001907349px">Number of points: 0</span></div><div style=""><span style="font-size:12.8000001907349px">Number of lines: 0</span></div><div style=""><span style="font-size:12.8000001907349px">Number of boundaries: 7307</span></div><div style=""><span style="font-size:12.8000001907349px">Number of centroids: 0</span></div><div style=""><span style="font-size:12.8000001907349px">Number of areas: 95</span></div><div style=""><span style="font-size:12.8000001907349px">Number of isles: 8</span></div><div style=""><span style="font-size:12.8000001907349px">-----------------------------------------------------</span></div><div style=""><span style="font-size:12.8000001907349px">Removing bridges...</span></div><div style=""><span style="font-size:12.8000001907349px"><br></span></div><div style=""><span style="font-size:12.8000001907349px">-----------------------------------------------------</span></div><div style=""><span style="font-size:12.8000001907349px">Registering primitives...</span></div><div style=""><span style="font-size:12.8000001907349px">231 primitives registered</span></div><div style=""><span style="font-size:12.8000001907349px">7594 vertices registered</span></div><div style=""><span style="font-size:12.8000001907349px">Building areas...</span></div><div style=""><span style="font-size:12.8000001907349px"><br></span></div><div style=""><span style="font-size:12.8000001907349px">95 areas built</span></div><div style=""><span style="font-size:12.8000001907349px">8 isles built</span></div><div style=""><span style="font-size:12.8000001907349px">Attaching islands...</span></div><div style=""><span style="font-size:12.8000001907349px"><br></span></div><div style=""><span style="font-size:12.8000001907349px">Number of nodes: 144</span></div><div style=""><span style="font-size:12.8000001907349px">Number of primitives: 231</span></div><div style=""><span style="font-size:12.8000001907349px">Number of points: 0</span></div><div style=""><span style="font-size:12.8000001907349px">Number of lines: 0</span></div><div style=""><span style="font-size:12.8000001907349px">Number of boundaries: 231</span></div><div style=""><span style="font-size:12.8000001907349px">Number of centroids: 0</span></div><div style=""><span style="font-size:12.8000001907349px">Number of areas: 95</span></div><div style=""><span style="font-size:12.8000001907349px">Number of isles: 8</span></div><div style=""><span style="font-size:12.8000001907349px">-----------------------------------------------------</span></div><div style=""><span style="font-size:12.8000001907349px">Finding centroids for OGR layer <r848659>...</span></div><div style=""><span style="font-size:12.8000001907349px"><br></span></div><div style=""><span style="font-size:12.8000001907349px">-----------------------------------------------------</span></div><div style=""><span style="font-size:12.8000001907349px">Writing centroids...</span></div><div style=""><span style="font-size:12.8000001907349px"><br></span></div><div style=""><span style="font-size:12.8000001907349px">-----------------------------------------------------</span></div><div style=""><span style="font-size:12.8000001907349px">95 input polygons</span></div><div style=""><span style="font-size:12.8000001907349px">Total area: 1.28981E+006 (95 areas)</span></div><div style=""><span style="font-size:12.8000001907349px">-----------------------------------------------------</span></div><div style=""><span style="font-size:12.8000001907349px">Copying features...</span></div><div style=""><span style="font-size:12.8000001907349px"><br></span></div><div style=""><span style="font-size:12.8000001907349px">WARNING: Unable to delete file</span></div><div style=""><span style="font-size:12.8000001907349px">         'C:/Users/ediez1/AppData/Local/Temp/Rtmpg10lvi/filec2473b0126/filec24129b63ac/.tmp/unknown/vector/tmp_10484/coor'</span></div><div style=""><span style="font-size:12.8000001907349px">Building topology for vector map <r848659@filec24129b63ac>...</span></div><div style=""><span style="font-size:12.8000001907349px">Registering primitives...</span></div><div style=""><span style="font-size:12.8000001907349px">326 primitives registered</span></div><div style=""><span style="font-size:12.8000001907349px">7689 vertices registered</span></div><div style=""><span style="font-size:12.8000001907349px">Building areas...</span></div><div style=""><span style="font-size:12.8000001907349px"><br></span></div><div style=""><span style="font-size:12.8000001907349px">95 areas built</span></div><div style=""><span style="font-size:12.8000001907349px">8 isles built</span></div><div style=""><span style="font-size:12.8000001907349px">Attaching islands...</span></div><div style=""><span style="font-size:12.8000001907349px"><br></span></div><div style=""><span style="font-size:12.8000001907349px">Attaching centroids...</span></div><div style=""><span style="font-size:12.8000001907349px"><br></span></div><div style=""><span style="font-size:12.8000001907349px">Number of nodes: 144</span></div><div style=""><span style="font-size:12.8000001907349px">Number of primitives: 326</span></div><div style=""><span style="font-size:12.8000001907349px">Number of points: 0</span></div><div style=""><span style="font-size:12.8000001907349px">Number of lines: 0</span></div><div style=""><span style="font-size:12.8000001907349px">Number of boundaries: 231</span></div><div style=""><span style="font-size:12.8000001907349px">Number of centroids: 95</span></div><div style=""><span style="font-size:12.8000001907349px">Number of areas: 95</span></div><div style=""><span style="font-size:12.8000001907349px">Number of isles: 8</span></div></div></div><div style="font-size:12.8000001907349px"><br></div><div style=""><div style=""><span style="font-size:12.8000001907349px">> execGRASS("v.clean", flags = c("overwrite"), input = "pol1",</span></div><div style=""><span style="font-size:12.8000001907349px">+ output = "clnpol", tool = "rmarea", threshold = 3000)</span></div><div style=""><span style="font-size:12.8000001907349px">--------------------------------------------------</span></div><div style=""><span style="font-size:12.8000001907349px">Tool: Threshold</span></div><div style=""><span style="font-size:12.8000001907349px">Remove small areas: 3000</span></div><div style=""><span style="font-size:12.8000001907349px">--------------------------------------------------</span></div><div style=""><span style="font-size:12.8000001907349px">Copying features...</span></div><div style=""><span style="font-size:12.8000001907349px"><br></span></div><div style=""><span style="font-size:12.8000001907349px">Rebuilding parts of topology...</span></div><div style=""><span style="font-size:12.8000001907349px">Building topology for vector map <k1f9f75@filec24129b63ac>...</span></div><div style=""><span style="font-size:12.8000001907349px">Registering primitives...</span></div><div style=""><span style="font-size:12.8000001907349px">326 primitives registered</span></div><div style=""><span style="font-size:12.8000001907349px">7689 vertices registered</span></div><div style=""><span style="font-size:12.8000001907349px">Building areas...</span></div><div style=""><span style="font-size:12.8000001907349px"><br></span></div><div style=""><span style="font-size:12.8000001907349px">95 areas built</span></div><div style=""><span style="font-size:12.8000001907349px">8 isles built</span></div><div style=""><span style="font-size:12.8000001907349px">Attaching islands...</span></div><div style=""><span style="font-size:12.8000001907349px"><br></span></div><div style=""><span style="font-size:12.8000001907349px">Attaching centroids...</span></div><div style=""><span style="font-size:12.8000001907349px"><br></span></div><div style=""><span style="font-size:12.8000001907349px">Number of nodes: 144</span></div><div style=""><span style="font-size:12.8000001907349px">Number of primitives: 326</span></div><div style=""><span style="font-size:12.8000001907349px">Number of points: 0</span></div><div style=""><span style="font-size:12.8000001907349px">Number of lines: 0</span></div><div style=""><span style="font-size:12.8000001907349px">Number of boundaries: 231</span></div><div style=""><span style="font-size:12.8000001907349px">Number of centroids: 95</span></div><div style=""><span style="font-size:12.8000001907349px">Number of areas: 95</span></div><div style=""><span style="font-size:12.8000001907349px">Number of isles: 8</span></div><div style=""><span style="font-size:12.8000001907349px">--------------------------------------------------</span></div><div style=""><span style="font-size:12.8000001907349px">Tool: Remove small areas</span></div><div style=""><span style="font-size:12.8000001907349px"><br></span></div><div style=""><span style="font-size:12.8000001907349px">55 areas of total size 29487.1 removed</span></div><div style=""><span style="font-size:12.8000001907349px">--------------------------------------------------</span></div><div style=""><span style="font-size:12.8000001907349px">Rebuilding topology for output vector map...</span></div><div style=""><span style="font-size:12.8000001907349px">Building topology for vector map <k1f9f75@filec24129b63ac>...</span></div><div style=""><span style="font-size:12.8000001907349px">Registering primitives...</span></div><div style=""><span style="font-size:12.8000001907349px">212 primitives registered</span></div><div style=""><span style="font-size:12.8000001907349px">6840 vertices registered</span></div><div style=""><span style="font-size:12.8000001907349px">Building areas...</span></div><div style=""><span style="font-size:12.8000001907349px"><br></span></div><div style=""><span style="font-size:12.8000001907349px">40 areas built</span></div><div style=""><span style="font-size:12.8000001907349px">4 isles built</span></div><div style=""><span style="font-size:12.8000001907349px">Attaching islands...</span></div><div style=""><span style="font-size:12.8000001907349px"><br></span></div><div style=""><span style="font-size:12.8000001907349px">Attaching centroids...</span></div><div style=""><span style="font-size:12.8000001907349px"><br></span></div><div style=""><span style="font-size:12.8000001907349px">Number of nodes: 136</span></div><div style=""><span style="font-size:12.8000001907349px">Number of primitives: 212</span></div><div style=""><span style="font-size:12.8000001907349px">Number of points: 0</span></div><div style=""><span style="font-size:12.8000001907349px">Number of lines: 0</span></div><div style=""><span style="font-size:12.8000001907349px">Number of boundaries: 172</span></div><div style=""><span style="font-size:12.8000001907349px">Number of centroids: 40</span></div><div style=""><span style="font-size:12.8000001907349px">Number of areas: 40</span></div><div style=""><span style="font-size:12.8000001907349px">Number of isles: 4</span></div><div style=""><span style="font-size:12.8000001907349px">> cln.pol <- readVECT("clnpol")</span></div><div style=""><span style="font-size:12.8000001907349px">Error: !is.null(driver) is not TRUE</span></div><div style=""><span style="font-size:12.8000001907349px">> cln.pol <- readVECT("clnpol", driver = "ESRI Shapefile")</span></div><div style=""><span style="font-size:12.8000001907349px">Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings,  : </span></div><div style=""><span style="font-size:12.8000001907349px">  line 4 did not have 2 elements</span></div></div><div style="font-size:12.8000001907349px"><br></div><div style="font-size:12.8000001907349px"><div>> sessionInfo()</div><div>R version 3.2.2 (2015-08-14)</div><div>Platform: x86_64-w64-mingw32/x64 (64-bit)</div><div>Running under: Windows 7 x64 (build 7601) Service Pack 1</div><div><br></div><div>locale:</div><div>[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252    LC_MONETARY=English_United States.1252</div><div>[4] LC_NUMERIC=C                           LC_TIME=English_United States.1252    </div><div><br></div><div>attached base packages:</div><div>[1] stats     graphics  grDevices utils     datasets  methods   base     </div><div><br></div><div>other attached packages:</div><div>[1] rgrass7_0.1-2   classInt_0.1-22 maptools_0.8-36 ggplot2_1.0.1   XML_3.98-1.3    raster_2.4-20   sp_1.2-0       </div><div><br></div><div>loaded via a namespace (and not attached):</div><div> [1] Rcpp_0.12.1      magrittr_1.5     MASS_7.3-43      munsell_0.4.2    colorspace_1.2-6 lattice_0.20-33  stringr_1.0.0    plyr_1.8.3      </div><div> [9] tools_3.2.2      parallel_3.2.2   rgdal_1.0-7      grid_3.2.2       gtable_0.1.2     e1071_1.6-7      class_7.3-13     rgeos_0.3-12    </div><div>[17] digest_0.6.8     reshape2_1.4.1   labeling_0.3     stringi_0.5-5    scales_0.3.0     foreign_0.8-65   proto_0.3-10    </div></div></div>