Discussion:
[GRASS-stats] rgrass7 read/write SpatialPolygonsDataFrames errors
Eduardo Diez
2015-09-24 19:11:02 UTC
Permalink
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.

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).

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.
Below i paste an extract of my R console with the errors and some
information.

Thanks in advance,
Eduardo

> mult.rp <- projectRaster(mult.r, crs = prj.crs, method = "ngb")
> mult.pol <- rasterToPolygons(mult.rp, dissolve = T)
> initGRASS(gisBase = "c:/Program Files (x86)/GRASS GIS 7.0.1", home =
tempdir(), override = T)
gisdbase C:/Users/ediez1/AppData/Local/Temp/RtmpegbyiQ
location file2f7c6dc070e6
mapset file2f7c30eb3f52
rows 1
columns 1
north 1
south 0
west 0
east 1
nsres 1
ewres 1
projection NA
> writeVECT(mult.pol, "pol1", v.in.ogr_flags = "o")
Error: !is.null(driver) is not TRUE
> writeVECT(mult.pol, "pol1", v.in.ogr_flags = "o", driver = "ESRI
Shapefile")
Over-riding projection check
Check if OGR layer <r848659> contains polygons...

Importing 4 features (OGR layer <r848659>)...

-----------------------------------------------------
Registering primitives...
3005 primitives registered
15587 vertices registered
Number of nodes: 2691
Number of primitives: 3005
Number of points: 0
Number of lines: 0
Number of boundaries: 3005
Number of centroids: 0
Number of areas: -
Number of isles: -
-----------------------------------------------------
Cleaning polygons
-----------------------------------------------------
Breaking polygons...
Breaking polygons (pass 1: select break points)...

Breaking polygons (pass 2: break at selected points)...

-----------------------------------------------------
Removing duplicates...

-----------------------------------------------------
Breaking boundaries...

-----------------------------------------------------
Removing duplicates...

-----------------------------------------------------
Cleaning boundaries at nodes...

-----------------------------------------------------
Merging boundaries...

-----------------------------------------------------
Removing dangles...

-----------------------------------------------------
Building areas...

95 areas built
8 isles built
Number of nodes: 2771
Number of primitives: 7307
Number of points: 0
Number of lines: 0
Number of boundaries: 7307
Number of centroids: 0
Number of areas: 95
Number of isles: 8
-----------------------------------------------------
Removing bridges...

-----------------------------------------------------
Registering primitives...
231 primitives registered
7594 vertices registered
Building areas...

95 areas built
8 isles built
Attaching islands...

Number of nodes: 144
Number of primitives: 231
Number of points: 0
Number of lines: 0
Number of boundaries: 231
Number of centroids: 0
Number of areas: 95
Number of isles: 8
-----------------------------------------------------
Finding centroids for OGR layer <r848659>...

-----------------------------------------------------
Writing centroids...

-----------------------------------------------------
95 input polygons
Total area: 1.28981E+006 (95 areas)
-----------------------------------------------------
Copying features...

WARNING: Unable to delete file

'C:/Users/ediez1/AppData/Local/Temp/Rtmpg10lvi/filec2473b0126/filec24129b63ac/.tmp/unknown/vector/tmp_10484/coor'
Building topology for vector map <***@filec24129b63ac>...
Registering primitives...
326 primitives registered
7689 vertices registered
Building areas...

95 areas built
8 isles built
Attaching islands...

Attaching centroids...

Number of nodes: 144
Number of primitives: 326
Number of points: 0
Number of lines: 0
Number of boundaries: 231
Number of centroids: 95
Number of areas: 95
Number of isles: 8

> execGRASS("v.clean", flags = c("overwrite"), input = "pol1",
+ output = "clnpol", tool = "rmarea", threshold = 3000)
--------------------------------------------------
Tool: Threshold
Remove small areas: 3000
--------------------------------------------------
Copying features...

Rebuilding parts of topology...
Building topology for vector map <***@filec24129b63ac>...
Registering primitives...
326 primitives registered
7689 vertices registered
Building areas...

95 areas built
8 isles built
Attaching islands...

Attaching centroids...

Number of nodes: 144
Number of primitives: 326
Number of points: 0
Number of lines: 0
Number of boundaries: 231
Number of centroids: 95
Number of areas: 95
Number of isles: 8
--------------------------------------------------
Tool: Remove small areas

55 areas of total size 29487.1 removed
--------------------------------------------------
Rebuilding topology for output vector map...
Building topology for vector map <***@filec24129b63ac>...
Registering primitives...
212 primitives registered
6840 vertices registered
Building areas...

40 areas built
4 isles built
Attaching islands...

Attaching centroids...

Number of nodes: 136
Number of primitives: 212
Number of points: 0
Number of lines: 0
Number of boundaries: 172
Number of centroids: 40
Number of areas: 40
Number of isles: 4
> cln.pol <- readVECT("clnpol")
Error: !is.null(driver) is not TRUE
> cln.pol <- readVECT("clnpol", driver = "ESRI Shapefile")
Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings,
:
line 4 did not have 2 elements

> sessionInfo()
R version 3.2.2 (2015-08-14)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1

locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United
States.1252 LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C LC_TIME=English_United
States.1252

attached base packages:
[1] stats graphics grDevices utils datasets methods base

other attached packages:
[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

loaded via a namespace (and not attached):
[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
[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
[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
Roger Bivand
2015-10-08 21:57:40 UTC
Permalink
Sorry this has taken a long time; please try installing the development version available from:

http://win-builder.r-project.org/8Y3Ihj451Clx

(rgrass7_0.1-3.zip). The problem was the use of "_" instead of " " in the name of the OGR shapefile driver - in OGR and R it is "ESRI Shapefile", in GRASS it is "ESRI_Shapefile". Because the new long-name work-around worked on systems not needing to use this driver, it wasn't properly tested - and on Windows the GRASS standalone has OGR with the SQLite driver, but the Windows rgdal binary does not have SQLite. You may wish to install the R RSQLite package to move data if you use long field/column names.

Before installing this development version, and after library(rgrass7), run example(readVECT) in the basic nc location from:

https://grass.osgeo.org/sampledata/north_carolina/nc_basic_spm_grass7.zip

it should fail. Then restart R, install the development version of rgrass7 from the first link, and repeat - it works for me and should resolve the problem.

Hope this helps,

Roger


--
Roger Bivand
Norwegian School of Economics
Helleveien 30, 5045 Bergen, Norway
***@nhh.no





Fra: grass-stats-***@lists.osgeo.org [grass-stats-***@lists.osgeo.org] på vegne av Eduardo Diez [***@gmx.com]
Sendt: 24. september 2015 9:11
Til: grass-***@lists.osgeo.org
Emne: [GRASS-stats] rgrass7 read/write SpatialPolygonsDataFrames errors


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.


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).



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.
Below i paste an extract of my R console with the errors and some information.



Thanks in advance,

Eduardo


> mult.rp <- projectRaster(mult.r, crs = prj.crs, method = "ngb")
> mult.pol <- rasterToPolygons(mult.rp, dissolve = T)

> initGRASS(gisBase = "c:/Program Files (x86)/GRASS GIS 7.0.1", home = tempdir(), override = T)
gisdbase C:/Users/ediez1/AppData/Local/Temp/RtmpegbyiQ
location file2f7c6dc070e6
mapset file2f7c30eb3f52
rows 1
columns 1
north 1
south 0
west 0
east 1
nsres 1
ewres 1
projection NA
> writeVECT(mult.pol, "pol1", v.in.ogr_flags = "o")
Error: !is.null(driver) is not TRUE
> writeVECT(mult.pol, "pol1", v.in.ogr_flags = "o", driver = "ESRI Shapefile")

Over-riding projection check
Check if OGR layer <r848659> contains polygons...


Importing 4 features (OGR layer <r848659>)...


-----------------------------------------------------
Registering primitives...
3005 primitives registered
15587 vertices registered
Number of nodes: 2691
Number of primitives: 3005
Number of points: 0
Number of lines: 0
Number of boundaries: 3005
Number of centroids: 0
Number of areas: -
Number of isles: -
-----------------------------------------------------
Cleaning polygons
-----------------------------------------------------
Breaking polygons...
Breaking polygons (pass 1: select break points)...


Breaking polygons (pass 2: break at selected points)...


-----------------------------------------------------
Removing duplicates...


-----------------------------------------------------
Breaking boundaries...


-----------------------------------------------------
Removing duplicates...


-----------------------------------------------------
Cleaning boundaries at nodes...


-----------------------------------------------------
Merging boundaries...


-----------------------------------------------------
Removing dangles...


-----------------------------------------------------
Building areas...


95 areas built
8 isles built
Number of nodes: 2771
Number of primitives: 7307
Number of points: 0
Number of lines: 0
Number of boundaries: 7307
Number of centroids: 0
Number of areas: 95
Number of isles: 8
-----------------------------------------------------
Removing bridges...


-----------------------------------------------------
Registering primitives...
231 primitives registered
7594 vertices registered
Building areas...


95 areas built
8 isles built
Attaching islands...


Number of nodes: 144
Number of primitives: 231
Number of points: 0
Number of lines: 0
Number of boundaries: 231
Number of centroids: 0
Number of areas: 95
Number of isles: 8
-----------------------------------------------------
Finding centroids for OGR layer <r848659>...


-----------------------------------------------------
Writing centroids...


-----------------------------------------------------
95 input polygons
Total area: 1.28981E+006 (95 areas)
-----------------------------------------------------
Copying features...


WARNING: Unable to delete file
'C:/Users/ediez1/AppData/Local/Temp/Rtmpg10lvi/filec2473b0126/filec24129b63ac/.tmp/unknown/vector/tmp_10484/coor'
Building topology for vector map <***@filec24129b63ac>...
Registering primitives...
326 primitives registered
7689 vertices registered
Building areas...


95 areas built
8 isles built
Attaching islands...


Attaching centroids...


Number of nodes: 144
Number of primitives: 326
Number of points: 0
Number of lines: 0
Number of boundaries: 231
Number of centroids: 95
Number of areas: 95
Number of isles: 8


> execGRASS("v.clean", flags = c("overwrite"), input = "pol1",
+ output = "clnpol", tool = "rmarea", threshold = 3000)
--------------------------------------------------
Tool: Threshold
Remove small areas: 3000
--------------------------------------------------
Copying features...


Rebuilding parts of topology...
Building topology for vector map <***@filec24129b63ac>...
Registering primitives...
326 primitives registered
7689 vertices registered
Building areas...


95 areas built
8 isles built
Attaching islands...


Attaching centroids...


Number of nodes: 144
Number of primitives: 326
Number of points: 0
Number of lines: 0
Number of boundaries: 231
Number of centroids: 95
Number of areas: 95
Number of isles: 8
--------------------------------------------------
Tool: Remove small areas


55 areas of total size 29487.1 removed
--------------------------------------------------
Rebuilding topology for output vector map...
Building topology for vector map <***@filec24129b63ac>...
Registering primitives...
212 primitives registered
6840 vertices registered
Building areas...


40 areas built
4 isles built
Attaching islands...


Attaching centroids...


Number of nodes: 136
Number of primitives: 212
Number of points: 0
Number of lines: 0
Number of boundaries: 172
Number of centroids: 40
Number of areas: 40
Number of isles: 4
> cln.pol <- readVECT("clnpol")
Error: !is.null(driver) is not TRUE
> cln.pol <- readVECT("clnpol", driver = "ESRI Shapefile")
Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings, :
line 4 did not have 2 elements


> sessionInfo()
R version 3.2.2 (2015-08-14)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1


locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C LC_TIME=English_United States.1252


attached base packages:
[1] stats graphics grDevices utils datasets methods base


other attached packages:
[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


loaded via a namespace (and not attached):
[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
[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
[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
Eduardo Diez
2015-10-09 14:04:10 UTC
Permalink
Roger, with GRASS version 7.0.1 and rgrass7_0.1-3, readVECT now doesn't ask
for the driver to use but gives the same error as before:

writeVECT(SDF = mz.pol, vname = zm.pol, v.in.ogr_flags = "o")
Over-riding projection check
Check if OGR layer <q7468fb> contains polygons...

Importing 205 features (OGR layer <q7468fb>)...

-----------------------------------------------------
Registering primitives...
3924 primitives registered
12866 vertices registered
Number of nodes: 2884
Number of primitives: 3924
Number of points: 0
Number of lines: 0
Number of boundaries: 3924
Number of centroids: 0
Number of areas: -
Number of isles: -
-----------------------------------------------------
Cleaning polygons
-----------------------------------------------------
Breaking polygons...
Breaking polygons (pass 1: select break points)...

Breaking polygons (pass 2: break at selected points)...

-----------------------------------------------------
Removing duplicates...

-----------------------------------------------------
Breaking boundaries...

-----------------------------------------------------
Removing duplicates...

-----------------------------------------------------
Cleaning boundaries at nodes...

-----------------------------------------------------
Merging boundaries...

-----------------------------------------------------
Removing dangles...

-----------------------------------------------------
Building areas...

205 areas built
13 isles built
Number of nodes: 2929
Number of primitives: 7268
Number of points: 0
Number of lines: 0
Number of boundaries: 7268
Number of centroids: 0
Number of areas: 205
Number of isles: 13
-----------------------------------------------------
Removing bridges...

-----------------------------------------------------
Registering primitives...
498 primitives registered
5828 vertices registered
Building areas...

205 areas built
13 isles built
Attaching islands...

Number of nodes: 306
Number of primitives: 498
Number of points: 0
Number of lines: 0
Number of boundaries: 498
Number of centroids: 0
Number of areas: 205
Number of isles: 13
-----------------------------------------------------
Finding centroids for OGR layer <q7468fb>...

-----------------------------------------------------
Writing centroids...

-----------------------------------------------------
205 input polygons
Total area: 1.25187E+006 (205 areas)
-----------------------------------------------------
Copying features...

WARNING: Unable to delete file

'C:/Users/ediez1/AppData/Local/Temp/Rtmpqkeay4/file480c1e5e16a7/file480c11cc233b/.tmp/unknown/vector/tmp_8308/coor'
Building topology for vector map <***@file480c11cc233b>...
Registering primitives...
703 primitives registered
6033 vertices registered
Building areas...

205 areas built
13 isles built
Attaching islands...

Attaching centroids...

Number of nodes: 306
Number of primitives: 703
Number of points: 0
Number of lines: 0
Number of boundaries: 498
Number of centroids: 205
Number of areas: 205
Number of isles: 13
> execGRASS("v.clean", flags = c("overwrite"), input = zm.pol,
+ output = zm.gnrl, tool = "rmarea", threshold = 3000)
--------------------------------------------------
Tool: Threshold
Remove small areas: 3000
--------------------------------------------------
Copying features...

Rebuilding parts of topology...
Building topology for vector map <***@file480c11cc233b>...
Registering primitives...
703 primitives registered
6033 vertices registered
Building areas...

205 areas built
13 isles built
Attaching islands...

Attaching centroids...

Number of nodes: 306
Number of primitives: 703
Number of points: 0
Number of lines: 0
Number of boundaries: 498
Number of centroids: 205
Number of areas: 205
Number of isles: 13
--------------------------------------------------
Tool: Remove small areas

174 areas of total size 50601.7 removed
--------------------------------------------------
Rebuilding topology for output vector map...
Building topology for vector map <***@file480c11cc233b>...
Registering primitives...
333 primitives registered
4705 vertices registered
Building areas...

31 areas built
3 isles built
Attaching islands...

Attaching centroids...

Number of nodes: 274
Number of primitives: 333
Number of points: 0
Number of lines: 0
Number of boundaries: 302
Number of centroids: 31
Number of areas: 31
Number of isles: 3
> zm.fnl <- readVECT(zm.gnrl)
Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings,
:
line 4 did not have 2 elements
> sessionInfo()
R version 3.2.2 (2015-08-14)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1

locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United
States.1252 LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C LC_TIME=English_United
States.1252

attached base packages:
[1] stats graphics grDevices utils datasets methods base

other attached packages:
[1] RPyGeo_0.9-3 RSAGA_0.94-3 plyr_1.8.3 gstat_1.0-26
shapefiles_0.7 foreign_0.8-65 maptools_0.8-37 rgdal_1.0-7
classInt_0.1-23
[10] raster_2.4-20 rgrass7_0.1-3 XML_3.98-1.3 sp_1.2-0

loaded via a namespace (and not attached):
[1] Rcpp_0.12.1 intervals_0.15.1 lattice_0.20-33 FNN_1.1
spacetime_1.1-4 class_7.3-13 zoo_1.7-12 grid_3.2.2
[9] e1071_1.6-7 xts_0.9-7 tools_3.2.2

Thanks


2015-10-08 18:57 GMT-03:00 Roger Bivand <***@nhh.no>:

> Sorry this has taken a long time; please try installing the development
> version available from:
>
> http://win-builder.r-project.org/8Y3Ihj451Clx
>
> (rgrass7_0.1-3.zip). The problem was the use of "_" instead of " " in the
> name of the OGR shapefile driver - in OGR and R it is "ESRI Shapefile", in
> GRASS it is "ESRI_Shapefile". Because the new long-name work-around worked
> on systems not needing to use this driver, it wasn't properly tested - and
> on Windows the GRASS standalone has OGR with the SQLite driver, but the
> Windows rgdal binary does not have SQLite. You may wish to install the R
> RSQLite package to move data if you use long field/column names.
>
> Before installing this development version, and after library(rgrass7),
> run example(readVECT) in the basic nc location from:
>
> https://grass.osgeo.org/sampledata/north_carolina/nc_basic_spm_grass7.zip
>
> it should fail. Then restart R, install the development version of rgrass7
> from the first link, and repeat - it works for me and should resolve the
> problem.
>
> Hope this helps,
>
> Roger
>
>
> --
> Roger Bivand
> Norwegian School of Economics
> Helleveien 30, 5045 Bergen, Norway
> ***@nhh.no
>
>
>
>
>
> Fra: grass-stats-***@lists.osgeo.org [
> grass-stats-***@lists.osgeo.org] på vegne av Eduardo Diez [
> ***@gmx.com]
> Sendt: 24. september 2015 9:11
> Til: grass-***@lists.osgeo.org
> Emne: [GRASS-stats] rgrass7 read/write SpatialPolygonsDataFrames errors
>
>
> 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.
>
>
> 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).
>
>
>
> 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.
> Below i paste an extract of my R console with the errors and some
> information.
>
>
>
> Thanks in advance,
>
> Eduardo
>
>
> > mult.rp <- projectRaster(mult.r, crs = prj.crs, method = "ngb")
> > mult.pol <- rasterToPolygons(mult.rp, dissolve = T)
>
> > initGRASS(gisBase = "c:/Program Files (x86)/GRASS GIS 7.0.1", home =
> tempdir(), override = T)
> gisdbase C:/Users/ediez1/AppData/Local/Temp/RtmpegbyiQ
> location file2f7c6dc070e6
> mapset file2f7c30eb3f52
> rows 1
> columns 1
> north 1
> south 0
> west 0
> east 1
> nsres 1
> ewres 1
> projection NA
> > writeVECT(mult.pol, "pol1", v.in.ogr_flags = "o")
> Error: !is.null(driver) is not TRUE
> > writeVECT(mult.pol, "pol1", v.in.ogr_flags = "o", driver = "ESRI
> Shapefile")
>
> Over-riding projection check
> Check if OGR layer <r848659> contains polygons...
>
>
> Importing 4 features (OGR layer <r848659>)...
>
>
> -----------------------------------------------------
> Registering primitives...
> 3005 primitives registered
> 15587 vertices registered
> Number of nodes: 2691
> Number of primitives: 3005
> Number of points: 0
> Number of lines: 0
> Number of boundaries: 3005
> Number of centroids: 0
> Number of areas: -
> Number of isles: -
> -----------------------------------------------------
> Cleaning polygons
> -----------------------------------------------------
> Breaking polygons...
> Breaking polygons (pass 1: select break points)...
>
>
> Breaking polygons (pass 2: break at selected points)...
>
>
> -----------------------------------------------------
> Removing duplicates...
>
>
> -----------------------------------------------------
> Breaking boundaries...
>
>
> -----------------------------------------------------
> Removing duplicates...
>
>
> -----------------------------------------------------
> Cleaning boundaries at nodes...
>
>
> -----------------------------------------------------
> Merging boundaries...
>
>
> -----------------------------------------------------
> Removing dangles...
>
>
> -----------------------------------------------------
> Building areas...
>
>
> 95 areas built
> 8 isles built
> Number of nodes: 2771
> Number of primitives: 7307
> Number of points: 0
> Number of lines: 0
> Number of boundaries: 7307
> Number of centroids: 0
> Number of areas: 95
> Number of isles: 8
> -----------------------------------------------------
> Removing bridges...
>
>
> -----------------------------------------------------
> Registering primitives...
> 231 primitives registered
> 7594 vertices registered
> Building areas...
>
>
> 95 areas built
> 8 isles built
> Attaching islands...
>
>
> Number of nodes: 144
> Number of primitives: 231
> Number of points: 0
> Number of lines: 0
> Number of boundaries: 231
> Number of centroids: 0
> Number of areas: 95
> Number of isles: 8
> -----------------------------------------------------
> Finding centroids for OGR layer <r848659>...
>
>
> -----------------------------------------------------
> Writing centroids...
>
>
> -----------------------------------------------------
> 95 input polygons
> Total area: 1.28981E+006 (95 areas)
> -----------------------------------------------------
> Copying features...
>
>
> WARNING: Unable to delete file
>
> 'C:/Users/ediez1/AppData/Local/Temp/Rtmpg10lvi/filec2473b0126/filec24129b63ac/.tmp/unknown/vector/tmp_10484/coor'
> Building topology for vector map <***@filec24129b63ac>...
> Registering primitives...
> 326 primitives registered
> 7689 vertices registered
> Building areas...
>
>
> 95 areas built
> 8 isles built
> Attaching islands...
>
>
> Attaching centroids...
>
>
> Number of nodes: 144
> Number of primitives: 326
> Number of points: 0
> Number of lines: 0
> Number of boundaries: 231
> Number of centroids: 95
> Number of areas: 95
> Number of isles: 8
>
>
> > execGRASS("v.clean", flags = c("overwrite"), input = "pol1",
> + output = "clnpol", tool = "rmarea", threshold = 3000)
> --------------------------------------------------
> Tool: Threshold
> Remove small areas: 3000
> --------------------------------------------------
> Copying features...
>
>
> Rebuilding parts of topology...
> Building topology for vector map <***@filec24129b63ac>...
> Registering primitives...
> 326 primitives registered
> 7689 vertices registered
> Building areas...
>
>
> 95 areas built
> 8 isles built
> Attaching islands...
>
>
> Attaching centroids...
>
>
> Number of nodes: 144
> Number of primitives: 326
> Number of points: 0
> Number of lines: 0
> Number of boundaries: 231
> Number of centroids: 95
> Number of areas: 95
> Number of isles: 8
> --------------------------------------------------
> Tool: Remove small areas
>
>
> 55 areas of total size 29487.1 removed
> --------------------------------------------------
> Rebuilding topology for output vector map...
> Building topology for vector map <***@filec24129b63ac>...
> Registering primitives...
> 212 primitives registered
> 6840 vertices registered
> Building areas...
>
>
> 40 areas built
> 4 isles built
> Attaching islands...
>
>
> Attaching centroids...
>
>
> Number of nodes: 136
> Number of primitives: 212
> Number of points: 0
> Number of lines: 0
> Number of boundaries: 172
> Number of centroids: 40
> Number of areas: 40
> Number of isles: 4
> > cln.pol <- readVECT("clnpol")
> Error: !is.null(driver) is not TRUE
> > cln.pol <- readVECT("clnpol", driver = "ESRI Shapefile")
> Error in scan(file, what, nmax, sep, dec, quote, skip, nlines,
> na.strings, :
> line 4 did not have 2 elements
>
>
> > sessionInfo()
> R version 3.2.2 (2015-08-14)
> Platform: x86_64-w64-mingw32/x64 (64-bit)
> Running under: Windows 7 x64 (build 7601) Service Pack 1
>
>
> locale:
> [1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United
> States.1252 LC_MONETARY=English_United States.1252
> [4] LC_NUMERIC=C LC_TIME=English_United
> States.1252
>
>
> attached base packages:
> [1] stats graphics grDevices utils datasets methods base
>
>
> other attached packages:
> [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
>
>
> loaded via a namespace (and not attached):
> [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
> [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
> [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
>
Roger Bivand
2015-10-09 14:27:53 UTC
Permalink
OK, please provide the output of traceback() run immediately after the failing readVECT(). That will show which command invokes scan(). Also try to run vInfo(zm.gnrl) - I think the failure is in:

execGRASS("v.info", flags="t", map="zm.gnrl", layer=1L)

not returning a structure that vInfo understands, and which ois then used in readVECT().

Roger

--
Roger Bivand
Norwegian School of Economics
Helleveien 30, 5045 Bergen, Norway
***@nhh.no







Fra: ***@gmail.com [***@gmail.com] på vegne av Eduardo Diez [***@gmx.com]

Sendt: 9. oktober 2015 4:04

Til: Roger Bivand

Kopi: grass-***@lists.osgeo.org

Emne: Re: [GRASS-stats] rgrass7 read/write SpatialPolygonsDataFrames errors






Roger, with GRASS version 7.0.1 and rgrass7_0.1-3, readVECT now doesn't ask for the driver to use but gives the same error as before:




writeVECT(SDF = mz.pol, vname = zm.pol, v.in.ogr_flags = "o")
Over-riding projection check
Check if OGR layer <q7468fb> contains polygons...



Importing 205 features (OGR layer <q7468fb>)...



-----------------------------------------------------
Registering primitives...
3924 primitives registered
12866 vertices registered
Number of nodes: 2884
Number of primitives: 3924
Number of points: 0
Number of lines: 0
Number of boundaries: 3924
Number of centroids: 0
Number of areas: -
Number of isles: -
-----------------------------------------------------
Cleaning polygons
-----------------------------------------------------
Breaking polygons...
Breaking polygons (pass 1: select break points)...



Breaking polygons (pass 2: break at selected points)...



-----------------------------------------------------
Removing duplicates...



-----------------------------------------------------
Breaking boundaries...



-----------------------------------------------------
Removing duplicates...



-----------------------------------------------------
Cleaning boundaries at nodes...



-----------------------------------------------------
Merging boundaries...



-----------------------------------------------------
Removing dangles...



-----------------------------------------------------
Building areas...



205 areas built
13 isles built
Number of nodes: 2929
Number of primitives: 7268
Number of points: 0
Number of lines: 0
Number of boundaries: 7268
Number of centroids: 0
Number of areas: 205
Number of isles: 13
-----------------------------------------------------
Removing bridges...



-----------------------------------------------------
Registering primitives...
498 primitives registered
5828 vertices registered
Building areas...



205 areas built
13 isles built
Attaching islands...



Number of nodes: 306
Number of primitives: 498
Number of points: 0
Number of lines: 0
Number of boundaries: 498
Number of centroids: 0
Number of areas: 205
Number of isles: 13
-----------------------------------------------------
Finding centroids for OGR layer <q7468fb>...



-----------------------------------------------------
Writing centroids...



-----------------------------------------------------
205 input polygons
Total area: 1.25187E+006 (205 areas)
-----------------------------------------------------
Copying features...



WARNING: Unable to delete file
'C:/Users/ediez1/AppData/Local/Temp/Rtmpqkeay4/file480c1e5e16a7/file480c11cc233b/.tmp/unknown/vector/tmp_8308/coor'
Building topology for vector map <***@file480c11cc233b>...
Registering primitives...
703 primitives registered
6033 vertices registered
Building areas...



205 areas built
13 isles built
Attaching islands...



Attaching centroids...



Number of nodes: 306
Number of primitives: 703
Number of points: 0
Number of lines: 0
Number of boundaries: 498
Number of centroids: 205
Number of areas: 205
Number of isles: 13
> execGRASS("v.clean", flags = c("overwrite"), input = zm.pol,
+ output = zm.gnrl, tool = "rmarea", threshold = 3000)
--------------------------------------------------
Tool: Threshold
Remove small areas: 3000
--------------------------------------------------
Copying features...



Rebuilding parts of topology...
Building topology for vector map <***@file480c11cc233b>...
Registering primitives...
703 primitives registered
6033 vertices registered
Building areas...



205 areas built
13 isles built
Attaching islands...



Attaching centroids...



Number of nodes: 306
Number of primitives: 703
Number of points: 0
Number of lines: 0
Number of boundaries: 498
Number of centroids: 205
Number of areas: 205
Number of isles: 13
--------------------------------------------------
Tool: Remove small areas



174 areas of total size 50601.7 removed
--------------------------------------------------
Rebuilding topology for output vector map...
Building topology for vector map <***@file480c11cc233b>...
Registering primitives...
333 primitives registered
4705 vertices registered
Building areas...



31 areas built
3 isles built
Attaching islands...



Attaching centroids...



Number of nodes: 274
Number of primitives: 333
Number of points: 0
Number of lines: 0
Number of boundaries: 302
Number of centroids: 31
Number of areas: 31
Number of isles: 3
> zm.fnl <- readVECT(zm.gnrl)


Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings, :
line 4 did not have 2 elements
> sessionInfo()
R version 3.2.2 (2015-08-14)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1



locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C LC_TIME=English_United States.1252



attached base packages:
[1] stats graphics grDevices utils datasets methods base



other attached packages:
[1] RPyGeo_0.9-3 RSAGA_0.94-3 plyr_1.8.3 gstat_1.0-26 shapefiles_0.7 foreign_0.8-65 maptools_0.8-37 rgdal_1.0-7 classInt_0.1-23
[10] raster_2.4-20 rgrass7_0.1-3 XML_3.98-1.3 sp_1.2-0



loaded via a namespace (and not attached):
[1] Rcpp_0.12.1 intervals_0.15.1 lattice_0.20-33 FNN_1.1 spacetime_1.1-4 class_7.3-13 zoo_1.7-12 grid_3.2.2
[9] e1071_1.6-7 xts_0.9-7 tools_3.2.2




Thanks






2015-10-08 18:57 GMT-03:00 Roger Bivand
<***@nhh.no>:


Sorry this has taken a long time; please try installing the development version available from:



http://win-builder.r-project.org/8Y3Ihj451Clx



(rgrass7_0.1-3.zip). The problem was the use of "_" instead of " " in the name of the OGR shapefile driver - in OGR and R it is "ESRI Shapefile", in GRASS it is "ESRI_Shapefile". Because the new long-name work-around worked on systems not needing to use this
driver, it wasn't properly tested - and on Windows the GRASS standalone has OGR with the SQLite driver, but the Windows rgdal binary does not have SQLite. You may wish to install the R RSQLite package to move data if you use long field/column names.



Before installing this development version, and after library(rgrass7), run example(readVECT) in the basic nc location from:



https://grass.osgeo.org/sampledata/north_carolina/nc_basic_spm_grass7.zip



it should fail. Then restart R, install the development version of rgrass7 from the first link, and repeat - it works for me and should resolve the problem.



Hope this helps,



Roger





--

Roger Bivand

Norwegian School of Economics

Helleveien 30, 5045 Bergen, Norway

***@nhh.no











Fra:
grass-stats-***@lists.osgeo.org [grass-stats-***@lists.osgeo.org]
på vegne av Eduardo Diez [***@gmx.com]

Sendt: 24. september 2015 9:11

Til:
grass-***@lists.osgeo.org

Emne: [GRASS-stats] rgrass7 read/write SpatialPolygonsDataFrames errors






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.





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).







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.

Below i paste an extract of my R console with the errors and some information.







Thanks in advance,



Eduardo





> mult.rp <- projectRaster(mult.r, crs = prj.crs, method = "ngb")

> mult.pol <- rasterToPolygons(mult.rp, dissolve = T)



> initGRASS(gisBase = "c:/Program Files (x86)/GRASS GIS 7.0.1", home = tempdir(), override = T)

gisdbase C:/Users/ediez1/AppData/Local/Temp/RtmpegbyiQ

location file2f7c6dc070e6

mapset file2f7c30eb3f52

rows 1

columns 1

north 1

south 0

west 0

east 1

nsres 1

ewres 1

projection NA

> writeVECT(mult.pol, "pol1", v.in.ogr_flags = "o")

Error: !is.null(driver) is not TRUE

> writeVECT(mult.pol, "pol1", v.in.ogr_flags = "o", driver = "ESRI Shapefile")



Over-riding projection check

Check if OGR layer <r848659> contains polygons...





Importing 4 features (OGR layer <r848659>)...





-----------------------------------------------------

Registering primitives...

3005 primitives registered

15587 vertices registered

Number of nodes: 2691

Number of primitives: 3005

Number of points: 0

Number of lines: 0

Number of boundaries: 3005

Number of centroids: 0

Number of areas: -

Number of isles: -

-----------------------------------------------------

Cleaning polygons

-----------------------------------------------------

Breaking polygons...

Breaking polygons (pass 1: select break points)...





Breaking polygons (pass 2: break at selected points)...





-----------------------------------------------------

Removing duplicates...





-----------------------------------------------------

Breaking boundaries...





-----------------------------------------------------

Removing duplicates...





-----------------------------------------------------

Cleaning boundaries at nodes...





-----------------------------------------------------

Merging boundaries...





-----------------------------------------------------

Removing dangles...





-----------------------------------------------------

Building areas...





95 areas built

8 isles built

Number of nodes: 2771

Number of primitives: 7307

Number of points: 0

Number of lines: 0

Number of boundaries: 7307

Number of centroids: 0

Number of areas: 95

Number of isles: 8

-----------------------------------------------------

Removing bridges...





-----------------------------------------------------

Registering primitives...

231 primitives registered

7594 vertices registered

Building areas...





95 areas built

8 isles built

Attaching islands...





Number of nodes: 144

Number of primitives: 231

Number of points: 0

Number of lines: 0

Number of boundaries: 231

Number of centroids: 0

Number of areas: 95

Number of isles: 8

-----------------------------------------------------

Finding centroids for OGR layer <r848659>...





-----------------------------------------------------

Writing centroids...





-----------------------------------------------------

95 input polygons

Total area: 1.28981E+006 (95 areas)

-----------------------------------------------------

Copying features...





WARNING: Unable to delete file

'C:/Users/ediez1/AppData/Local/Temp/Rtmpg10lvi/filec2473b0126/filec24129b63ac/.tmp/unknown/vector/tmp_10484/coor'

Building topology for vector map <***@filec24129b63ac>...

Registering primitives...

326 primitives registered

7689 vertices registered

Building areas...





95 areas built

8 isles built

Attaching islands...





Attaching centroids...





Number of nodes: 144

Number of primitives: 326

Number of points: 0

Number of lines: 0

Number of boundaries: 231

Number of centroids: 95

Number of areas: 95

Number of isles: 8





> execGRASS("v.clean", flags = c("overwrite"), input = "pol1",

+ output = "clnpol", tool = "rmarea", threshold = 3000)

--------------------------------------------------

Tool: Threshold

Remove small areas: 3000

--------------------------------------------------

Copying features...





Rebuilding parts of topology...

Building topology for vector map <***@filec24129b63ac>...

Registering primitives...

326 primitives registered

7689 vertices registered

Building areas...





95 areas built

8 isles built

Attaching islands...





Attaching centroids...





Number of nodes: 144

Number of primitives: 326

Number of points: 0

Number of lines: 0

Number of boundaries: 231

Number of centroids: 95

Number of areas: 95

Number of isles: 8

--------------------------------------------------

Tool: Remove small areas





55 areas of total size 29487.1 removed

--------------------------------------------------

Rebuilding topology for output vector map...

Building topology for vector map <***@filec24129b63ac>...

Registering primitives...

212 primitives registered

6840 vertices registered

Building areas...





40 areas built

4 isles built

Attaching islands...





Attaching centroids...





Number of nodes: 136

Number of primitives: 212

Number of points: 0

Number of lines: 0

Number of boundaries: 172

Number of centroids: 40

Number of areas: 40

Number of isles: 4

> cln.pol <- readVECT("clnpol")

Error: !is.null(driver) is not TRUE

> cln.pol <- readVECT("clnpol", driver = "ESRI Shapefile")

Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings, :

line 4 did not have 2 elements





> sessionInfo()

R version 3.2.2 (2015-08-14)

Platform: x86_64-w64-mingw32/x64 (64-bit)

Running under: Windows 7 x64 (build 7601) Service Pack 1





locale:

[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 LC_MONETARY=English_United States.1252

[4] LC_NUMERIC=C LC_TIME=English_United States.1252





attached base packages:

[1] stats graphics grDevices utils datasets methods base





other attached packages:

[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





loaded via a namespace (and not attached):

[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

[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

[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
Roger Bivand
2015-10-09 14:36:01 UTC
Permalink
If it is the v.info call, please run:

res <- execGRASS("v.info", flags="t", map="zm.gnrl", layer=1L, intern=TRUE)

and report the output of:

print(res)

and maybe send me offlist the output of

save(res, file="vinfo_odd_output.RData")

Roger

--
Roger Bivand
Norwegian School of Economics
Helleveien 30, 5045 Bergen, Norway
***@nhh.no


________________________________________
Fra: grass-stats [grass-stats-***@lists.osgeo.org] p&#229; vegne av Roger Bivand [***@nhh.no]
Sendt: 9. oktober 2015 4:27
Til: Eduardo Diez
Kopi: grass-***@lists.osgeo.org
Emne: Re: [GRASS-stats] rgrass7 read/write SpatialPolygonsDataFrames errors

OK, please provide the output of traceback() run immediately after the failing readVECT(). That will show which command invokes scan(). Also try to run vInfo(zm.gnrl) - I think the failure is in:

execGRASS("v.info", flags="t", map="zm.gnrl", layer=1L)

not returning a structure that vInfo understands, and which ois then used in readVECT().

Roger

--
Roger Bivand
Norwegian School of Economics
Helleveien 30, 5045 Bergen, Norway
***@nhh.no







Fra: ***@gmail.com [***@gmail.com] på vegne av Eduardo Diez [***@gmx.com]

Sendt: 9. oktober 2015 4:04

Til: Roger Bivand

Kopi: grass-***@lists.osgeo.org

Emne: Re: [GRASS-stats] rgrass7 read/write SpatialPolygonsDataFrames errors






Roger, with GRASS version 7.0.1 and rgrass7_0.1-3, readVECT now doesn't ask for the driver to use but gives the same error as before:




writeVECT(SDF = mz.pol, vname = zm.pol, v.in.ogr_flags = "o")
Over-riding projection check
Check if OGR layer <q7468fb> contains polygons...



Importing 205 features (OGR layer <q7468fb>)...



-----------------------------------------------------
Registering primitives...
3924 primitives registered
12866 vertices registered
Number of nodes: 2884
Number of primitives: 3924
Number of points: 0
Number of lines: 0
Number of boundaries: 3924
Number of centroids: 0
Number of areas: -
Number of isles: -
-----------------------------------------------------
Cleaning polygons
-----------------------------------------------------
Breaking polygons...
Breaking polygons (pass 1: select break points)...



Breaking polygons (pass 2: break at selected points)...



-----------------------------------------------------
Removing duplicates...



-----------------------------------------------------
Breaking boundaries...



-----------------------------------------------------
Removing duplicates...



-----------------------------------------------------
Cleaning boundaries at nodes...



-----------------------------------------------------
Merging boundaries...



-----------------------------------------------------
Removing dangles...



-----------------------------------------------------
Building areas...



205 areas built
13 isles built
Number of nodes: 2929
Number of primitives: 7268
Number of points: 0
Number of lines: 0
Number of boundaries: 7268
Number of centroids: 0
Number of areas: 205
Number of isles: 13
-----------------------------------------------------
Removing bridges...



-----------------------------------------------------
Registering primitives...
498 primitives registered
5828 vertices registered
Building areas...



205 areas built
13 isles built
Attaching islands...



Number of nodes: 306
Number of primitives: 498
Number of points: 0
Number of lines: 0
Number of boundaries: 498
Number of centroids: 0
Number of areas: 205
Number of isles: 13
-----------------------------------------------------
Finding centroids for OGR layer <q7468fb>...



-----------------------------------------------------
Writing centroids...



-----------------------------------------------------
205 input polygons
Total area: 1.25187E+006 (205 areas)
-----------------------------------------------------
Copying features...



WARNING: Unable to delete file
'C:/Users/ediez1/AppData/Local/Temp/Rtmpqkeay4/file480c1e5e16a7/file480c11cc233b/.tmp/unknown/vector/tmp_8308/coor'
Building topology for vector map <***@file480c11cc233b>...
Registering primitives...
703 primitives registered
6033 vertices registered
Building areas...



205 areas built
13 isles built
Attaching islands...



Attaching centroids...



Number of nodes: 306
Number of primitives: 703
Number of points: 0
Number of lines: 0
Number of boundaries: 498
Number of centroids: 205
Number of areas: 205
Number of isles: 13
> execGRASS("v.clean", flags = c("overwrite"), input = zm.pol,
+ output = zm.gnrl, tool = "rmarea", threshold = 3000)
--------------------------------------------------
Tool: Threshold
Remove small areas: 3000
--------------------------------------------------
Copying features...



Rebuilding parts of topology...
Building topology for vector map <***@file480c11cc233b>...
Registering primitives...
703 primitives registered
6033 vertices registered
Building areas...



205 areas built
13 isles built
Attaching islands...



Attaching centroids...



Number of nodes: 306
Number of primitives: 703
Number of points: 0
Number of lines: 0
Number of boundaries: 498
Number of centroids: 205
Number of areas: 205
Number of isles: 13
--------------------------------------------------
Tool: Remove small areas



174 areas of total size 50601.7 removed
--------------------------------------------------
Rebuilding topology for output vector map...
Building topology for vector map <***@file480c11cc233b>...
Registering primitives...
333 primitives registered
4705 vertices registered
Building areas...



31 areas built
3 isles built
Attaching islands...



Attaching centroids...



Number of nodes: 274
Number of primitives: 333
Number of points: 0
Number of lines: 0
Number of boundaries: 302
Number of centroids: 31
Number of areas: 31
Number of isles: 3
> zm.fnl <- readVECT(zm.gnrl)


Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings, :
line 4 did not have 2 elements
> sessionInfo()
R version 3.2.2 (2015-08-14)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1



locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C LC_TIME=English_United States.1252



attached base packages:
[1] stats graphics grDevices utils datasets methods base



other attached packages:
[1] RPyGeo_0.9-3 RSAGA_0.94-3 plyr_1.8.3 gstat_1.0-26 shapefiles_0.7 foreign_0.8-65 maptools_0.8-37 rgdal_1.0-7 classInt_0.1-23
[10] raster_2.4-20 rgrass7_0.1-3 XML_3.98-1.3 sp_1.2-0



loaded via a namespace (and not attached):
[1] Rcpp_0.12.1 intervals_0.15.1 lattice_0.20-33 FNN_1.1 spacetime_1.1-4 class_7.3-13 zoo_1.7-12 grid_3.2.2
[9] e1071_1.6-7 xts_0.9-7 tools_3.2.2




Thanks






2015-10-08 18:57 GMT-03:00 Roger Bivand
<***@nhh.no>:


Sorry this has taken a long time; please try installing the development version available from:



http://win-builder.r-project.org/8Y3Ihj451Clx



(rgrass7_0.1-3.zip). The problem was the use of "_" instead of " " in the name of the OGR shapefile driver - in OGR and R it is "ESRI Shapefile", in GRASS it is "ESRI_Shapefile". Because the new long-name work-around worked on systems not needing to use this
driver, it wasn't properly tested - and on Windows the GRASS standalone has OGR with the SQLite driver, but the Windows rgdal binary does not have SQLite. You may wish to install the R RSQLite package to move data if you use long field/column names.



Before installing this development version, and after library(rgrass7), run example(readVECT) in the basic nc location from:



https://grass.osgeo.org/sampledata/north_carolina/nc_basic_spm_grass7.zip



it should fail. Then restart R, install the development version of rgrass7 from the first link, and repeat - it works for me and should resolve the problem.



Hope this helps,



Roger





--

Roger Bivand

Norwegian School of Economics

Helleveien 30, 5045 Bergen, Norway

***@nhh.no











Fra:
grass-stats-***@lists.osgeo.org [grass-stats-***@lists.osgeo.org]
på vegne av Eduardo Diez [***@gmx.com]

Sendt: 24. september 2015 9:11

Til:
grass-***@lists.osgeo.org

Emne: [GRASS-stats] rgrass7 read/write SpatialPolygonsDataFrames errors






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.





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).







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.

Below i paste an extract of my R console with the errors and some information.







Thanks in advance,



Eduardo





> mult.rp <- projectRaster(mult.r, crs = prj.crs, method = "ngb")

> mult.pol <- rasterToPolygons(mult.rp, dissolve = T)



> initGRASS(gisBase = "c:/Program Files (x86)/GRASS GIS 7.0.1", home = tempdir(), override = T)

gisdbase C:/Users/ediez1/AppData/Local/Temp/RtmpegbyiQ

location file2f7c6dc070e6

mapset file2f7c30eb3f52

rows 1

columns 1

north 1

south 0

west 0

east 1

nsres 1

ewres 1

projection NA

> writeVECT(mult.pol, "pol1", v.in.ogr_flags = "o")

Error: !is.null(driver) is not TRUE

> writeVECT(mult.pol, "pol1", v.in.ogr_flags = "o", driver = "ESRI Shapefile")



Over-riding projection check

Check if OGR layer <r848659> contains polygons...





Importing 4 features (OGR layer <r848659>)...





-----------------------------------------------------

Registering primitives...

3005 primitives registered

15587 vertices registered

Number of nodes: 2691

Number of primitives: 3005

Number of points: 0

Number of lines: 0

Number of boundaries: 3005

Number of centroids: 0

Number of areas: -

Number of isles: -

-----------------------------------------------------

Cleaning polygons

-----------------------------------------------------

Breaking polygons...

Breaking polygons (pass 1: select break points)...





Breaking polygons (pass 2: break at selected points)...





-----------------------------------------------------

Removing duplicates...





-----------------------------------------------------

Breaking boundaries...





-----------------------------------------------------

Removing duplicates...





-----------------------------------------------------

Cleaning boundaries at nodes...





-----------------------------------------------------

Merging boundaries...





-----------------------------------------------------

Removing dangles...





-----------------------------------------------------

Building areas...





95 areas built

8 isles built

Number of nodes: 2771

Number of primitives: 7307

Number of points: 0

Number of lines: 0

Number of boundaries: 7307

Number of centroids: 0

Number of areas: 95

Number of isles: 8

-----------------------------------------------------

Removing bridges...





-----------------------------------------------------

Registering primitives...

231 primitives registered

7594 vertices registered

Building areas...





95 areas built

8 isles built

Attaching islands...





Number of nodes: 144

Number of primitives: 231

Number of points: 0

Number of lines: 0

Number of boundaries: 231

Number of centroids: 0

Number of areas: 95

Number of isles: 8

-----------------------------------------------------

Finding centroids for OGR layer <r848659>...





-----------------------------------------------------

Writing centroids...





-----------------------------------------------------

95 input polygons

Total area: 1.28981E+006 (95 areas)

-----------------------------------------------------

Copying features...





WARNING: Unable to delete file

'C:/Users/ediez1/AppData/Local/Temp/Rtmpg10lvi/filec2473b0126/filec24129b63ac/.tmp/unknown/vector/tmp_10484/coor'

Building topology for vector map <***@filec24129b63ac>...

Registering primitives...

326 primitives registered

7689 vertices registered

Building areas...





95 areas built

8 isles built

Attaching islands...





Attaching centroids...





Number of nodes: 144

Number of primitives: 326

Number of points: 0

Number of lines: 0

Number of boundaries: 231

Number of centroids: 95

Number of areas: 95

Number of isles: 8





> execGRASS("v.clean", flags = c("overwrite"), input = "pol1",

+ output = "clnpol", tool = "rmarea", threshold = 3000)

--------------------------------------------------

Tool: Threshold

Remove small areas: 3000

--------------------------------------------------

Copying features...





Rebuilding parts of topology...

Building topology for vector map <***@filec24129b63ac>...

Registering primitives...

326 primitives registered

7689 vertices registered

Building areas...





95 areas built

8 isles built

Attaching islands...





Attaching centroids...





Number of nodes: 144

Number of primitives: 326

Number of points: 0

Number of lines: 0

Number of boundaries: 231

Number of centroids: 95

Number of areas: 95

Number of isles: 8

--------------------------------------------------

Tool: Remove small areas





55 areas of total size 29487.1 removed

--------------------------------------------------

Rebuilding topology for output vector map...

Building topology for vector map <***@filec24129b63ac>...

Registering primitives...

212 primitives registered

6840 vertices registered

Building areas...





40 areas built

4 isles built

Attaching islands...





Attaching centroids...





Number of nodes: 136

Number of primitives: 212

Number of points: 0

Number of lines: 0

Number of boundaries: 172

Number of centroids: 40

Number of areas: 40

Number of isles: 4

> cln.pol <- readVECT("clnpol")

Error: !is.null(driver) is not TRUE

> cln.pol <- readVECT("clnpol", driver = "ESRI Shapefile")

Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings, :

line 4 did not have 2 elements





> sessionInfo()

R version 3.2.2 (2015-08-14)

Platform: x86_64-w64-mingw32/x64 (64-bit)

Running under: Windows 7 x64 (build 7601) Service Pack 1





locale:

[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 LC_MONETARY=English_United States.1252

[4] LC_NUMERIC=C LC_TIME=English_United States.1252





attached base packages:

[1] stats graphics grDevices utils datasets methods base





other attached packages:

[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





loaded via a namespace (and not attached):

[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

[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

[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
Eduardo Diez
2015-10-09 16:05:03 UTC
Permalink
Here are the traceback and the vInfo(zm.gnrl). The latter seems to work
fine.

> zm.fnl <- readVECT(zm.gnrl)
Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings,
:
line 4 did not have 2 elements
> traceback()
8: scan(file = file, what = what, sep = sep, quote = quote, dec = dec,
nmax = nrows, skip = 0, na.strings = na.strings, quiet = TRUE,
fill = fill, strip.white = strip.white, blank.lines.skip =
blank.lines.skip,
multi.line = FALSE, comment.char = comment.char, allowEscapes =
allowEscapes,
flush = flush, encoding = encoding, skipNul = skipNul)
7: read.table(con, header = FALSE, sep = "|")
6: vColumns(vname)
5: nchar(as.character(vColumns(vname)$name))
4: .read_vect_non_plugin(vname = vname, layer = layer, type = type,
remove.duplicates = remove.duplicates, ignore.stderr =
ignore.stderr,
pointDropZ = pointDropZ, driver = driver, with_prj = with_prj,
with_c = with_c)
3: tryCatchList(expr, classes, parentenv, handlers)
2: tryCatch({
stopifnot(is.logical(plugin) || is.null(plugin))
stopifnot(is.logical(ignore.stderr))
if (missing(layer))
layer <- 1L
layer <- as.character(layer)
stopifnot(is.logical(with_c))
if (!is.null(driver) && driver == "GRASS")
plugin <- TRUE
if (!requireNamespace("rgdal", quietly = TRUE)) {
stop("rgdal not available")
}
if (is.null(plugin)) {
ogrD <- rgdal::ogrDrivers()$name
plugin <- "GRASS" %in% ogrD
}
if (plugin) {
res <- .read_vect_plugin(vname = vname, layer = layer,
type = type, ignore.stderr = ignore.stderr, pointDropZ =
pointDropZ,
mapset = mapset)
}
else {
res <- .read_vect_non_plugin(vname = vname, layer = layer,
type = type, remove.duplicates = remove.duplicates,
ignore.stderr = ignore.stderr, pointDropZ = pointDropZ,
driver = driver, with_prj = with_prj, with_c = with_c)
}
}, finally = {
if (get.suppressEchoCmdInFuncOption()) {
tull <- set.echoCmdOption(inEchoCmd)
}
})
1: readVECT(zm.gnrl)
> vInfo(zm.gnrl)
nodes points lines boundaries centroids areas
islands primitives map3d
274 0 0 302 31 31
3 333 0

Thanks


2015-10-09 11:36 GMT-03:00 Roger Bivand <***@nhh.no>:

> If it is the v.info call, please run:
>
> res <- execGRASS("v.info", flags="t", map="zm.gnrl", layer=1L,
> intern=TRUE)
>
> and report the output of:
>
> print(res)
>
> and maybe send me offlist the output of
>
> save(res, file="vinfo_odd_output.RData")
>
> Roger
>
> --
> Roger Bivand
> Norwegian School of Economics
> Helleveien 30, 5045 Bergen, Norway
> ***@nhh.no
>
>
> ________________________________________
> Fra: grass-stats [grass-stats-***@lists.osgeo.org] p&#229; vegne av
> Roger Bivand [***@nhh.no]
> Sendt: 9. oktober 2015 4:27
> Til: Eduardo Diez
> Kopi: grass-***@lists.osgeo.org
> Emne: Re: [GRASS-stats] rgrass7 read/write SpatialPolygonsDataFrames errors
>
> OK, please provide the output of traceback() run immediately after the
> failing readVECT(). That will show which command invokes scan(). Also try
> to run vInfo(zm.gnrl) - I think the failure is in:
>
> execGRASS("v.info", flags="t", map="zm.gnrl", layer=1L)
>
> not returning a structure that vInfo understands, and which ois then used
> in readVECT().
>
> Roger
>
> --
> Roger Bivand
> Norwegian School of Economics
> Helleveien 30, 5045 Bergen, Norway
> ***@nhh.no
>
>
>
>
>
>
>
> Fra: ***@gmail.com [***@gmail.com] på vegne av Eduardo Diez [
> ***@gmx.com]
>
> Sendt: 9. oktober 2015 4:04
>
> Til: Roger Bivand
>
> Kopi: grass-***@lists.osgeo.org
>
> Emne: Re: [GRASS-stats] rgrass7 read/write SpatialPolygonsDataFrames errors
>
>
>
>
>
>
> Roger, with GRASS version 7.0.1 and rgrass7_0.1-3, readVECT now doesn't
> ask for the driver to use but gives the same error as before:
>
>
>
>
> writeVECT(SDF = mz.pol, vname = zm.pol, v.in.ogr_flags = "o")
> Over-riding projection check
> Check if OGR layer <q7468fb> contains polygons...
>
>
>
> Importing 205 features (OGR layer <q7468fb>)...
>
>
>
> -----------------------------------------------------
> Registering primitives...
> 3924 primitives registered
> 12866 vertices registered
> Number of nodes: 2884
> Number of primitives: 3924
> Number of points: 0
> Number of lines: 0
> Number of boundaries: 3924
> Number of centroids: 0
> Number of areas: -
> Number of isles: -
> -----------------------------------------------------
> Cleaning polygons
> -----------------------------------------------------
> Breaking polygons...
> Breaking polygons (pass 1: select break points)...
>
>
>
> Breaking polygons (pass 2: break at selected points)...
>
>
>
> -----------------------------------------------------
> Removing duplicates...
>
>
>
> -----------------------------------------------------
> Breaking boundaries...
>
>
>
> -----------------------------------------------------
> Removing duplicates...
>
>
>
> -----------------------------------------------------
> Cleaning boundaries at nodes...
>
>
>
> -----------------------------------------------------
> Merging boundaries...
>
>
>
> -----------------------------------------------------
> Removing dangles...
>
>
>
> -----------------------------------------------------
> Building areas...
>
>
>
> 205 areas built
> 13 isles built
> Number of nodes: 2929
> Number of primitives: 7268
> Number of points: 0
> Number of lines: 0
> Number of boundaries: 7268
> Number of centroids: 0
> Number of areas: 205
> Number of isles: 13
> -----------------------------------------------------
> Removing bridges...
>
>
>
> -----------------------------------------------------
> Registering primitives...
> 498 primitives registered
> 5828 vertices registered
> Building areas...
>
>
>
> 205 areas built
> 13 isles built
> Attaching islands...
>
>
>
> Number of nodes: 306
> Number of primitives: 498
> Number of points: 0
> Number of lines: 0
> Number of boundaries: 498
> Number of centroids: 0
> Number of areas: 205
> Number of isles: 13
> -----------------------------------------------------
> Finding centroids for OGR layer <q7468fb>...
>
>
>
> -----------------------------------------------------
> Writing centroids...
>
>
>
> -----------------------------------------------------
> 205 input polygons
> Total area: 1.25187E+006 (205 areas)
> -----------------------------------------------------
> Copying features...
>
>
>
> WARNING: Unable to delete file
>
> 'C:/Users/ediez1/AppData/Local/Temp/Rtmpqkeay4/file480c1e5e16a7/file480c11cc233b/.tmp/unknown/vector/tmp_8308/coor'
> Building topology for vector map <***@file480c11cc233b>...
> Registering primitives...
> 703 primitives registered
> 6033 vertices registered
> Building areas...
>
>
>
> 205 areas built
> 13 isles built
> Attaching islands...
>
>
>
> Attaching centroids...
>
>
>
> Number of nodes: 306
> Number of primitives: 703
> Number of points: 0
> Number of lines: 0
> Number of boundaries: 498
> Number of centroids: 205
> Number of areas: 205
> Number of isles: 13
> > execGRASS("v.clean", flags = c("overwrite"), input = zm.pol,
> + output = zm.gnrl, tool = "rmarea", threshold = 3000)
> --------------------------------------------------
> Tool: Threshold
> Remove small areas: 3000
> --------------------------------------------------
> Copying features...
>
>
>
> Rebuilding parts of topology...
> Building topology for vector map <***@file480c11cc233b>...
> Registering primitives...
> 703 primitives registered
> 6033 vertices registered
> Building areas...
>
>
>
> 205 areas built
> 13 isles built
> Attaching islands...
>
>
>
> Attaching centroids...
>
>
>
> Number of nodes: 306
> Number of primitives: 703
> Number of points: 0
> Number of lines: 0
> Number of boundaries: 498
> Number of centroids: 205
> Number of areas: 205
> Number of isles: 13
> --------------------------------------------------
> Tool: Remove small areas
>
>
>
> 174 areas of total size 50601.7 removed
> --------------------------------------------------
> Rebuilding topology for output vector map...
> Building topology for vector map <***@file480c11cc233b>...
> Registering primitives...
> 333 primitives registered
> 4705 vertices registered
> Building areas...
>
>
>
> 31 areas built
> 3 isles built
> Attaching islands...
>
>
>
> Attaching centroids...
>
>
>
> Number of nodes: 274
> Number of primitives: 333
> Number of points: 0
> Number of lines: 0
> Number of boundaries: 302
> Number of centroids: 31
> Number of areas: 31
> Number of isles: 3
> > zm.fnl <- readVECT(zm.gnrl)
>
>
> Error in scan(file, what, nmax, sep, dec, quote, skip, nlines,
> na.strings, :
> line 4 did not have 2 elements
> > sessionInfo()
> R version 3.2.2 (2015-08-14)
> Platform: x86_64-w64-mingw32/x64 (64-bit)
> Running under: Windows 7 x64 (build 7601) Service Pack 1
>
>
>
> locale:
> [1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United
> States.1252 LC_MONETARY=English_United States.1252
> [4] LC_NUMERIC=C LC_TIME=English_United
> States.1252
>
>
>
> attached base packages:
> [1] stats graphics grDevices utils datasets methods base
>
>
>
> other attached packages:
> [1] RPyGeo_0.9-3 RSAGA_0.94-3 plyr_1.8.3 gstat_1.0-26
> shapefiles_0.7 foreign_0.8-65 maptools_0.8-37 rgdal_1.0-7
> classInt_0.1-23
> [10] raster_2.4-20 rgrass7_0.1-3 XML_3.98-1.3 sp_1.2-0
>
>
>
> loaded via a namespace (and not attached):
> [1] Rcpp_0.12.1 intervals_0.15.1 lattice_0.20-33 FNN_1.1
> spacetime_1.1-4 class_7.3-13 zoo_1.7-12 grid_3.2.2
> [9] e1071_1.6-7 xts_0.9-7 tools_3.2.2
>
>
>
>
> Thanks
>
>
>
>
>
>
> 2015-10-08 18:57 GMT-03:00 Roger Bivand
> <***@nhh.no>:
>
>
> Sorry this has taken a long time; please try installing the development
> version available from:
>
>
>
> http://win-builder.r-project.org/8Y3Ihj451Clx
>
>
>
> (rgrass7_0.1-3.zip). The problem was the use of "_" instead of " " in the
> name of the OGR shapefile driver - in OGR and R it is "ESRI Shapefile", in
> GRASS it is "ESRI_Shapefile". Because the new long-name work-around worked
> on systems not needing to use this
> driver, it wasn't properly tested - and on Windows the GRASS standalone
> has OGR with the SQLite driver, but the Windows rgdal binary does not have
> SQLite. You may wish to install the R RSQLite package to move data if you
> use long field/column names.
>
>
>
> Before installing this development version, and after library(rgrass7),
> run example(readVECT) in the basic nc location from:
>
>
>
> https://grass.osgeo.org/sampledata/north_carolina/nc_basic_spm_grass7.zip
>
>
>
> it should fail. Then restart R, install the development version of rgrass7
> from the first link, and repeat - it works for me and should resolve the
> problem.
>
>
>
> Hope this helps,
>
>
>
> Roger
>
>
>
>
>
> --
>
> Roger Bivand
>
> Norwegian School of Economics
>
> Helleveien 30, 5045 Bergen, Norway
>
> ***@nhh.no
>
>
>
>
>
>
>
>
>
>
>
> Fra:
> grass-stats-***@lists.osgeo.org [grass-stats-***@lists.osgeo.org]
> på vegne av Eduardo Diez [***@gmx.com]
>
> Sendt: 24. september 2015 9:11
>
> Til:
> grass-***@lists.osgeo.org
>
> Emne: [GRASS-stats] rgrass7 read/write SpatialPolygonsDataFrames errors
>
>
>
>
>
>
> 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.
>
>
>
>
>
> 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).
>
>
>
>
>
>
>
> 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.
>
> Below i paste an extract of my R console with the errors and some
> information.
>
>
>
>
>
>
>
> Thanks in advance,
>
>
>
> Eduardo
>
>
>
>
>
> > mult.rp <- projectRaster(mult.r, crs = prj.crs, method = "ngb")
>
> > mult.pol <- rasterToPolygons(mult.rp, dissolve = T)
>
>
>
> > initGRASS(gisBase = "c:/Program Files (x86)/GRASS GIS 7.0.1", home =
> tempdir(), override = T)
>
> gisdbase C:/Users/ediez1/AppData/Local/Temp/RtmpegbyiQ
>
> location file2f7c6dc070e6
>
> mapset file2f7c30eb3f52
>
> rows 1
>
> columns 1
>
> north 1
>
> south 0
>
> west 0
>
> east 1
>
> nsres 1
>
> ewres 1
>
> projection NA
>
> > writeVECT(mult.pol, "pol1", v.in.ogr_flags = "o")
>
> Error: !is.null(driver) is not TRUE
>
> > writeVECT(mult.pol, "pol1", v.in.ogr_flags = "o", driver = "ESRI
> Shapefile")
>
>
>
> Over-riding projection check
>
> Check if OGR layer <r848659> contains polygons...
>
>
>
>
>
> Importing 4 features (OGR layer <r848659>)...
>
>
>
>
>
> -----------------------------------------------------
>
> Registering primitives...
>
> 3005 primitives registered
>
> 15587 vertices registered
>
> Number of nodes: 2691
>
> Number of primitives: 3005
>
> Number of points: 0
>
> Number of lines: 0
>
> Number of boundaries: 3005
>
> Number of centroids: 0
>
> Number of areas: -
>
> Number of isles: -
>
> -----------------------------------------------------
>
> Cleaning polygons
>
> -----------------------------------------------------
>
> Breaking polygons...
>
> Breaking polygons (pass 1: select break points)...
>
>
>
>
>
> Breaking polygons (pass 2: break at selected points)...
>
>
>
>
>
> -----------------------------------------------------
>
> Removing duplicates...
>
>
>
>
>
> -----------------------------------------------------
>
> Breaking boundaries...
>
>
>
>
>
> -----------------------------------------------------
>
> Removing duplicates...
>
>
>
>
>
> -----------------------------------------------------
>
> Cleaning boundaries at nodes...
>
>
>
>
>
> -----------------------------------------------------
>
> Merging boundaries...
>
>
>
>
>
> -----------------------------------------------------
>
> Removing dangles...
>
>
>
>
>
> -----------------------------------------------------
>
> Building areas...
>
>
>
>
>
> 95 areas built
>
> 8 isles built
>
> Number of nodes: 2771
>
> Number of primitives: 7307
>
> Number of points: 0
>
> Number of lines: 0
>
> Number of boundaries: 7307
>
> Number of centroids: 0
>
> Number of areas: 95
>
> Number of isles: 8
>
> -----------------------------------------------------
>
> Removing bridges...
>
>
>
>
>
> -----------------------------------------------------
>
> Registering primitives...
>
> 231 primitives registered
>
> 7594 vertices registered
>
> Building areas...
>
>
>
>
>
> 95 areas built
>
> 8 isles built
>
> Attaching islands...
>
>
>
>
>
> Number of nodes: 144
>
> Number of primitives: 231
>
> Number of points: 0
>
> Number of lines: 0
>
> Number of boundaries: 231
>
> Number of centroids: 0
>
> Number of areas: 95
>
> Number of isles: 8
>
> -----------------------------------------------------
>
> Finding centroids for OGR layer <r848659>...
>
>
>
>
>
> -----------------------------------------------------
>
> Writing centroids...
>
>
>
>
>
> -----------------------------------------------------
>
> 95 input polygons
>
> Total area: 1.28981E+006 (95 areas)
>
> -----------------------------------------------------
>
> Copying features...
>
>
>
>
>
> WARNING: Unable to delete file
>
>
> 'C:/Users/ediez1/AppData/Local/Temp/Rtmpg10lvi/filec2473b0126/filec24129b63ac/.tmp/unknown/vector/tmp_10484/coor'
>
> Building topology for vector map <***@filec24129b63ac>...
>
> Registering primitives...
>
> 326 primitives registered
>
> 7689 vertices registered
>
> Building areas...
>
>
>
>
>
> 95 areas built
>
> 8 isles built
>
> Attaching islands...
>
>
>
>
>
> Attaching centroids...
>
>
>
>
>
> Number of nodes: 144
>
> Number of primitives: 326
>
> Number of points: 0
>
> Number of lines: 0
>
> Number of boundaries: 231
>
> Number of centroids: 95
>
> Number of areas: 95
>
> Number of isles: 8
>
>
>
>
>
> > execGRASS("v.clean", flags = c("overwrite"), input = "pol1",
>
> + output = "clnpol", tool = "rmarea", threshold = 3000)
>
> --------------------------------------------------
>
> Tool: Threshold
>
> Remove small areas: 3000
>
> --------------------------------------------------
>
> Copying features...
>
>
>
>
>
> Rebuilding parts of topology...
>
> Building topology for vector map <***@filec24129b63ac>...
>
> Registering primitives...
>
> 326 primitives registered
>
> 7689 vertices registered
>
> Building areas...
>
>
>
>
>
> 95 areas built
>
> 8 isles built
>
> Attaching islands...
>
>
>
>
>
> Attaching centroids...
>
>
>
>
>
> Number of nodes: 144
>
> Number of primitives: 326
>
> Number of points: 0
>
> Number of lines: 0
>
> Number of boundaries: 231
>
> Number of centroids: 95
>
> Number of areas: 95
>
> Number of isles: 8
>
> --------------------------------------------------
>
> Tool: Remove small areas
>
>
>
>
>
> 55 areas of total size 29487.1 removed
>
> --------------------------------------------------
>
> Rebuilding topology for output vector map...
>
> Building topology for vector map <***@filec24129b63ac>...
>
> Registering primitives...
>
> 212 primitives registered
>
> 6840 vertices registered
>
> Building areas...
>
>
>
>
>
> 40 areas built
>
> 4 isles built
>
> Attaching islands...
>
>
>
>
>
> Attaching centroids...
>
>
>
>
>
> Number of nodes: 136
>
> Number of primitives: 212
>
> Number of points: 0
>
> Number of lines: 0
>
> Number of boundaries: 172
>
> Number of centroids: 40
>
> Number of areas: 40
>
> Number of isles: 4
>
> > cln.pol <- readVECT("clnpol")
>
> Error: !is.null(driver) is not TRUE
>
> > cln.pol <- readVECT("clnpol", driver = "ESRI Shapefile")
>
> Error in scan(file, what, nmax, sep, dec, quote, skip, nlines,
> na.strings, :
>
> line 4 did not have 2 elements
>
>
>
>
>
> > sessionInfo()
>
> R version 3.2.2 (2015-08-14)
>
> Platform: x86_64-w64-mingw32/x64 (64-bit)
>
> Running under: Windows 7 x64 (build 7601) Service Pack 1
>
>
>
>
>
> locale:
>
> [1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United
> States.1252 LC_MONETARY=English_United States.1252
>
> [4] LC_NUMERIC=C LC_TIME=English_United
> States.1252
>
>
>
>
>
> attached base packages:
>
> [1] stats graphics grDevices utils datasets methods base
>
>
>
>
>
> other attached packages:
>
> [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
>
>
>
>
>
> loaded via a namespace (and not attached):
>
> [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
>
> [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
>
> [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
>
>
>
>
>
>
>
>
>
>
> _______________________________________________
> grass-stats mailing list
> grass-***@lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/grass-stats
>
Roger Bivand
2015-10-10 13:56:22 UTC
Permalink
OK, thanks. So the failure is in:

vinfo0 <- execGRASS("v.info", flags="c", map="<name>", layer=1L,
intern=TRUE)

used to return the column/field names. Please repeat with that.

Roger

On Fri, 9 Oct 2015, Eduardo Diez wrote:

> Here are the traceback and the vInfo(zm.gnrl). The latter seems to work
> fine.
>
>> zm.fnl <- readVECT(zm.gnrl)
> Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings,
> :
> line 4 did not have 2 elements
>> traceback()
> 8: scan(file = file, what = what, sep = sep, quote = quote, dec = dec,
> nmax = nrows, skip = 0, na.strings = na.strings, quiet = TRUE,
> fill = fill, strip.white = strip.white, blank.lines.skip =
> blank.lines.skip,
> multi.line = FALSE, comment.char = comment.char, allowEscapes =
> allowEscapes,
> flush = flush, encoding = encoding, skipNul = skipNul)
> 7: read.table(con, header = FALSE, sep = "|")
> 6: vColumns(vname)
> 5: nchar(as.character(vColumns(vname)$name))
> 4: .read_vect_non_plugin(vname = vname, layer = layer, type = type,
> remove.duplicates = remove.duplicates, ignore.stderr =
> ignore.stderr,
> pointDropZ = pointDropZ, driver = driver, with_prj = with_prj,
> with_c = with_c)
> 3: tryCatchList(expr, classes, parentenv, handlers)
> 2: tryCatch({
> stopifnot(is.logical(plugin) || is.null(plugin))
> stopifnot(is.logical(ignore.stderr))
> if (missing(layer))
> layer <- 1L
> layer <- as.character(layer)
> stopifnot(is.logical(with_c))
> if (!is.null(driver) && driver == "GRASS")
> plugin <- TRUE
> if (!requireNamespace("rgdal", quietly = TRUE)) {
> stop("rgdal not available")
> }
> if (is.null(plugin)) {
> ogrD <- rgdal::ogrDrivers()$name
> plugin <- "GRASS" %in% ogrD
> }
> if (plugin) {
> res <- .read_vect_plugin(vname = vname, layer = layer,
> type = type, ignore.stderr = ignore.stderr, pointDropZ =
> pointDropZ,
> mapset = mapset)
> }
> else {
> res <- .read_vect_non_plugin(vname = vname, layer = layer,
> type = type, remove.duplicates = remove.duplicates,
> ignore.stderr = ignore.stderr, pointDropZ = pointDropZ,
> driver = driver, with_prj = with_prj, with_c = with_c)
> }
> }, finally = {
> if (get.suppressEchoCmdInFuncOption()) {
> tull <- set.echoCmdOption(inEchoCmd)
> }
> })
> 1: readVECT(zm.gnrl)
>> vInfo(zm.gnrl)
> nodes points lines boundaries centroids areas
> islands primitives map3d
> 274 0 0 302 31 31
> 3 333 0
>
> Thanks
>
>
> 2015-10-09 11:36 GMT-03:00 Roger Bivand <***@nhh.no>:
>
>> If it is the v.info call, please run:
>>
>> res <- execGRASS("v.info", flags="t", map="zm.gnrl", layer=1L,
>> intern=TRUE)
>>
>> and report the output of:
>>
>> print(res)
>>
>> and maybe send me offlist the output of
>>
>> save(res, file="vinfo_odd_output.RData")
>>
>> Roger
>>
>> --
>> Roger Bivand
>> Norwegian School of Economics
>> Helleveien 30, 5045 Bergen, Norway
>> ***@nhh.no
>>
>>
>> ________________________________________
>> Fra: grass-stats [grass-stats-***@lists.osgeo.org] p&#229; vegne av
>> Roger Bivand [***@nhh.no]
>> Sendt: 9. oktober 2015 4:27
>> Til: Eduardo Diez
>> Kopi: grass-***@lists.osgeo.org
>> Emne: Re: [GRASS-stats] rgrass7 read/write SpatialPolygonsDataFrames errors
>>
>> OK, please provide the output of traceback() run immediately after the
>> failing readVECT(). That will show which command invokes scan(). Also try
>> to run vInfo(zm.gnrl) - I think the failure is in:
>>
>> execGRASS("v.info", flags="t", map="zm.gnrl", layer=1L)
>>
>> not returning a structure that vInfo understands, and which ois then used
>> in readVECT().
>>
>> Roger
>>
>> --
>> Roger Bivand
>> Norwegian School of Economics
>> Helleveien 30, 5045 Bergen, Norway
>> ***@nhh.no
>>
>>
>>
>>
>>
>>
>>
>> Fra: ***@gmail.com [***@gmail.com] på vegne av Eduardo Diez [
>> ***@gmx.com]
>>
>> Sendt: 9. oktober 2015 4:04
>>
>> Til: Roger Bivand
>>
>> Kopi: grass-***@lists.osgeo.org
>>
>> Emne: Re: [GRASS-stats] rgrass7 read/write SpatialPolygonsDataFrames errors
>>
>>
>>
>>
>>
>>
>> Roger, with GRASS version 7.0.1 and rgrass7_0.1-3, readVECT now doesn't
>> ask for the driver to use but gives the same error as before:
>>
>>
>>
>>
>> writeVECT(SDF = mz.pol, vname = zm.pol, v.in.ogr_flags = "o")
>> Over-riding projection check
>> Check if OGR layer <q7468fb> contains polygons...
>>
>>
>>
>> Importing 205 features (OGR layer <q7468fb>)...
>>
>>
>>
>> -----------------------------------------------------
>> Registering primitives...
>> 3924 primitives registered
>> 12866 vertices registered
>> Number of nodes: 2884
>> Number of primitives: 3924
>> Number of points: 0
>> Number of lines: 0
>> Number of boundaries: 3924
>> Number of centroids: 0
>> Number of areas: -
>> Number of isles: -
>> -----------------------------------------------------
>> Cleaning polygons
>> -----------------------------------------------------
>> Breaking polygons...
>> Breaking polygons (pass 1: select break points)...
>>
>>
>>
>> Breaking polygons (pass 2: break at selected points)...
>>
>>
>>
>> -----------------------------------------------------
>> Removing duplicates...
>>
>>
>>
>> -----------------------------------------------------
>> Breaking boundaries...
>>
>>
>>
>> -----------------------------------------------------
>> Removing duplicates...
>>
>>
>>
>> -----------------------------------------------------
>> Cleaning boundaries at nodes...
>>
>>
>>
>> -----------------------------------------------------
>> Merging boundaries...
>>
>>
>>
>> -----------------------------------------------------
>> Removing dangles...
>>
>>
>>
>> -----------------------------------------------------
>> Building areas...
>>
>>
>>
>> 205 areas built
>> 13 isles built
>> Number of nodes: 2929
>> Number of primitives: 7268
>> Number of points: 0
>> Number of lines: 0
>> Number of boundaries: 7268
>> Number of centroids: 0
>> Number of areas: 205
>> Number of isles: 13
>> -----------------------------------------------------
>> Removing bridges...
>>
>>
>>
>> -----------------------------------------------------
>> Registering primitives...
>> 498 primitives registered
>> 5828 vertices registered
>> Building areas...
>>
>>
>>
>> 205 areas built
>> 13 isles built
>> Attaching islands...
>>
>>
>>
>> Number of nodes: 306
>> Number of primitives: 498
>> Number of points: 0
>> Number of lines: 0
>> Number of boundaries: 498
>> Number of centroids: 0
>> Number of areas: 205
>> Number of isles: 13
>> -----------------------------------------------------
>> Finding centroids for OGR layer <q7468fb>...
>>
>>
>>
>> -----------------------------------------------------
>> Writing centroids...
>>
>>
>>
>> -----------------------------------------------------
>> 205 input polygons
>> Total area: 1.25187E+006 (205 areas)
>> -----------------------------------------------------
>> Copying features...
>>
>>
>>
>> WARNING: Unable to delete file
>>
>> 'C:/Users/ediez1/AppData/Local/Temp/Rtmpqkeay4/file480c1e5e16a7/file480c11cc233b/.tmp/unknown/vector/tmp_8308/coor'
>> Building topology for vector map <***@file480c11cc233b>...
>> Registering primitives...
>> 703 primitives registered
>> 6033 vertices registered
>> Building areas...
>>
>>
>>
>> 205 areas built
>> 13 isles built
>> Attaching islands...
>>
>>
>>
>> Attaching centroids...
>>
>>
>>
>> Number of nodes: 306
>> Number of primitives: 703
>> Number of points: 0
>> Number of lines: 0
>> Number of boundaries: 498
>> Number of centroids: 205
>> Number of areas: 205
>> Number of isles: 13
>>> execGRASS("v.clean", flags = c("overwrite"), input = zm.pol,
>> + output = zm.gnrl, tool = "rmarea", threshold = 3000)
>> --------------------------------------------------
>> Tool: Threshold
>> Remove small areas: 3000
>> --------------------------------------------------
>> Copying features...
>>
>>
>>
>> Rebuilding parts of topology...
>> Building topology for vector map <***@file480c11cc233b>...
>> Registering primitives...
>> 703 primitives registered
>> 6033 vertices registered
>> Building areas...
>>
>>
>>
>> 205 areas built
>> 13 isles built
>> Attaching islands...
>>
>>
>>
>> Attaching centroids...
>>
>>
>>
>> Number of nodes: 306
>> Number of primitives: 703
>> Number of points: 0
>> Number of lines: 0
>> Number of boundaries: 498
>> Number of centroids: 205
>> Number of areas: 205
>> Number of isles: 13
>> --------------------------------------------------
>> Tool: Remove small areas
>>
>>
>>
>> 174 areas of total size 50601.7 removed
>> --------------------------------------------------
>> Rebuilding topology for output vector map...
>> Building topology for vector map <***@file480c11cc233b>...
>> Registering primitives...
>> 333 primitives registered
>> 4705 vertices registered
>> Building areas...
>>
>>
>>
>> 31 areas built
>> 3 isles built
>> Attaching islands...
>>
>>
>>
>> Attaching centroids...
>>
>>
>>
>> Number of nodes: 274
>> Number of primitives: 333
>> Number of points: 0
>> Number of lines: 0
>> Number of boundaries: 302
>> Number of centroids: 31
>> Number of areas: 31
>> Number of isles: 3
>>> zm.fnl <- readVECT(zm.gnrl)
>>
>>
>> Error in scan(file, what, nmax, sep, dec, quote, skip, nlines,
>> na.strings, :
>> line 4 did not have 2 elements
>>> sessionInfo()
>> R version 3.2.2 (2015-08-14)
>> Platform: x86_64-w64-mingw32/x64 (64-bit)
>> Running under: Windows 7 x64 (build 7601) Service Pack 1
>>
>>
>>
>> locale:
>> [1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United
>> States.1252 LC_MONETARY=English_United States.1252
>> [4] LC_NUMERIC=C LC_TIME=English_United
>> States.1252
>>
>>
>>
>> attached base packages:
>> [1] stats graphics grDevices utils datasets methods base
>>
>>
>>
>> other attached packages:
>> [1] RPyGeo_0.9-3 RSAGA_0.94-3 plyr_1.8.3 gstat_1.0-26
>> shapefiles_0.7 foreign_0.8-65 maptools_0.8-37 rgdal_1.0-7
>> classInt_0.1-23
>> [10] raster_2.4-20 rgrass7_0.1-3 XML_3.98-1.3 sp_1.2-0
>>
>>
>>
>> loaded via a namespace (and not attached):
>> [1] Rcpp_0.12.1 intervals_0.15.1 lattice_0.20-33 FNN_1.1
>> spacetime_1.1-4 class_7.3-13 zoo_1.7-12 grid_3.2.2
>> [9] e1071_1.6-7 xts_0.9-7 tools_3.2.2
>>
>>
>>
>>
>> Thanks
>>
>>
>>
>>
>>
>>
>> 2015-10-08 18:57 GMT-03:00 Roger Bivand
>> <***@nhh.no>:
>>
>>
>> Sorry this has taken a long time; please try installing the development
>> version available from:
>>
>>
>>
>> http://win-builder.r-project.org/8Y3Ihj451Clx
>>
>>
>>
>> (rgrass7_0.1-3.zip). The problem was the use of "_" instead of " " in the
>> name of the OGR shapefile driver - in OGR and R it is "ESRI Shapefile", in
>> GRASS it is "ESRI_Shapefile". Because the new long-name work-around worked
>> on systems not needing to use this
>> driver, it wasn't properly tested - and on Windows the GRASS standalone
>> has OGR with the SQLite driver, but the Windows rgdal binary does not have
>> SQLite. You may wish to install the R RSQLite package to move data if you
>> use long field/column names.
>>
>>
>>
>> Before installing this development version, and after library(rgrass7),
>> run example(readVECT) in the basic nc location from:
>>
>>
>>
>> https://grass.osgeo.org/sampledata/north_carolina/nc_basic_spm_grass7.zip
>>
>>
>>
>> it should fail. Then restart R, install the development version of rgrass7
>> from the first link, and repeat - it works for me and should resolve the
>> problem.
>>
>>
>>
>> Hope this helps,
>>
>>
>>
>> Roger
>>
>>
>>
>>
>>
>> --
>>
>> Roger Bivand
>>
>> Norwegian School of Economics
>>
>> Helleveien 30, 5045 Bergen, Norway
>>
>> ***@nhh.no
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> Fra:
>> grass-stats-***@lists.osgeo.org [grass-stats-***@lists.osgeo.org]
>> på vegne av Eduardo Diez [***@gmx.com]
>>
>> Sendt: 24. september 2015 9:11
>>
>> Til:
>> grass-***@lists.osgeo.org
>>
>> Emne: [GRASS-stats] rgrass7 read/write SpatialPolygonsDataFrames errors
>>
>>
>>
>>
>>
>>
>> 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.
>>
>>
>>
>>
>>
>> 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).
>>
>>
>>
>>
>>
>>
>>
>> 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.
>>
>> Below i paste an extract of my R console with the errors and some
>> information.
>>
>>
>>
>>
>>
>>
>>
>> Thanks in advance,
>>
>>
>>
>> Eduardo
>>
>>
>>
>>
>>
>>> mult.rp <- projectRaster(mult.r, crs = prj.crs, method = "ngb")
>>
>>> mult.pol <- rasterToPolygons(mult.rp, dissolve = T)
>>
>>
>>
>>> initGRASS(gisBase = "c:/Program Files (x86)/GRASS GIS 7.0.1", home =
>> tempdir(), override = T)
>>
>> gisdbase C:/Users/ediez1/AppData/Local/Temp/RtmpegbyiQ
>>
>> location file2f7c6dc070e6
>>
>> mapset file2f7c30eb3f52
>>
>> rows 1
>>
>> columns 1
>>
>> north 1
>>
>> south 0
>>
>> west 0
>>
>> east 1
>>
>> nsres 1
>>
>> ewres 1
>>
>> projection NA
>>
>>> writeVECT(mult.pol, "pol1", v.in.ogr_flags = "o")
>>
>> Error: !is.null(driver) is not TRUE
>>
>>> writeVECT(mult.pol, "pol1", v.in.ogr_flags = "o", driver = "ESRI
>> Shapefile")
>>
>>
>>
>> Over-riding projection check
>>
>> Check if OGR layer <r848659> contains polygons...
>>
>>
>>
>>
>>
>> Importing 4 features (OGR layer <r848659>)...
>>
>>
>>
>>
>>
>> -----------------------------------------------------
>>
>> Registering primitives...
>>
>> 3005 primitives registered
>>
>> 15587 vertices registered
>>
>> Number of nodes: 2691
>>
>> Number of primitives: 3005
>>
>> Number of points: 0
>>
>> Number of lines: 0
>>
>> Number of boundaries: 3005
>>
>> Number of centroids: 0
>>
>> Number of areas: -
>>
>> Number of isles: -
>>
>> -----------------------------------------------------
>>
>> Cleaning polygons
>>
>> -----------------------------------------------------
>>
>> Breaking polygons...
>>
>> Breaking polygons (pass 1: select break points)...
>>
>>
>>
>>
>>
>> Breaking polygons (pass 2: break at selected points)...
>>
>>
>>
>>
>>
>> -----------------------------------------------------
>>
>> Removing duplicates...
>>
>>
>>
>>
>>
>> -----------------------------------------------------
>>
>> Breaking boundaries...
>>
>>
>>
>>
>>
>> -----------------------------------------------------
>>
>> Removing duplicates...
>>
>>
>>
>>
>>
>> -----------------------------------------------------
>>
>> Cleaning boundaries at nodes...
>>
>>
>>
>>
>>
>> -----------------------------------------------------
>>
>> Merging boundaries...
>>
>>
>>
>>
>>
>> -----------------------------------------------------
>>
>> Removing dangles...
>>
>>
>>
>>
>>
>> -----------------------------------------------------
>>
>> Building areas...
>>
>>
>>
>>
>>
>> 95 areas built
>>
>> 8 isles built
>>
>> Number of nodes: 2771
>>
>> Number of primitives: 7307
>>
>> Number of points: 0
>>
>> Number of lines: 0
>>
>> Number of boundaries: 7307
>>
>> Number of centroids: 0
>>
>> Number of areas: 95
>>
>> Number of isles: 8
>>
>> -----------------------------------------------------
>>
>> Removing bridges...
>>
>>
>>
>>
>>
>> -----------------------------------------------------
>>
>> Registering primitives...
>>
>> 231 primitives registered
>>
>> 7594 vertices registered
>>
>> Building areas...
>>
>>
>>
>>
>>
>> 95 areas built
>>
>> 8 isles built
>>
>> Attaching islands...
>>
>>
>>
>>
>>
>> Number of nodes: 144
>>
>> Number of primitives: 231
>>
>> Number of points: 0
>>
>> Number of lines: 0
>>
>> Number of boundaries: 231
>>
>> Number of centroids: 0
>>
>> Number of areas: 95
>>
>> Number of isles: 8
>>
>> -----------------------------------------------------
>>
>> Finding centroids for OGR layer <r848659>...
>>
>>
>>
>>
>>
>> -----------------------------------------------------
>>
>> Writing centroids...
>>
>>
>>
>>
>>
>> -----------------------------------------------------
>>
>> 95 input polygons
>>
>> Total area: 1.28981E+006 (95 areas)
>>
>> -----------------------------------------------------
>>
>> Copying features...
>>
>>
>>
>>
>>
>> WARNING: Unable to delete file
>>
>>
>> 'C:/Users/ediez1/AppData/Local/Temp/Rtmpg10lvi/filec2473b0126/filec24129b63ac/.tmp/unknown/vector/tmp_10484/coor'
>>
>> Building topology for vector map <***@filec24129b63ac>...
>>
>> Registering primitives...
>>
>> 326 primitives registered
>>
>> 7689 vertices registered
>>
>> Building areas...
>>
>>
>>
>>
>>
>> 95 areas built
>>
>> 8 isles built
>>
>> Attaching islands...
>>
>>
>>
>>
>>
>> Attaching centroids...
>>
>>
>>
>>
>>
>> Number of nodes: 144
>>
>> Number of primitives: 326
>>
>> Number of points: 0
>>
>> Number of lines: 0
>>
>> Number of boundaries: 231
>>
>> Number of centroids: 95
>>
>> Number of areas: 95
>>
>> Number of isles: 8
>>
>>
>>
>>
>>
>>> execGRASS("v.clean", flags = c("overwrite"), input = "pol1",
>>
>> + output = "clnpol", tool = "rmarea", threshold = 3000)
>>
>> --------------------------------------------------
>>
>> Tool: Threshold
>>
>> Remove small areas: 3000
>>
>> --------------------------------------------------
>>
>> Copying features...
>>
>>
>>
>>
>>
>> Rebuilding parts of topology...
>>
>> Building topology for vector map <***@filec24129b63ac>...
>>
>> Registering primitives...
>>
>> 326 primitives registered
>>
>> 7689 vertices registered
>>
>> Building areas...
>>
>>
>>
>>
>>
>> 95 areas built
>>
>> 8 isles built
>>
>> Attaching islands...
>>
>>
>>
>>
>>
>> Attaching centroids...
>>
>>
>>
>>
>>
>> Number of nodes: 144
>>
>> Number of primitives: 326
>>
>> Number of points: 0
>>
>> Number of lines: 0
>>
>> Number of boundaries: 231
>>
>> Number of centroids: 95
>>
>> Number of areas: 95
>>
>> Number of isles: 8
>>
>> --------------------------------------------------
>>
>> Tool: Remove small areas
>>
>>
>>
>>
>>
>> 55 areas of total size 29487.1 removed
>>
>> --------------------------------------------------
>>
>> Rebuilding topology for output vector map...
>>
>> Building topology for vector map <***@filec24129b63ac>...
>>
>> Registering primitives...
>>
>> 212 primitives registered
>>
>> 6840 vertices registered
>>
>> Building areas...
>>
>>
>>
>>
>>
>> 40 areas built
>>
>> 4 isles built
>>
>> Attaching islands...
>>
>>
>>
>>
>>
>> Attaching centroids...
>>
>>
>>
>>
>>
>> Number of nodes: 136
>>
>> Number of primitives: 212
>>
>> Number of points: 0
>>
>> Number of lines: 0
>>
>> Number of boundaries: 172
>>
>> Number of centroids: 40
>>
>> Number of areas: 40
>>
>> Number of isles: 4
>>
>>> cln.pol <- readVECT("clnpol")
>>
>> Error: !is.null(driver) is not TRUE
>>
>>> cln.pol <- readVECT("clnpol", driver = "ESRI Shapefile")
>>
>> Error in scan(file, what, nmax, sep, dec, quote, skip, nlines,
>> na.strings, :
>>
>> line 4 did not have 2 elements
>>
>>
>>
>>
>>
>>> sessionInfo()
>>
>> R version 3.2.2 (2015-08-14)
>>
>> Platform: x86_64-w64-mingw32/x64 (64-bit)
>>
>> Running under: Windows 7 x64 (build 7601) Service Pack 1
>>
>>
>>
>>
>>
>> locale:
>>
>> [1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United
>> States.1252 LC_MONETARY=English_United States.1252
>>
>> [4] LC_NUMERIC=C LC_TIME=English_United
>> States.1252
>>
>>
>>
>>
>>
>> attached base packages:
>>
>> [1] stats graphics grDevices utils datasets methods base
>>
>>
>>
>>
>>
>> other attached packages:
>>
>> [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
>>
>>
>>
>>
>>
>> loaded via a namespace (and not attached):
>>
>> [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
>>
>> [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
>>
>> [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
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> _______________________________________________
>> grass-stats mailing list
>> grass-***@lists.osgeo.org
>> http://lists.osgeo.org/mailman/listinfo/grass-stats
>>
>

--
Roger Bivand
Department of Economics, Norwegian School of Economics,
Helleveien 30, N-5045 Bergen, Norway.
voice: +47 55 95 93 55; fax +47 55 95 91 00
e-mail: ***@nhh.no
Eduardo Diez
2015-10-10 15:45:41 UTC
Permalink
Apparently "v.info" through execGRASS is expecting the "layer" argument to
be a string rather than an integer.


> zm.fnl <- readVECT(zm.gnrl)Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings, :
line 4 did not have 2 elements> vinfo0 <- execGRASS("v.info",
flags="c", map=zm.gnrl, layer=1L,+ intern=TRUE)Error in doGRASS(cmd,
flags = flags, ..., parameters = parameters, echoCmd = echoCmd, :
Parameter <layer> does not have string value>
parseGRASS("v.info")Command: v.info
Extension: .exe
Description: Outputs basic information about a vector map.
Keywords: vector, metadata, topology, extent, history, attribute columns
Parameters:
name: map, type: string, required: yes, multiple: no
keydesc: name, keydesc_count: 1
[Or data source for direct OGR access]
name: layer, type: string, required: no, multiple: no
default: 1
[Vector features can have category values in different layers. This
number determines which layer to use. When used with direct OGR access
this is the layer name.]
Flags:
name: h [Print history instead of info and exit] {FALSE}
name: c [Print types/names of table columns for specified layer
instead of info and exit] {FALSE}
name: g [Print region info in shell script style] {FALSE}
name: e [Print extended metadata info in shell script style] {FALSE}
name: t [Print topology info in shell script style] {FALSE}
name: help [Print usage summary] {FALSE}
name: verbose [Verbose module output] {FALSE}
name: quiet [Quiet module output] {FALSE}


>

2015-10-10 10:56 GMT-03:00 Roger Bivand <***@nhh.no>:

> OK, thanks. So the failure is in:
>
> vinfo0 <- execGRASS("v.info", flags="c", map="<name>", layer=1L,
> intern=TRUE)
>
> used to return the column/field names. Please repeat with that.
>
> Roger
>
>
> On Fri, 9 Oct 2015, Eduardo Diez wrote:
>
> Here are the traceback and the vInfo(zm.gnrl). The latter seems to work
>> fine.
>>
>> zm.fnl <- readVECT(zm.gnrl)
>>>
>> Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings,
>> :
>> line 4 did not have 2 elements
>>
>>> traceback()
>>>
>> 8: scan(file = file, what = what, sep = sep, quote = quote, dec = dec,
>> nmax = nrows, skip = 0, na.strings = na.strings, quiet = TRUE,
>> fill = fill, strip.white = strip.white, blank.lines.skip =
>> blank.lines.skip,
>> multi.line = FALSE, comment.char = comment.char, allowEscapes =
>> allowEscapes,
>> flush = flush, encoding = encoding, skipNul = skipNul)
>> 7: read.table(con, header = FALSE, sep = "|")
>> 6: vColumns(vname)
>> 5: nchar(as.character(vColumns(vname)$name))
>> 4: .read_vect_non_plugin(vname = vname, layer = layer, type = type,
>> remove.duplicates = remove.duplicates, ignore.stderr =
>> ignore.stderr,
>> pointDropZ = pointDropZ, driver = driver, with_prj = with_prj,
>> with_c = with_c)
>> 3: tryCatchList(expr, classes, parentenv, handlers)
>> 2: tryCatch({
>> stopifnot(is.logical(plugin) || is.null(plugin))
>> stopifnot(is.logical(ignore.stderr))
>> if (missing(layer))
>> layer <- 1L
>> layer <- as.character(layer)
>> stopifnot(is.logical(with_c))
>> if (!is.null(driver) && driver == "GRASS")
>> plugin <- TRUE
>> if (!requireNamespace("rgdal", quietly = TRUE)) {
>> stop("rgdal not available")
>> }
>> if (is.null(plugin)) {
>> ogrD <- rgdal::ogrDrivers()$name
>> plugin <- "GRASS" %in% ogrD
>> }
>> if (plugin) {
>> res <- .read_vect_plugin(vname = vname, layer = layer,
>> type = type, ignore.stderr = ignore.stderr, pointDropZ =
>> pointDropZ,
>> mapset = mapset)
>> }
>> else {
>> res <- .read_vect_non_plugin(vname = vname, layer = layer,
>> type = type, remove.duplicates = remove.duplicates,
>> ignore.stderr = ignore.stderr, pointDropZ = pointDropZ,
>> driver = driver, with_prj = with_prj, with_c = with_c)
>> }
>> }, finally = {
>> if (get.suppressEchoCmdInFuncOption()) {
>> tull <- set.echoCmdOption(inEchoCmd)
>> }
>> })
>> 1: readVECT(zm.gnrl)
>>
>>> vInfo(zm.gnrl)
>>>
>> nodes points lines boundaries centroids areas
>> islands primitives map3d
>> 274 0 0 302 31 31
>> 3 333 0
>>
>> Thanks
>>
>>
>> 2015-10-09 11:36 GMT-03:00 Roger Bivand <***@nhh.no>:
>>
>> If it is the v.info call, please run:
>>>
>>> res <- execGRASS("v.info", flags="t", map="zm.gnrl", layer=1L,
>>> intern=TRUE)
>>>
>>> and report the output of:
>>>
>>> print(res)
>>>
>>> and maybe send me offlist the output of
>>>
>>> save(res, file="vinfo_odd_output.RData")
>>>
>>> Roger
>>>
>>> --
>>> Roger Bivand
>>> Norwegian School of Economics
>>> Helleveien 30, 5045 Bergen, Norway
>>> ***@nhh.no
>>>
>>>
>>> ________________________________________
>>> Fra: grass-stats [grass-stats-***@lists.osgeo.org] p&#229; vegne av
>>> Roger Bivand [***@nhh.no]
>>> Sendt: 9. oktober 2015 4:27
>>> Til: Eduardo Diez
>>> Kopi: grass-***@lists.osgeo.org
>>> Emne: Re: [GRASS-stats] rgrass7 read/write SpatialPolygonsDataFrames
>>> errors
>>>
>>> OK, please provide the output of traceback() run immediately after the
>>> failing readVECT(). That will show which command invokes scan(). Also try
>>> to run vInfo(zm.gnrl) - I think the failure is in:
>>>
>>> execGRASS("v.info", flags="t", map="zm.gnrl", layer=1L)
>>>
>>> not returning a structure that vInfo understands, and which ois then used
>>> in readVECT().
>>>
>>> Roger
>>>
>>> --
>>> Roger Bivand
>>> Norwegian School of Economics
>>> Helleveien 30, 5045 Bergen, Norway
>>> ***@nhh.no
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> Fra: ***@gmail.com [***@gmail.com] på vegne av Eduardo Diez [
>>> ***@gmx.com]
>>>
>>> Sendt: 9. oktober 2015 4:04
>>>
>>> Til: Roger Bivand
>>>
>>> Kopi: grass-***@lists.osgeo.org
>>>
>>> Emne: Re: [GRASS-stats] rgrass7 read/write SpatialPolygonsDataFrames
>>> errors
>>>
>>>
>>>
>>>
>>>
>>>
>>> Roger, with GRASS version 7.0.1 and rgrass7_0.1-3, readVECT now doesn't
>>> ask for the driver to use but gives the same error as before:
>>>
>>>
>>>
>>>
>>> writeVECT(SDF = mz.pol, vname = zm.pol, v.in.ogr_flags = "o")
>>> Over-riding projection check
>>> Check if OGR layer <q7468fb> contains polygons...
>>>
>>>
>>>
>>> Importing 205 features (OGR layer <q7468fb>)...
>>>
>>>
>>>
>>> -----------------------------------------------------
>>> Registering primitives...
>>> 3924 primitives registered
>>> 12866 vertices registered
>>> Number of nodes: 2884
>>> Number of primitives: 3924
>>> Number of points: 0
>>> Number of lines: 0
>>> Number of boundaries: 3924
>>> Number of centroids: 0
>>> Number of areas: -
>>> Number of isles: -
>>> -----------------------------------------------------
>>> Cleaning polygons
>>> -----------------------------------------------------
>>> Breaking polygons...
>>> Breaking polygons (pass 1: select break points)...
>>>
>>>
>>>
>>> Breaking polygons (pass 2: break at selected points)...
>>>
>>>
>>>
>>> -----------------------------------------------------
>>> Removing duplicates...
>>>
>>>
>>>
>>> -----------------------------------------------------
>>> Breaking boundaries...
>>>
>>>
>>>
>>> -----------------------------------------------------
>>> Removing duplicates...
>>>
>>>
>>>
>>> -----------------------------------------------------
>>> Cleaning boundaries at nodes...
>>>
>>>
>>>
>>> -----------------------------------------------------
>>> Merging boundaries...
>>>
>>>
>>>
>>> -----------------------------------------------------
>>> Removing dangles...
>>>
>>>
>>>
>>> -----------------------------------------------------
>>> Building areas...
>>>
>>>
>>>
>>> 205 areas built
>>> 13 isles built
>>> Number of nodes: 2929
>>> Number of primitives: 7268
>>> Number of points: 0
>>> Number of lines: 0
>>> Number of boundaries: 7268
>>> Number of centroids: 0
>>> Number of areas: 205
>>> Number of isles: 13
>>> -----------------------------------------------------
>>> Removing bridges...
>>>
>>>
>>>
>>> -----------------------------------------------------
>>> Registering primitives...
>>> 498 primitives registered
>>> 5828 vertices registered
>>> Building areas...
>>>
>>>
>>>
>>> 205 areas built
>>> 13 isles built
>>> Attaching islands...
>>>
>>>
>>>
>>> Number of nodes: 306
>>> Number of primitives: 498
>>> Number of points: 0
>>> Number of lines: 0
>>> Number of boundaries: 498
>>> Number of centroids: 0
>>> Number of areas: 205
>>> Number of isles: 13
>>> -----------------------------------------------------
>>> Finding centroids for OGR layer <q7468fb>...
>>>
>>>
>>>
>>> -----------------------------------------------------
>>> Writing centroids...
>>>
>>>
>>>
>>> -----------------------------------------------------
>>> 205 input polygons
>>> Total area: 1.25187E+006 (205 areas)
>>> -----------------------------------------------------
>>> Copying features...
>>>
>>>
>>>
>>> WARNING: Unable to delete file
>>>
>>>
>>> 'C:/Users/ediez1/AppData/Local/Temp/Rtmpqkeay4/file480c1e5e16a7/file480c11cc233b/.tmp/unknown/vector/tmp_8308/coor'
>>> Building topology for vector map <***@file480c11cc233b>...
>>> Registering primitives...
>>> 703 primitives registered
>>> 6033 vertices registered
>>> Building areas...
>>>
>>>
>>>
>>> 205 areas built
>>> 13 isles built
>>> Attaching islands...
>>>
>>>
>>>
>>> Attaching centroids...
>>>
>>>
>>>
>>> Number of nodes: 306
>>> Number of primitives: 703
>>> Number of points: 0
>>> Number of lines: 0
>>> Number of boundaries: 498
>>> Number of centroids: 205
>>> Number of areas: 205
>>> Number of isles: 13
>>>
>>>> execGRASS("v.clean", flags = c("overwrite"), input = zm.pol,
>>>>
>>> + output = zm.gnrl, tool = "rmarea", threshold = 3000)
>>> --------------------------------------------------
>>> Tool: Threshold
>>> Remove small areas: 3000
>>> --------------------------------------------------
>>> Copying features...
>>>
>>>
>>>
>>> Rebuilding parts of topology...
>>> Building topology for vector map <***@file480c11cc233b>...
>>> Registering primitives...
>>> 703 primitives registered
>>> 6033 vertices registered
>>> Building areas...
>>>
>>>
>>>
>>> 205 areas built
>>> 13 isles built
>>> Attaching islands...
>>>
>>>
>>>
>>> Attaching centroids...
>>>
>>>
>>>
>>> Number of nodes: 306
>>> Number of primitives: 703
>>> Number of points: 0
>>> Number of lines: 0
>>> Number of boundaries: 498
>>> Number of centroids: 205
>>> Number of areas: 205
>>> Number of isles: 13
>>> --------------------------------------------------
>>> Tool: Remove small areas
>>>
>>>
>>>
>>> 174 areas of total size 50601.7 removed
>>> --------------------------------------------------
>>> Rebuilding topology for output vector map...
>>> Building topology for vector map <***@file480c11cc233b>...
>>> Registering primitives...
>>> 333 primitives registered
>>> 4705 vertices registered
>>> Building areas...
>>>
>>>
>>>
>>> 31 areas built
>>> 3 isles built
>>> Attaching islands...
>>>
>>>
>>>
>>> Attaching centroids...
>>>
>>>
>>>
>>> Number of nodes: 274
>>> Number of primitives: 333
>>> Number of points: 0
>>> Number of lines: 0
>>> Number of boundaries: 302
>>> Number of centroids: 31
>>> Number of areas: 31
>>> Number of isles: 3
>>>
>>>> zm.fnl <- readVECT(zm.gnrl)
>>>>
>>>
>>>
>>> Error in scan(file, what, nmax, sep, dec, quote, skip, nlines,
>>> na.strings, :
>>> line 4 did not have 2 elements
>>>
>>>> sessionInfo()
>>>>
>>> R version 3.2.2 (2015-08-14)
>>> Platform: x86_64-w64-mingw32/x64 (64-bit)
>>> Running under: Windows 7 x64 (build 7601) Service Pack 1
>>>
>>>
>>>
>>> locale:
>>> [1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United
>>> States.1252 LC_MONETARY=English_United States.1252
>>> [4] LC_NUMERIC=C LC_TIME=English_United
>>> States.1252
>>>
>>>
>>>
>>> attached base packages:
>>> [1] stats graphics grDevices utils datasets methods base
>>>
>>>
>>>
>>> other attached packages:
>>> [1] RPyGeo_0.9-3 RSAGA_0.94-3 plyr_1.8.3 gstat_1.0-26
>>> shapefiles_0.7 foreign_0.8-65 maptools_0.8-37 rgdal_1.0-7
>>> classInt_0.1-23
>>> [10] raster_2.4-20 rgrass7_0.1-3 XML_3.98-1.3 sp_1.2-0
>>>
>>>
>>>
>>> loaded via a namespace (and not attached):
>>> [1] Rcpp_0.12.1 intervals_0.15.1 lattice_0.20-33 FNN_1.1
>>> spacetime_1.1-4 class_7.3-13 zoo_1.7-12 grid_3.2.2
>>> [9] e1071_1.6-7 xts_0.9-7 tools_3.2.2
>>>
>>>
>>>
>>>
>>> Thanks
>>>
>>>
>>>
>>>
>>>
>>>
>>> 2015-10-08 18:57 GMT-03:00 Roger Bivand
>>> <***@nhh.no>:
>>>
>>>
>>> Sorry this has taken a long time; please try installing the development
>>> version available from:
>>>
>>>
>>>
>>> http://win-builder.r-project.org/8Y3Ihj451Clx
>>>
>>>
>>>
>>> (rgrass7_0.1-3.zip). The problem was the use of "_" instead of " " in the
>>> name of the OGR shapefile driver - in OGR and R it is "ESRI Shapefile",
>>> in
>>> GRASS it is "ESRI_Shapefile". Because the new long-name work-around
>>> worked
>>> on systems not needing to use this
>>> driver, it wasn't properly tested - and on Windows the GRASS standalone
>>> has OGR with the SQLite driver, but the Windows rgdal binary does not
>>> have
>>> SQLite. You may wish to install the R RSQLite package to move data if you
>>> use long field/column names.
>>>
>>>
>>>
>>> Before installing this development version, and after library(rgrass7),
>>> run example(readVECT) in the basic nc location from:
>>>
>>>
>>>
>>> https://grass.osgeo.org/sampledata/north_carolina/nc_basic_spm_grass7.zip
>>>
>>>
>>>
>>> it should fail. Then restart R, install the development version of
>>> rgrass7
>>> from the first link, and repeat - it works for me and should resolve the
>>> problem.
>>>
>>>
>>>
>>> Hope this helps,
>>>
>>>
>>>
>>> Roger
>>>
>>>
>>>
>>>
>>>
>>> --
>>>
>>> Roger Bivand
>>>
>>> Norwegian School of Economics
>>>
>>> Helleveien 30, 5045 Bergen, Norway
>>>
>>> ***@nhh.no
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> Fra:
>>> grass-stats-***@lists.osgeo.org [grass-stats-***@lists.osgeo.org
>>> ]
>>> på vegne av Eduardo Diez [***@gmx.com]
>>>
>>> Sendt: 24. september 2015 9:11
>>>
>>> Til:
>>> grass-***@lists.osgeo.org
>>>
>>> Emne: [GRASS-stats] rgrass7 read/write SpatialPolygonsDataFrames errors
>>>
>>>
>>>
>>>
>>>
>>>
>>> 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.
>>>
>>>
>>>
>>>
>>>
>>> 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).
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> 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.
>>>
>>> Below i paste an extract of my R console with the errors and some
>>> information.
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> Thanks in advance,
>>>
>>>
>>>
>>> Eduardo
>>>
>>>
>>>
>>>
>>>
>>> mult.rp <- projectRaster(mult.r, crs = prj.crs, method = "ngb")
>>>>
>>>
>>> mult.pol <- rasterToPolygons(mult.rp, dissolve = T)
>>>>
>>>
>>>
>>>
>>> initGRASS(gisBase = "c:/Program Files (x86)/GRASS GIS 7.0.1", home =
>>>>
>>> tempdir(), override = T)
>>>
>>> gisdbase C:/Users/ediez1/AppData/Local/Temp/RtmpegbyiQ
>>>
>>> location file2f7c6dc070e6
>>>
>>> mapset file2f7c30eb3f52
>>>
>>> rows 1
>>>
>>> columns 1
>>>
>>> north 1
>>>
>>> south 0
>>>
>>> west 0
>>>
>>> east 1
>>>
>>> nsres 1
>>>
>>> ewres 1
>>>
>>> projection NA
>>>
>>> writeVECT(mult.pol, "pol1", v.in.ogr_flags = "o")
>>>>
>>>
>>> Error: !is.null(driver) is not TRUE
>>>
>>> writeVECT(mult.pol, "pol1", v.in.ogr_flags = "o", driver = "ESRI
>>>>
>>> Shapefile")
>>>
>>>
>>>
>>> Over-riding projection check
>>>
>>> Check if OGR layer <r848659> contains polygons...
>>>
>>>
>>>
>>>
>>>
>>> Importing 4 features (OGR layer <r848659>)...
>>>
>>>
>>>
>>>
>>>
>>> -----------------------------------------------------
>>>
>>> Registering primitives...
>>>
>>> 3005 primitives registered
>>>
>>> 15587 vertices registered
>>>
>>> Number of nodes: 2691
>>>
>>> Number of primitives: 3005
>>>
>>> Number of points: 0
>>>
>>> Number of lines: 0
>>>
>>> Number of boundaries: 3005
>>>
>>> Number of centroids: 0
>>>
>>> Number of areas: -
>>>
>>> Number of isles: -
>>>
>>> -----------------------------------------------------
>>>
>>> Cleaning polygons
>>>
>>> -----------------------------------------------------
>>>
>>> Breaking polygons...
>>>
>>> Breaking polygons (pass 1: select break points)...
>>>
>>>
>>>
>>>
>>>
>>> Breaking polygons (pass 2: break at selected points)...
>>>
>>>
>>>
>>>
>>>
>>> -----------------------------------------------------
>>>
>>> Removing duplicates...
>>>
>>>
>>>
>>>
>>>
>>> -----------------------------------------------------
>>>
>>> Breaking boundaries...
>>>
>>>
>>>
>>>
>>>
>>> -----------------------------------------------------
>>>
>>> Removing duplicates...
>>>
>>>
>>>
>>>
>>>
>>> -----------------------------------------------------
>>>
>>> Cleaning boundaries at nodes...
>>>
>>>
>>>
>>>
>>>
>>> -----------------------------------------------------
>>>
>>> Merging boundaries...
>>>
>>>
>>>
>>>
>>>
>>> -----------------------------------------------------
>>>
>>> Removing dangles...
>>>
>>>
>>>
>>>
>>>
>>> -----------------------------------------------------
>>>
>>> Building areas...
>>>
>>>
>>>
>>>
>>>
>>> 95 areas built
>>>
>>> 8 isles built
>>>
>>> Number of nodes: 2771
>>>
>>> Number of primitives: 7307
>>>
>>> Number of points: 0
>>>
>>> Number of lines: 0
>>>
>>> Number of boundaries: 7307
>>>
>>> Number of centroids: 0
>>>
>>> Number of areas: 95
>>>
>>> Number of isles: 8
>>>
>>> -----------------------------------------------------
>>>
>>> Removing bridges...
>>>
>>>
>>>
>>>
>>>
>>> -----------------------------------------------------
>>>
>>> Registering primitives...
>>>
>>> 231 primitives registered
>>>
>>> 7594 vertices registered
>>>
>>> Building areas...
>>>
>>>
>>>
>>>
>>>
>>> 95 areas built
>>>
>>> 8 isles built
>>>
>>> Attaching islands...
>>>
>>>
>>>
>>>
>>>
>>> Number of nodes: 144
>>>
>>> Number of primitives: 231
>>>
>>> Number of points: 0
>>>
>>> Number of lines: 0
>>>
>>> Number of boundaries: 231
>>>
>>> Number of centroids: 0
>>>
>>> Number of areas: 95
>>>
>>> Number of isles: 8
>>>
>>> -----------------------------------------------------
>>>
>>> Finding centroids for OGR layer <r848659>...
>>>
>>>
>>>
>>>
>>>
>>> -----------------------------------------------------
>>>
>>> Writing centroids...
>>>
>>>
>>>
>>>
>>>
>>> -----------------------------------------------------
>>>
>>> 95 input polygons
>>>
>>> Total area: 1.28981E+006 (95 areas)
>>>
>>> -----------------------------------------------------
>>>
>>> Copying features...
>>>
>>>
>>>
>>>
>>>
>>> WARNING: Unable to delete file
>>>
>>>
>>>
>>> 'C:/Users/ediez1/AppData/Local/Temp/Rtmpg10lvi/filec2473b0126/filec24129b63ac/.tmp/unknown/vector/tmp_10484/coor'
>>>
>>> Building topology for vector map <***@filec24129b63ac>...
>>>
>>> Registering primitives...
>>>
>>> 326 primitives registered
>>>
>>> 7689 vertices registered
>>>
>>> Building areas...
>>>
>>>
>>>
>>>
>>>
>>> 95 areas built
>>>
>>> 8 isles built
>>>
>>> Attaching islands...
>>>
>>>
>>>
>>>
>>>
>>> Attaching centroids...
>>>
>>>
>>>
>>>
>>>
>>> Number of nodes: 144
>>>
>>> Number of primitives: 326
>>>
>>> Number of points: 0
>>>
>>> Number of lines: 0
>>>
>>> Number of boundaries: 231
>>>
>>> Number of centroids: 95
>>>
>>> Number of areas: 95
>>>
>>> Number of isles: 8
>>>
>>>
>>>
>>>
>>>
>>> execGRASS("v.clean", flags = c("overwrite"), input = "pol1",
>>>>
>>>
>>> + output = "clnpol", tool = "rmarea", threshold = 3000)
>>>
>>> --------------------------------------------------
>>>
>>> Tool: Threshold
>>>
>>> Remove small areas: 3000
>>>
>>> --------------------------------------------------
>>>
>>> Copying features...
>>>
>>>
>>>
>>>
>>>
>>> Rebuilding parts of topology...
>>>
>>> Building topology for vector map <***@filec24129b63ac>...
>>>
>>> Registering primitives...
>>>
>>> 326 primitives registered
>>>
>>> 7689 vertices registered
>>>
>>> Building areas...
>>>
>>>
>>>
>>>
>>>
>>> 95 areas built
>>>
>>> 8 isles built
>>>
>>> Attaching islands...
>>>
>>>
>>>
>>>
>>>
>>> Attaching centroids...
>>>
>>>
>>>
>>>
>>>
>>> Number of nodes: 144
>>>
>>> Number of primitives: 326
>>>
>>> Number of points: 0
>>>
>>> Number of lines: 0
>>>
>>> Number of boundaries: 231
>>>
>>> Number of centroids: 95
>>>
>>> Number of areas: 95
>>>
>>> Number of isles: 8
>>>
>>> --------------------------------------------------
>>>
>>> Tool: Remove small areas
>>>
>>>
>>>
>>>
>>>
>>> 55 areas of total size 29487.1 removed
>>>
>>> --------------------------------------------------
>>>
>>> Rebuilding topology for output vector map...
>>>
>>> Building topology for vector map <***@filec24129b63ac>...
>>>
>>> Registering primitives...
>>>
>>> 212 primitives registered
>>>
>>> 6840 vertices registered
>>>
>>> Building areas...
>>>
>>>
>>>
>>>
>>>
>>> 40 areas built
>>>
>>> 4 isles built
>>>
>>> Attaching islands...
>>>
>>>
>>>
>>>
>>>
>>> Attaching centroids...
>>>
>>>
>>>
>>>
>>>
>>> Number of nodes: 136
>>>
>>> Number of primitives: 212
>>>
>>> Number of points: 0
>>>
>>> Number of lines: 0
>>>
>>> Number of boundaries: 172
>>>
>>> Number of centroids: 40
>>>
>>> Number of areas: 40
>>>
>>> Number of isles: 4
>>>
>>> cln.pol <- readVECT("clnpol")
>>>>
>>>
>>> Error: !is.null(driver) is not TRUE
>>>
>>> cln.pol <- readVECT("clnpol", driver = "ESRI Shapefile")
>>>>
>>>
>>> Error in scan(file, what, nmax, sep, dec, quote, skip, nlines,
>>> na.strings, :
>>>
>>> line 4 did not have 2 elements
>>>
>>>
>>>
>>>
>>>
>>> sessionInfo()
>>>>
>>>
>>> R version 3.2.2 (2015-08-14)
>>>
>>> Platform: x86_64-w64-mingw32/x64 (64-bit)
>>>
>>> Running under: Windows 7 x64 (build 7601) Service Pack 1
>>>
>>>
>>>
>>>
>>>
>>> locale:
>>>
>>> [1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United
>>> States.1252 LC_MONETARY=English_United States.1252
>>>
>>> [4] LC_NUMERIC=C LC_TIME=English_United
>>> States.1252
>>>
>>>
>>>
>>>
>>>
>>> attached base packages:
>>>
>>> [1] stats graphics grDevices utils datasets methods base
>>>
>>>
>>>
>>>
>>>
>>> other attached packages:
>>>
>>> [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
>>>
>>>
>>>
>>>
>>>
>>> loaded via a namespace (and not attached):
>>>
>>> [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
>>>
>>> [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
>>>
>>> [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
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> _______________________________________________
>>> grass-stats mailing list
>>> grass-***@lists.osgeo.org
>>> http://lists.osgeo.org/mailman/listinfo/grass-stats
>>>
>>>
>>
> --
> Roger Bivand
> Department of Economics, Norwegian School of Economics,
> Helleveien 30, N-5045 Bergen, Norway.
> voice: +47 55 95 93 55; fax +47 55 95 91 00
> e-mail: ***@nhh.no
>
Roger Bivand
2015-10-10 16:12:45 UTC
Permalink
On Sat, 10 Oct 2015, Eduardo Diez wrote:

> Apparently "v.info" through execGRASS is expecting the "layer" argument to
> be a string rather than an integer.

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):

vinfo0 <- execGRASS("v.info", flags="c", map=zm.gnrl)

My guess is that v.info is saying that this map is broken, or suffering
from something that vColumns does not know about.

v.info -c map=

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).

Does readVECT() work if you do not use v.clean? Is v.clean having a side
effect of causing v.info -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?)?

Roger

>
>
>> zm.fnl <- readVECT(zm.gnrl)Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings, :
> line 4 did not have 2 elements> vinfo0 <- execGRASS("v.info",
> flags="c", map=zm.gnrl, layer=1L,+ intern=TRUE)Error in doGRASS(cmd,
> flags = flags, ..., parameters = parameters, echoCmd = echoCmd, :
> Parameter <layer> does not have string value>
> parseGRASS("v.info")Command: v.info
> Extension: .exe
> Description: Outputs basic information about a vector map.
> Keywords: vector, metadata, topology, extent, history, attribute columns
> Parameters:
> name: map, type: string, required: yes, multiple: no
> keydesc: name, keydesc_count: 1
> [Or data source for direct OGR access]
> name: layer, type: string, required: no, multiple: no
> default: 1
> [Vector features can have category values in different layers. This
> number determines which layer to use. When used with direct OGR access
> this is the layer name.]
> Flags:
> name: h [Print history instead of info and exit] {FALSE}
> name: c [Print types/names of table columns for specified layer
> instead of info and exit] {FALSE}
> name: g [Print region info in shell script style] {FALSE}
> name: e [Print extended metadata info in shell script style] {FALSE}
> name: t [Print topology info in shell script style] {FALSE}
> name: help [Print usage summary] {FALSE}
> name: verbose [Verbose module output] {FALSE}
> name: quiet [Quiet module output] {FALSE}
>
>
>>
>
> 2015-10-10 10:56 GMT-03:00 Roger Bivand <***@nhh.no>:
>
>> OK, thanks. So the failure is in:
>>
>> vinfo0 <- execGRASS("v.info", flags="c", map="<name>", layer=1L,
>> intern=TRUE)
>>
>> used to return the column/field names. Please repeat with that.
>>
>> Roger
>>
>>
>> On Fri, 9 Oct 2015, Eduardo Diez wrote:
>>
>> Here are the traceback and the vInfo(zm.gnrl). The latter seems to work
>>> fine.
>>>
>>> zm.fnl <- readVECT(zm.gnrl)
>>>>
>>> Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings,
>>> :
>>> line 4 did not have 2 elements
>>>
>>>> traceback()
>>>>
>>> 8: scan(file = file, what = what, sep = sep, quote = quote, dec = dec,
>>> nmax = nrows, skip = 0, na.strings = na.strings, quiet = TRUE,
>>> fill = fill, strip.white = strip.white, blank.lines.skip =
>>> blank.lines.skip,
>>> multi.line = FALSE, comment.char = comment.char, allowEscapes =
>>> allowEscapes,
>>> flush = flush, encoding = encoding, skipNul = skipNul)
>>> 7: read.table(con, header = FALSE, sep = "|")
>>> 6: vColumns(vname)
>>> 5: nchar(as.character(vColumns(vname)$name))
>>> 4: .read_vect_non_plugin(vname = vname, layer = layer, type = type,
>>> remove.duplicates = remove.duplicates, ignore.stderr =
>>> ignore.stderr,
>>> pointDropZ = pointDropZ, driver = driver, with_prj = with_prj,
>>> with_c = with_c)
>>> 3: tryCatchList(expr, classes, parentenv, handlers)
>>> 2: tryCatch({
>>> stopifnot(is.logical(plugin) || is.null(plugin))
>>> stopifnot(is.logical(ignore.stderr))
>>> if (missing(layer))
>>> layer <- 1L
>>> layer <- as.character(layer)
>>> stopifnot(is.logical(with_c))
>>> if (!is.null(driver) && driver == "GRASS")
>>> plugin <- TRUE
>>> if (!requireNamespace("rgdal", quietly = TRUE)) {
>>> stop("rgdal not available")
>>> }
>>> if (is.null(plugin)) {
>>> ogrD <- rgdal::ogrDrivers()$name
>>> plugin <- "GRASS" %in% ogrD
>>> }
>>> if (plugin) {
>>> res <- .read_vect_plugin(vname = vname, layer = layer,
>>> type = type, ignore.stderr = ignore.stderr, pointDropZ =
>>> pointDropZ,
>>> mapset = mapset)
>>> }
>>> else {
>>> res <- .read_vect_non_plugin(vname = vname, layer = layer,
>>> type = type, remove.duplicates = remove.duplicates,
>>> ignore.stderr = ignore.stderr, pointDropZ = pointDropZ,
>>> driver = driver, with_prj = with_prj, with_c = with_c)
>>> }
>>> }, finally = {
>>> if (get.suppressEchoCmdInFuncOption()) {
>>> tull <- set.echoCmdOption(inEchoCmd)
>>> }
>>> })
>>> 1: readVECT(zm.gnrl)
>>>
>>>> vInfo(zm.gnrl)
>>>>
>>> nodes points lines boundaries centroids areas
>>> islands primitives map3d
>>> 274 0 0 302 31 31
>>> 3 333 0
>>>
>>> Thanks
>>>
>>>
>>> 2015-10-09 11:36 GMT-03:00 Roger Bivand <***@nhh.no>:
>>>
>>> If it is the v.info call, please run:
>>>>
>>>> res <- execGRASS("v.info", flags="t", map="zm.gnrl", layer=1L,
>>>> intern=TRUE)
>>>>
>>>> and report the output of:
>>>>
>>>> print(res)
>>>>
>>>> and maybe send me offlist the output of
>>>>
>>>> save(res, file="vinfo_odd_output.RData")
>>>>
>>>> Roger
>>>>
>>>> --
>>>> Roger Bivand
>>>> Norwegian School of Economics
>>>> Helleveien 30, 5045 Bergen, Norway
>>>> ***@nhh.no
>>>>
>>>>
>>>> ________________________________________
>>>> Fra: grass-stats [grass-stats-***@lists.osgeo.org] p&#229; vegne av
>>>> Roger Bivand [***@nhh.no]
>>>> Sendt: 9. oktober 2015 4:27
>>>> Til: Eduardo Diez
>>>> Kopi: grass-***@lists.osgeo.org
>>>> Emne: Re: [GRASS-stats] rgrass7 read/write SpatialPolygonsDataFrames
>>>> errors
>>>>
>>>> OK, please provide the output of traceback() run immediately after the
>>>> failing readVECT(). That will show which command invokes scan(). Also try
>>>> to run vInfo(zm.gnrl) - I think the failure is in:
>>>>
>>>> execGRASS("v.info", flags="t", map="zm.gnrl", layer=1L)
>>>>
>>>> not returning a structure that vInfo understands, and which ois then used
>>>> in readVECT().
>>>>
>>>> Roger
>>>>
>>>> --
>>>> Roger Bivand
>>>> Norwegian School of Economics
>>>> Helleveien 30, 5045 Bergen, Norway
>>>> ***@nhh.no
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> Fra: ***@gmail.com [***@gmail.com] på vegne av Eduardo Diez [
>>>> ***@gmx.com]
>>>>
>>>> Sendt: 9. oktober 2015 4:04
>>>>
>>>> Til: Roger Bivand
>>>>
>>>> Kopi: grass-***@lists.osgeo.org
>>>>
>>>> Emne: Re: [GRASS-stats] rgrass7 read/write SpatialPolygonsDataFrames
>>>> errors
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> Roger, with GRASS version 7.0.1 and rgrass7_0.1-3, readVECT now doesn't
>>>> ask for the driver to use but gives the same error as before:
>>>>
>>>>
>>>>
>>>>
>>>> writeVECT(SDF = mz.pol, vname = zm.pol, v.in.ogr_flags = "o")
>>>> Over-riding projection check
>>>> Check if OGR layer <q7468fb> contains polygons...
>>>>
>>>>
>>>>
>>>> Importing 205 features (OGR layer <q7468fb>)...
>>>>
>>>>
>>>>
>>>> -----------------------------------------------------
>>>> Registering primitives...
>>>> 3924 primitives registered
>>>> 12866 vertices registered
>>>> Number of nodes: 2884
>>>> Number of primitives: 3924
>>>> Number of points: 0
>>>> Number of lines: 0
>>>> Number of boundaries: 3924
>>>> Number of centroids: 0
>>>> Number of areas: -
>>>> Number of isles: -
>>>> -----------------------------------------------------
>>>> Cleaning polygons
>>>> -----------------------------------------------------
>>>> Breaking polygons...
>>>> Breaking polygons (pass 1: select break points)...
>>>>
>>>>
>>>>
>>>> Breaking polygons (pass 2: break at selected points)...
>>>>
>>>>
>>>>
>>>> -----------------------------------------------------
>>>> Removing duplicates...
>>>>
>>>>
>>>>
>>>> -----------------------------------------------------
>>>> Breaking boundaries...
>>>>
>>>>
>>>>
>>>> -----------------------------------------------------
>>>> Removing duplicates...
>>>>
>>>>
>>>>
>>>> -----------------------------------------------------
>>>> Cleaning boundaries at nodes...
>>>>
>>>>
>>>>
>>>> -----------------------------------------------------
>>>> Merging boundaries...
>>>>
>>>>
>>>>
>>>> -----------------------------------------------------
>>>> Removing dangles...
>>>>
>>>>
>>>>
>>>> -----------------------------------------------------
>>>> Building areas...
>>>>
>>>>
>>>>
>>>> 205 areas built
>>>> 13 isles built
>>>> Number of nodes: 2929
>>>> Number of primitives: 7268
>>>> Number of points: 0
>>>> Number of lines: 0
>>>> Number of boundaries: 7268
>>>> Number of centroids: 0
>>>> Number of areas: 205
>>>> Number of isles: 13
>>>> -----------------------------------------------------
>>>> Removing bridges...
>>>>
>>>>
>>>>
>>>> -----------------------------------------------------
>>>> Registering primitives...
>>>> 498 primitives registered
>>>> 5828 vertices registered
>>>> Building areas...
>>>>
>>>>
>>>>
>>>> 205 areas built
>>>> 13 isles built
>>>> Attaching islands...
>>>>
>>>>
>>>>
>>>> Number of nodes: 306
>>>> Number of primitives: 498
>>>> Number of points: 0
>>>> Number of lines: 0
>>>> Number of boundaries: 498
>>>> Number of centroids: 0
>>>> Number of areas: 205
>>>> Number of isles: 13
>>>> -----------------------------------------------------
>>>> Finding centroids for OGR layer <q7468fb>...
>>>>
>>>>
>>>>
>>>> -----------------------------------------------------
>>>> Writing centroids...
>>>>
>>>>
>>>>
>>>> -----------------------------------------------------
>>>> 205 input polygons
>>>> Total area: 1.25187E+006 (205 areas)
>>>> -----------------------------------------------------
>>>> Copying features...
>>>>
>>>>
>>>>
>>>> WARNING: Unable to delete file
>>>>
>>>>
>>>> 'C:/Users/ediez1/AppData/Local/Temp/Rtmpqkeay4/file480c1e5e16a7/file480c11cc233b/.tmp/unknown/vector/tmp_8308/coor'
>>>> Building topology for vector map <***@file480c11cc233b>...
>>>> Registering primitives...
>>>> 703 primitives registered
>>>> 6033 vertices registered
>>>> Building areas...
>>>>
>>>>
>>>>
>>>> 205 areas built
>>>> 13 isles built
>>>> Attaching islands...
>>>>
>>>>
>>>>
>>>> Attaching centroids...
>>>>
>>>>
>>>>
>>>> Number of nodes: 306
>>>> Number of primitives: 703
>>>> Number of points: 0
>>>> Number of lines: 0
>>>> Number of boundaries: 498
>>>> Number of centroids: 205
>>>> Number of areas: 205
>>>> Number of isles: 13
>>>>
>>>>> execGRASS("v.clean", flags = c("overwrite"), input = zm.pol,
>>>>>
>>>> + output = zm.gnrl, tool = "rmarea", threshold = 3000)
>>>> --------------------------------------------------
>>>> Tool: Threshold
>>>> Remove small areas: 3000
>>>> --------------------------------------------------
>>>> Copying features...
>>>>
>>>>
>>>>
>>>> Rebuilding parts of topology...
>>>> Building topology for vector map <***@file480c11cc233b>...
>>>> Registering primitives...
>>>> 703 primitives registered
>>>> 6033 vertices registered
>>>> Building areas...
>>>>
>>>>
>>>>
>>>> 205 areas built
>>>> 13 isles built
>>>> Attaching islands...
>>>>
>>>>
>>>>
>>>> Attaching centroids...
>>>>
>>>>
>>>>
>>>> Number of nodes: 306
>>>> Number of primitives: 703
>>>> Number of points: 0
>>>> Number of lines: 0
>>>> Number of boundaries: 498
>>>> Number of centroids: 205
>>>> Number of areas: 205
>>>> Number of isles: 13
>>>> --------------------------------------------------
>>>> Tool: Remove small areas
>>>>
>>>>
>>>>
>>>> 174 areas of total size 50601.7 removed
>>>> --------------------------------------------------
>>>> Rebuilding topology for output vector map...
>>>> Building topology for vector map <***@file480c11cc233b>...
>>>> Registering primitives...
>>>> 333 primitives registered
>>>> 4705 vertices registered
>>>> Building areas...
>>>>
>>>>
>>>>
>>>> 31 areas built
>>>> 3 isles built
>>>> Attaching islands...
>>>>
>>>>
>>>>
>>>> Attaching centroids...
>>>>
>>>>
>>>>
>>>> Number of nodes: 274
>>>> Number of primitives: 333
>>>> Number of points: 0
>>>> Number of lines: 0
>>>> Number of boundaries: 302
>>>> Number of centroids: 31
>>>> Number of areas: 31
>>>> Number of isles: 3
>>>>
>>>>> zm.fnl <- readVECT(zm.gnrl)
>>>>>
>>>>
>>>>
>>>> Error in scan(file, what, nmax, sep, dec, quote, skip, nlines,
>>>> na.strings, :
>>>> line 4 did not have 2 elements
>>>>
>>>>> sessionInfo()
>>>>>
>>>> R version 3.2.2 (2015-08-14)
>>>> Platform: x86_64-w64-mingw32/x64 (64-bit)
>>>> Running under: Windows 7 x64 (build 7601) Service Pack 1
>>>>
>>>>
>>>>
>>>> locale:
>>>> [1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United
>>>> States.1252 LC_MONETARY=English_United States.1252
>>>> [4] LC_NUMERIC=C LC_TIME=English_United
>>>> States.1252
>>>>
>>>>
>>>>
>>>> attached base packages:
>>>> [1] stats graphics grDevices utils datasets methods base
>>>>
>>>>
>>>>
>>>> other attached packages:
>>>> [1] RPyGeo_0.9-3 RSAGA_0.94-3 plyr_1.8.3 gstat_1.0-26
>>>> shapefiles_0.7 foreign_0.8-65 maptools_0.8-37 rgdal_1.0-7
>>>> classInt_0.1-23
>>>> [10] raster_2.4-20 rgrass7_0.1-3 XML_3.98-1.3 sp_1.2-0
>>>>
>>>>
>>>>
>>>> loaded via a namespace (and not attached):
>>>> [1] Rcpp_0.12.1 intervals_0.15.1 lattice_0.20-33 FNN_1.1
>>>> spacetime_1.1-4 class_7.3-13 zoo_1.7-12 grid_3.2.2
>>>> [9] e1071_1.6-7 xts_0.9-7 tools_3.2.2
>>>>
>>>>
>>>>
>>>>
>>>> Thanks
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> 2015-10-08 18:57 GMT-03:00 Roger Bivand
>>>> <***@nhh.no>:
>>>>
>>>>
>>>> Sorry this has taken a long time; please try installing the development
>>>> version available from:
>>>>
>>>>
>>>>
>>>> http://win-builder.r-project.org/8Y3Ihj451Clx
>>>>
>>>>
>>>>
>>>> (rgrass7_0.1-3.zip). The problem was the use of "_" instead of " " in the
>>>> name of the OGR shapefile driver - in OGR and R it is "ESRI Shapefile",
>>>> in
>>>> GRASS it is "ESRI_Shapefile". Because the new long-name work-around
>>>> worked
>>>> on systems not needing to use this
>>>> driver, it wasn't properly tested - and on Windows the GRASS standalone
>>>> has OGR with the SQLite driver, but the Windows rgdal binary does not
>>>> have
>>>> SQLite. You may wish to install the R RSQLite package to move data if you
>>>> use long field/column names.
>>>>
>>>>
>>>>
>>>> Before installing this development version, and after library(rgrass7),
>>>> run example(readVECT) in the basic nc location from:
>>>>
>>>>
>>>>
>>>> https://grass.osgeo.org/sampledata/north_carolina/nc_basic_spm_grass7.zip
>>>>
>>>>
>>>>
>>>> it should fail. Then restart R, install the development version of
>>>> rgrass7
>>>> from the first link, and repeat - it works for me and should resolve the
>>>> problem.
>>>>
>>>>
>>>>
>>>> Hope this helps,
>>>>
>>>>
>>>>
>>>> Roger
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> --
>>>>
>>>> Roger Bivand
>>>>
>>>> Norwegian School of Economics
>>>>
>>>> Helleveien 30, 5045 Bergen, Norway
>>>>
>>>> ***@nhh.no
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> Fra:
>>>> grass-stats-***@lists.osgeo.org [grass-stats-***@lists.osgeo.org
>>>> ]
>>>> på vegne av Eduardo Diez [***@gmx.com]
>>>>
>>>> Sendt: 24. september 2015 9:11
>>>>
>>>> Til:
>>>> grass-***@lists.osgeo.org
>>>>
>>>> Emne: [GRASS-stats] rgrass7 read/write SpatialPolygonsDataFrames errors
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> 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.
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> 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).
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> 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.
>>>>
>>>> Below i paste an extract of my R console with the errors and some
>>>> information.
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> Thanks in advance,
>>>>
>>>>
>>>>
>>>> Eduardo
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> mult.rp <- projectRaster(mult.r, crs = prj.crs, method = "ngb")
>>>>>
>>>>
>>>> mult.pol <- rasterToPolygons(mult.rp, dissolve = T)
>>>>>
>>>>
>>>>
>>>>
>>>> initGRASS(gisBase = "c:/Program Files (x86)/GRASS GIS 7.0.1", home =
>>>>>
>>>> tempdir(), override = T)
>>>>
>>>> gisdbase C:/Users/ediez1/AppData/Local/Temp/RtmpegbyiQ
>>>>
>>>> location file2f7c6dc070e6
>>>>
>>>> mapset file2f7c30eb3f52
>>>>
>>>> rows 1
>>>>
>>>> columns 1
>>>>
>>>> north 1
>>>>
>>>> south 0
>>>>
>>>> west 0
>>>>
>>>> east 1
>>>>
>>>> nsres 1
>>>>
>>>> ewres 1
>>>>
>>>> projection NA
>>>>
>>>> writeVECT(mult.pol, "pol1", v.in.ogr_flags = "o")
>>>>>
>>>>
>>>> Error: !is.null(driver) is not TRUE
>>>>
>>>> writeVECT(mult.pol, "pol1", v.in.ogr_flags = "o", driver = "ESRI
>>>>>
>>>> Shapefile")
>>>>
>>>>
>>>>
>>>> Over-riding projection check
>>>>
>>>> Check if OGR layer <r848659> contains polygons...
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> Importing 4 features (OGR layer <r848659>)...
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> -----------------------------------------------------
>>>>
>>>> Registering primitives...
>>>>
>>>> 3005 primitives registered
>>>>
>>>> 15587 vertices registered
>>>>
>>>> Number of nodes: 2691
>>>>
>>>> Number of primitives: 3005
>>>>
>>>> Number of points: 0
>>>>
>>>> Number of lines: 0
>>>>
>>>> Number of boundaries: 3005
>>>>
>>>> Number of centroids: 0
>>>>
>>>> Number of areas: -
>>>>
>>>> Number of isles: -
>>>>
>>>> -----------------------------------------------------
>>>>
>>>> Cleaning polygons
>>>>
>>>> -----------------------------------------------------
>>>>
>>>> Breaking polygons...
>>>>
>>>> Breaking polygons (pass 1: select break points)...
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> Breaking polygons (pass 2: break at selected points)...
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> -----------------------------------------------------
>>>>
>>>> Removing duplicates...
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> -----------------------------------------------------
>>>>
>>>> Breaking boundaries...
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> -----------------------------------------------------
>>>>
>>>> Removing duplicates...
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> -----------------------------------------------------
>>>>
>>>> Cleaning boundaries at nodes...
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> -----------------------------------------------------
>>>>
>>>> Merging boundaries...
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> -----------------------------------------------------
>>>>
>>>> Removing dangles...
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> -----------------------------------------------------
>>>>
>>>> Building areas...
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> 95 areas built
>>>>
>>>> 8 isles built
>>>>
>>>> Number of nodes: 2771
>>>>
>>>> Number of primitives: 7307
>>>>
>>>> Number of points: 0
>>>>
>>>> Number of lines: 0
>>>>
>>>> Number of boundaries: 7307
>>>>
>>>> Number of centroids: 0
>>>>
>>>> Number of areas: 95
>>>>
>>>> Number of isles: 8
>>>>
>>>> -----------------------------------------------------
>>>>
>>>> Removing bridges...
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> -----------------------------------------------------
>>>>
>>>> Registering primitives...
>>>>
>>>> 231 primitives registered
>>>>
>>>> 7594 vertices registered
>>>>
>>>> Building areas...
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> 95 areas built
>>>>
>>>> 8 isles built
>>>>
>>>> Attaching islands...
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> Number of nodes: 144
>>>>
>>>> Number of primitives: 231
>>>>
>>>> Number of points: 0
>>>>
>>>> Number of lines: 0
>>>>
>>>> Number of boundaries: 231
>>>>
>>>> Number of centroids: 0
>>>>
>>>> Number of areas: 95
>>>>
>>>> Number of isles: 8
>>>>
>>>> -----------------------------------------------------
>>>>
>>>> Finding centroids for OGR layer <r848659>...
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> -----------------------------------------------------
>>>>
>>>> Writing centroids...
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> -----------------------------------------------------
>>>>
>>>> 95 input polygons
>>>>
>>>> Total area: 1.28981E+006 (95 areas)
>>>>
>>>> -----------------------------------------------------
>>>>
>>>> Copying features...
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> WARNING: Unable to delete file
>>>>
>>>>
>>>>
>>>> 'C:/Users/ediez1/AppData/Local/Temp/Rtmpg10lvi/filec2473b0126/filec24129b63ac/.tmp/unknown/vector/tmp_10484/coor'
>>>>
>>>> Building topology for vector map <***@filec24129b63ac>...
>>>>
>>>> Registering primitives...
>>>>
>>>> 326 primitives registered
>>>>
>>>> 7689 vertices registered
>>>>
>>>> Building areas...
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> 95 areas built
>>>>
>>>> 8 isles built
>>>>
>>>> Attaching islands...
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> Attaching centroids...
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> Number of nodes: 144
>>>>
>>>> Number of primitives: 326
>>>>
>>>> Number of points: 0
>>>>
>>>> Number of lines: 0
>>>>
>>>> Number of boundaries: 231
>>>>
>>>> Number of centroids: 95
>>>>
>>>> Number of areas: 95
>>>>
>>>> Number of isles: 8
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> execGRASS("v.clean", flags = c("overwrite"), input = "pol1",
>>>>>
>>>>
>>>> + output = "clnpol", tool = "rmarea", threshold = 3000)
>>>>
>>>> --------------------------------------------------
>>>>
>>>> Tool: Threshold
>>>>
>>>> Remove small areas: 3000
>>>>
>>>> --------------------------------------------------
>>>>
>>>> Copying features...
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> Rebuilding parts of topology...
>>>>
>>>> Building topology for vector map <***@filec24129b63ac>...
>>>>
>>>> Registering primitives...
>>>>
>>>> 326 primitives registered
>>>>
>>>> 7689 vertices registered
>>>>
>>>> Building areas...
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> 95 areas built
>>>>
>>>> 8 isles built
>>>>
>>>> Attaching islands...
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> Attaching centroids...
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> Number of nodes: 144
>>>>
>>>> Number of primitives: 326
>>>>
>>>> Number of points: 0
>>>>
>>>> Number of lines: 0
>>>>
>>>> Number of boundaries: 231
>>>>
>>>> Number of centroids: 95
>>>>
>>>> Number of areas: 95
>>>>
>>>> Number of isles: 8
>>>>
>>>> --------------------------------------------------
>>>>
>>>> Tool: Remove small areas
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> 55 areas of total size 29487.1 removed
>>>>
>>>> --------------------------------------------------
>>>>
>>>> Rebuilding topology for output vector map...
>>>>
>>>> Building topology for vector map <***@filec24129b63ac>...
>>>>
>>>> Registering primitives...
>>>>
>>>> 212 primitives registered
>>>>
>>>> 6840 vertices registered
>>>>
>>>> Building areas...
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> 40 areas built
>>>>
>>>> 4 isles built
>>>>
>>>> Attaching islands...
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> Attaching centroids...
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> Number of nodes: 136
>>>>
>>>> Number of primitives: 212
>>>>
>>>> Number of points: 0
>>>>
>>>> Number of lines: 0
>>>>
>>>> Number of boundaries: 172
>>>>
>>>> Number of centroids: 40
>>>>
>>>> Number of areas: 40
>>>>
>>>> Number of isles: 4
>>>>
>>>> cln.pol <- readVECT("clnpol")
>>>>>
>>>>
>>>> Error: !is.null(driver) is not TRUE
>>>>
>>>> cln.pol <- readVECT("clnpol", driver = "ESRI Shapefile")
>>>>>
>>>>
>>>> Error in scan(file, what, nmax, sep, dec, quote, skip, nlines,
>>>> na.strings, :
>>>>
>>>> line 4 did not have 2 elements
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> sessionInfo()
>>>>>
>>>>
>>>> R version 3.2.2 (2015-08-14)
>>>>
>>>> Platform: x86_64-w64-mingw32/x64 (64-bit)
>>>>
>>>> Running under: Windows 7 x64 (build 7601) Service Pack 1
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> locale:
>>>>
>>>> [1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United
>>>> States.1252 LC_MONETARY=English_United States.1252
>>>>
>>>> [4] LC_NUMERIC=C LC_TIME=English_United
>>>> States.1252
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> attached base packages:
>>>>
>>>> [1] stats graphics grDevices utils datasets methods base
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> other attached packages:
>>>>
>>>> [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
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> loaded via a namespace (and not attached):
>>>>
>>>> [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
>>>>
>>>> [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
>>>>
>>>> [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
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> _______________________________________________
>>>> grass-stats mailing list
>>>> grass-***@lists.osgeo.org
>>>> http://lists.osgeo.org/mailman/listinfo/grass-stats
>>>>
>>>>
>>>
>> --
>> Roger Bivand
>> Department of Economics, Norwegian School of Economics,
>> Helleveien 30, N-5045 Bergen, Norway.
>> voice: +47 55 95 93 55; fax +47 55 95 91 00
>> e-mail: ***@nhh.no
>>
>

--
Roger Bivand
Department of Economics, Norwegian School of Economics,
Helleveien 30, N-5045 Bergen, Norway.
voice: +47 55 95 93 55; fax +47 55 95 91 00
e-mail: ***@nhh.no
Eduardo Diez
2015-10-10 16:20:21 UTC
Permalink
This is what i got:

> vinfo0 <- execGRASS("v.info", flags="c", map=zm.gnrl)INTEGER|cat
INTEGER|ID
INTEGER|GRIDCODE
Displaying column types/names for database connection of layer <1>:


And trying to read back the original polygon (without v.clean):

> zm.fnl <- readVECT(zm.pol)Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings, :
line 4 did not have 2 elements





2015-10-10 13:12 GMT-03:00 Roger Bivand <***@nhh.no>:

> On Sat, 10 Oct 2015, Eduardo Diez wrote:
>
> Apparently "v.info" through execGRASS is expecting the "layer" argument to
>> be a string rather than an integer.
>>
>
> 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):
>
> vinfo0 <- execGRASS("v.info", flags="c", map=zm.gnrl)
>
> My guess is that v.info is saying that this map is broken, or suffering
> from something that vColumns does not know about.
>
> v.info -c map=
>
> 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).
>
> Does readVECT() work if you do not use v.clean? Is v.clean having a side
> effect of causing v.info -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?)?
>
> Roger
>
>
>>
>> zm.fnl <- readVECT(zm.gnrl)Error in scan(file, what, nmax, sep, dec,
>>> quote, skip, nlines, na.strings, :
>>>
>> line 4 did not have 2 elements> vinfo0 <- execGRASS("v.info",
>> flags="c", map=zm.gnrl, layer=1L,+ intern=TRUE)Error in doGRASS(cmd,
>> flags = flags, ..., parameters = parameters, echoCmd = echoCmd, :
>> Parameter <layer> does not have string value>
>> parseGRASS("v.info")Command: v.info
>>
>> Extension: .exe
>> Description: Outputs basic information about a vector map.
>> Keywords: vector, metadata, topology, extent, history, attribute columns
>> Parameters:
>> name: map, type: string, required: yes, multiple: no
>> keydesc: name, keydesc_count: 1
>> [Or data source for direct OGR access]
>> name: layer, type: string, required: no, multiple: no
>> default: 1
>> [Vector features can have category values in different layers. This
>> number determines which layer to use. When used with direct OGR access
>> this is the layer name.]
>> Flags:
>> name: h [Print history instead of info and exit] {FALSE}
>> name: c [Print types/names of table columns for specified layer
>> instead of info and exit] {FALSE}
>> name: g [Print region info in shell script style] {FALSE}
>> name: e [Print extended metadata info in shell script style] {FALSE}
>> name: t [Print topology info in shell script style] {FALSE}
>> name: help [Print usage summary] {FALSE}
>> name: verbose [Verbose module output] {FALSE}
>> name: quiet [Quiet module output] {FALSE}
>>
>>
>>
>>>
>> 2015-10-10 10:56 GMT-03:00 Roger Bivand <***@nhh.no>:
>>
>> OK, thanks. So the failure is in:
>>>
>>> vinfo0 <- execGRASS("v.info", flags="c", map="<name>", layer=1L,
>>> intern=TRUE)
>>>
>>> used to return the column/field names. Please repeat with that.
>>>
>>> Roger
>>>
>>>
>>> On Fri, 9 Oct 2015, Eduardo Diez wrote:
>>>
>>> Here are the traceback and the vInfo(zm.gnrl). The latter seems to work
>>>
>>>> fine.
>>>>
>>>> zm.fnl <- readVECT(zm.gnrl)
>>>>
>>>>>
>>>>> Error in scan(file, what, nmax, sep, dec, quote, skip, nlines,
>>>> na.strings,
>>>> :
>>>> line 4 did not have 2 elements
>>>>
>>>> traceback()
>>>>>
>>>>> 8: scan(file = file, what = what, sep = sep, quote = quote, dec = dec,
>>>> nmax = nrows, skip = 0, na.strings = na.strings, quiet = TRUE,
>>>> fill = fill, strip.white = strip.white, blank.lines.skip =
>>>> blank.lines.skip,
>>>> multi.line = FALSE, comment.char = comment.char, allowEscapes =
>>>> allowEscapes,
>>>> flush = flush, encoding = encoding, skipNul = skipNul)
>>>> 7: read.table(con, header = FALSE, sep = "|")
>>>> 6: vColumns(vname)
>>>> 5: nchar(as.character(vColumns(vname)$name))
>>>> 4: .read_vect_non_plugin(vname = vname, layer = layer, type = type,
>>>> remove.duplicates = remove.duplicates, ignore.stderr =
>>>> ignore.stderr,
>>>> pointDropZ = pointDropZ, driver = driver, with_prj = with_prj,
>>>> with_c = with_c)
>>>> 3: tryCatchList(expr, classes, parentenv, handlers)
>>>> 2: tryCatch({
>>>> stopifnot(is.logical(plugin) || is.null(plugin))
>>>> stopifnot(is.logical(ignore.stderr))
>>>> if (missing(layer))
>>>> layer <- 1L
>>>> layer <- as.character(layer)
>>>> stopifnot(is.logical(with_c))
>>>> if (!is.null(driver) && driver == "GRASS")
>>>> plugin <- TRUE
>>>> if (!requireNamespace("rgdal", quietly = TRUE)) {
>>>> stop("rgdal not available")
>>>> }
>>>> if (is.null(plugin)) {
>>>> ogrD <- rgdal::ogrDrivers()$name
>>>> plugin <- "GRASS" %in% ogrD
>>>> }
>>>> if (plugin) {
>>>> res <- .read_vect_plugin(vname = vname, layer = layer,
>>>> type = type, ignore.stderr = ignore.stderr, pointDropZ =
>>>> pointDropZ,
>>>> mapset = mapset)
>>>> }
>>>> else {
>>>> res <- .read_vect_non_plugin(vname = vname, layer = layer,
>>>> type = type, remove.duplicates = remove.duplicates,
>>>> ignore.stderr = ignore.stderr, pointDropZ = pointDropZ,
>>>> driver = driver, with_prj = with_prj, with_c = with_c)
>>>> }
>>>> }, finally = {
>>>> if (get.suppressEchoCmdInFuncOption()) {
>>>> tull <- set.echoCmdOption(inEchoCmd)
>>>> }
>>>> })
>>>> 1: readVECT(zm.gnrl)
>>>>
>>>> vInfo(zm.gnrl)
>>>>>
>>>>> nodes points lines boundaries centroids areas
>>>> islands primitives map3d
>>>> 274 0 0 302 31 31
>>>> 3 333 0
>>>>
>>>> Thanks
>>>>
>>>>
>>>> 2015-10-09 11:36 GMT-03:00 Roger Bivand <***@nhh.no>:
>>>>
>>>> If it is the v.info call, please run:
>>>>
>>>>>
>>>>> res <- execGRASS("v.info", flags="t", map="zm.gnrl", layer=1L,
>>>>> intern=TRUE)
>>>>>
>>>>> and report the output of:
>>>>>
>>>>> print(res)
>>>>>
>>>>> and maybe send me offlist the output of
>>>>>
>>>>> save(res, file="vinfo_odd_output.RData")
>>>>>
>>>>> Roger
>>>>>
>>>>> --
>>>>> Roger Bivand
>>>>> Norwegian School of Economics
>>>>> Helleveien 30, 5045 Bergen, Norway
>>>>> ***@nhh.no
>>>>>
>>>>>
>>>>> ________________________________________
>>>>> Fra: grass-stats [grass-stats-***@lists.osgeo.org] p&#229; vegne
>>>>> av
>>>>> Roger Bivand [***@nhh.no]
>>>>> Sendt: 9. oktober 2015 4:27
>>>>> Til: Eduardo Diez
>>>>> Kopi: grass-***@lists.osgeo.org
>>>>> Emne: Re: [GRASS-stats] rgrass7 read/write SpatialPolygonsDataFrames
>>>>> errors
>>>>>
>>>>> OK, please provide the output of traceback() run immediately after the
>>>>> failing readVECT(). That will show which command invokes scan(). Also
>>>>> try
>>>>> to run vInfo(zm.gnrl) - I think the failure is in:
>>>>>
>>>>> execGRASS("v.info", flags="t", map="zm.gnrl", layer=1L)
>>>>>
>>>>> not returning a structure that vInfo understands, and which ois then
>>>>> used
>>>>> in readVECT().
>>>>>
>>>>> Roger
>>>>>
>>>>> --
>>>>> Roger Bivand
>>>>> Norwegian School of Economics
>>>>> Helleveien 30, 5045 Bergen, Norway
>>>>> ***@nhh.no
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> Fra: ***@gmail.com [***@gmail.com] på vegne av Eduardo Diez
>>>>> [
>>>>> ***@gmx.com]
>>>>>
>>>>> Sendt: 9. oktober 2015 4:04
>>>>>
>>>>> Til: Roger Bivand
>>>>>
>>>>> Kopi: grass-***@lists.osgeo.org
>>>>>
>>>>> Emne: Re: [GRASS-stats] rgrass7 read/write SpatialPolygonsDataFrames
>>>>> errors
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> Roger, with GRASS version 7.0.1 and rgrass7_0.1-3, readVECT now doesn't
>>>>> ask for the driver to use but gives the same error as before:
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> writeVECT(SDF = mz.pol, vname = zm.pol, v.in.ogr_flags = "o")
>>>>> Over-riding projection check
>>>>> Check if OGR layer <q7468fb> contains polygons...
>>>>>
>>>>>
>>>>>
>>>>> Importing 205 features (OGR layer <q7468fb>)...
>>>>>
>>>>>
>>>>>
>>>>> -----------------------------------------------------
>>>>> Registering primitives...
>>>>> 3924 primitives registered
>>>>> 12866 vertices registered
>>>>> Number of nodes: 2884
>>>>> Number of primitives: 3924
>>>>> Number of points: 0
>>>>> Number of lines: 0
>>>>> Number of boundaries: 3924
>>>>> Number of centroids: 0
>>>>> Number of areas: -
>>>>> Number of isles: -
>>>>> -----------------------------------------------------
>>>>> Cleaning polygons
>>>>> -----------------------------------------------------
>>>>> Breaking polygons...
>>>>> Breaking polygons (pass 1: select break points)...
>>>>>
>>>>>
>>>>>
>>>>> Breaking polygons (pass 2: break at selected points)...
>>>>>
>>>>>
>>>>>
>>>>> -----------------------------------------------------
>>>>> Removing duplicates...
>>>>>
>>>>>
>>>>>
>>>>> -----------------------------------------------------
>>>>> Breaking boundaries...
>>>>>
>>>>>
>>>>>
>>>>> -----------------------------------------------------
>>>>> Removing duplicates...
>>>>>
>>>>>
>>>>>
>>>>> -----------------------------------------------------
>>>>> Cleaning boundaries at nodes...
>>>>>
>>>>>
>>>>>
>>>>> -----------------------------------------------------
>>>>> Merging boundaries...
>>>>>
>>>>>
>>>>>
>>>>> -----------------------------------------------------
>>>>> Removing dangles...
>>>>>
>>>>>
>>>>>
>>>>> -----------------------------------------------------
>>>>> Building areas...
>>>>>
>>>>>
>>>>>
>>>>> 205 areas built
>>>>> 13 isles built
>>>>> Number of nodes: 2929
>>>>> Number of primitives: 7268
>>>>> Number of points: 0
>>>>> Number of lines: 0
>>>>> Number of boundaries: 7268
>>>>> Number of centroids: 0
>>>>> Number of areas: 205
>>>>> Number of isles: 13
>>>>> -----------------------------------------------------
>>>>> Removing bridges...
>>>>>
>>>>>
>>>>>
>>>>> -----------------------------------------------------
>>>>> Registering primitives...
>>>>> 498 primitives registered
>>>>> 5828 vertices registered
>>>>> Building areas...
>>>>>
>>>>>
>>>>>
>>>>> 205 areas built
>>>>> 13 isles built
>>>>> Attaching islands...
>>>>>
>>>>>
>>>>>
>>>>> Number of nodes: 306
>>>>> Number of primitives: 498
>>>>> Number of points: 0
>>>>> Number of lines: 0
>>>>> Number of boundaries: 498
>>>>> Number of centroids: 0
>>>>> Number of areas: 205
>>>>> Number of isles: 13
>>>>> -----------------------------------------------------
>>>>> Finding centroids for OGR layer <q7468fb>...
>>>>>
>>>>>
>>>>>
>>>>> -----------------------------------------------------
>>>>> Writing centroids...
>>>>>
>>>>>
>>>>>
>>>>> -----------------------------------------------------
>>>>> 205 input polygons
>>>>> Total area: 1.25187E+006 (205 areas)
>>>>> -----------------------------------------------------
>>>>> Copying features...
>>>>>
>>>>>
>>>>>
>>>>> WARNING: Unable to delete file
>>>>>
>>>>>
>>>>>
>>>>> 'C:/Users/ediez1/AppData/Local/Temp/Rtmpqkeay4/file480c1e5e16a7/file480c11cc233b/.tmp/unknown/vector/tmp_8308/coor'
>>>>> Building topology for vector map <***@file480c11cc233b>...
>>>>> Registering primitives...
>>>>> 703 primitives registered
>>>>> 6033 vertices registered
>>>>> Building areas...
>>>>>
>>>>>
>>>>>
>>>>> 205 areas built
>>>>> 13 isles built
>>>>> Attaching islands...
>>>>>
>>>>>
>>>>>
>>>>> Attaching centroids...
>>>>>
>>>>>
>>>>>
>>>>> Number of nodes: 306
>>>>> Number of primitives: 703
>>>>> Number of points: 0
>>>>> Number of lines: 0
>>>>> Number of boundaries: 498
>>>>> Number of centroids: 205
>>>>> Number of areas: 205
>>>>> Number of isles: 13
>>>>>
>>>>> execGRASS("v.clean", flags = c("overwrite"), input = zm.pol,
>>>>>>
>>>>>> + output = zm.gnrl, tool = "rmarea", threshold = 3000)
>>>>> --------------------------------------------------
>>>>> Tool: Threshold
>>>>> Remove small areas: 3000
>>>>> --------------------------------------------------
>>>>> Copying features...
>>>>>
>>>>>
>>>>>
>>>>> Rebuilding parts of topology...
>>>>> Building topology for vector map <***@file480c11cc233b>...
>>>>> Registering primitives...
>>>>> 703 primitives registered
>>>>> 6033 vertices registered
>>>>> Building areas...
>>>>>
>>>>>
>>>>>
>>>>> 205 areas built
>>>>> 13 isles built
>>>>> Attaching islands...
>>>>>
>>>>>
>>>>>
>>>>> Attaching centroids...
>>>>>
>>>>>
>>>>>
>>>>> Number of nodes: 306
>>>>> Number of primitives: 703
>>>>> Number of points: 0
>>>>> Number of lines: 0
>>>>> Number of boundaries: 498
>>>>> Number of centroids: 205
>>>>> Number of areas: 205
>>>>> Number of isles: 13
>>>>> --------------------------------------------------
>>>>> Tool: Remove small areas
>>>>>
>>>>>
>>>>>
>>>>> 174 areas of total size 50601.7 removed
>>>>> --------------------------------------------------
>>>>> Rebuilding topology for output vector map...
>>>>> Building topology for vector map <***@file480c11cc233b>...
>>>>> Registering primitives...
>>>>> 333 primitives registered
>>>>> 4705 vertices registered
>>>>> Building areas...
>>>>>
>>>>>
>>>>>
>>>>> 31 areas built
>>>>> 3 isles built
>>>>> Attaching islands...
>>>>>
>>>>>
>>>>>
>>>>> Attaching centroids...
>>>>>
>>>>>
>>>>>
>>>>> Number of nodes: 274
>>>>> Number of primitives: 333
>>>>> Number of points: 0
>>>>> Number of lines: 0
>>>>> Number of boundaries: 302
>>>>> Number of centroids: 31
>>>>> Number of areas: 31
>>>>> Number of isles: 3
>>>>>
>>>>> zm.fnl <- readVECT(zm.gnrl)
>>>>>>
>>>>>>
>>>>>
>>>>> Error in scan(file, what, nmax, sep, dec, quote, skip, nlines,
>>>>> na.strings, :
>>>>> line 4 did not have 2 elements
>>>>>
>>>>> sessionInfo()
>>>>>>
>>>>>> R version 3.2.2 (2015-08-14)
>>>>> Platform: x86_64-w64-mingw32/x64 (64-bit)
>>>>> Running under: Windows 7 x64 (build 7601) Service Pack 1
>>>>>
>>>>>
>>>>>
>>>>> locale:
>>>>> [1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United
>>>>> States.1252 LC_MONETARY=English_United States.1252
>>>>> [4] LC_NUMERIC=C LC_TIME=English_United
>>>>> States.1252
>>>>>
>>>>>
>>>>>
>>>>> attached base packages:
>>>>> [1] stats graphics grDevices utils datasets methods base
>>>>>
>>>>>
>>>>>
>>>>> other attached packages:
>>>>> [1] RPyGeo_0.9-3 RSAGA_0.94-3 plyr_1.8.3 gstat_1.0-26
>>>>> shapefiles_0.7 foreign_0.8-65 maptools_0.8-37 rgdal_1.0-7
>>>>> classInt_0.1-23
>>>>> [10] raster_2.4-20 rgrass7_0.1-3 XML_3.98-1.3 sp_1.2-0
>>>>>
>>>>>
>>>>>
>>>>> loaded via a namespace (and not attached):
>>>>> [1] Rcpp_0.12.1 intervals_0.15.1 lattice_0.20-33 FNN_1.1
>>>>> spacetime_1.1-4 class_7.3-13 zoo_1.7-12 grid_3.2.2
>>>>> [9] e1071_1.6-7 xts_0.9-7 tools_3.2.2
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> Thanks
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> 2015-10-08 18:57 GMT-03:00 Roger Bivand
>>>>> <***@nhh.no>:
>>>>>
>>>>>
>>>>> Sorry this has taken a long time; please try installing the development
>>>>> version available from:
>>>>>
>>>>>
>>>>>
>>>>> http://win-builder.r-project.org/8Y3Ihj451Clx
>>>>>
>>>>>
>>>>>
>>>>> (rgrass7_0.1-3.zip). The problem was the use of "_" instead of " " in
>>>>> the
>>>>> name of the OGR shapefile driver - in OGR and R it is "ESRI Shapefile",
>>>>> in
>>>>> GRASS it is "ESRI_Shapefile". Because the new long-name work-around
>>>>> worked
>>>>> on systems not needing to use this
>>>>> driver, it wasn't properly tested - and on Windows the GRASS
>>>>> standalone
>>>>> has OGR with the SQLite driver, but the Windows rgdal binary does not
>>>>> have
>>>>> SQLite. You may wish to install the R RSQLite package to move data if
>>>>> you
>>>>> use long field/column names.
>>>>>
>>>>>
>>>>>
>>>>> Before installing this development version, and after library(rgrass7),
>>>>> run example(readVECT) in the basic nc location from:
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> https://grass.osgeo.org/sampledata/north_carolina/nc_basic_spm_grass7.zip
>>>>>
>>>>>
>>>>>
>>>>> it should fail. Then restart R, install the development version of
>>>>> rgrass7
>>>>> from the first link, and repeat - it works for me and should resolve
>>>>> the
>>>>> problem.
>>>>>
>>>>>
>>>>>
>>>>> Hope this helps,
>>>>>
>>>>>
>>>>>
>>>>> Roger
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>>
>>>>> Roger Bivand
>>>>>
>>>>> Norwegian School of Economics
>>>>>
>>>>> Helleveien 30, 5045 Bergen, Norway
>>>>>
>>>>> ***@nhh.no
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> Fra:
>>>>> grass-stats-***@lists.osgeo.org [
>>>>> grass-stats-***@lists.osgeo.org
>>>>> ]
>>>>> på vegne av Eduardo Diez [***@gmx.com]
>>>>>
>>>>> Sendt: 24. september 2015 9:11
>>>>>
>>>>> Til:
>>>>> grass-***@lists.osgeo.org
>>>>>
>>>>> Emne: [GRASS-stats] rgrass7 read/write SpatialPolygonsDataFrames errors
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> 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.
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> 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).
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> 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.
>>>>>
>>>>> Below i paste an extract of my R console with the errors and some
>>>>> information.
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> Thanks in advance,
>>>>>
>>>>>
>>>>>
>>>>> Eduardo
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> mult.rp <- projectRaster(mult.r, crs = prj.crs, method = "ngb")
>>>>>
>>>>>>
>>>>>>
>>>>> mult.pol <- rasterToPolygons(mult.rp, dissolve = T)
>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>> initGRASS(gisBase = "c:/Program Files (x86)/GRASS GIS 7.0.1", home =
>>>>>
>>>>>>
>>>>>> tempdir(), override = T)
>>>>>
>>>>> gisdbase C:/Users/ediez1/AppData/Local/Temp/RtmpegbyiQ
>>>>>
>>>>> location file2f7c6dc070e6
>>>>>
>>>>> mapset file2f7c30eb3f52
>>>>>
>>>>> rows 1
>>>>>
>>>>> columns 1
>>>>>
>>>>> north 1
>>>>>
>>>>> south 0
>>>>>
>>>>> west 0
>>>>>
>>>>> east 1
>>>>>
>>>>> nsres 1
>>>>>
>>>>> ewres 1
>>>>>
>>>>> projection NA
>>>>>
>>>>> writeVECT(mult.pol, "pol1", v.in.ogr_flags = "o")
>>>>>
>>>>>>
>>>>>>
>>>>> Error: !is.null(driver) is not TRUE
>>>>>
>>>>> writeVECT(mult.pol, "pol1", v.in.ogr_flags = "o", driver = "ESRI
>>>>>
>>>>>>
>>>>>> Shapefile")
>>>>>
>>>>>
>>>>>
>>>>> Over-riding projection check
>>>>>
>>>>> Check if OGR layer <r848659> contains polygons...
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> Importing 4 features (OGR layer <r848659>)...
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> -----------------------------------------------------
>>>>>
>>>>> Registering primitives...
>>>>>
>>>>> 3005 primitives registered
>>>>>
>>>>> 15587 vertices registered
>>>>>
>>>>> Number of nodes: 2691
>>>>>
>>>>> Number of primitives: 3005
>>>>>
>>>>> Number of points: 0
>>>>>
>>>>> Number of lines: 0
>>>>>
>>>>> Number of boundaries: 3005
>>>>>
>>>>> Number of centroids: 0
>>>>>
>>>>> Number of areas: -
>>>>>
>>>>> Number of isles: -
>>>>>
>>>>> -----------------------------------------------------
>>>>>
>>>>> Cleaning polygons
>>>>>
>>>>> -----------------------------------------------------
>>>>>
>>>>> Breaking polygons...
>>>>>
>>>>> Breaking polygons (pass 1: select break points)...
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> Breaking polygons (pass 2: break at selected points)...
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> -----------------------------------------------------
>>>>>
>>>>> Removing duplicates...
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> -----------------------------------------------------
>>>>>
>>>>> Breaking boundaries...
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> -----------------------------------------------------
>>>>>
>>>>> Removing duplicates...
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> -----------------------------------------------------
>>>>>
>>>>> Cleaning boundaries at nodes...
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> -----------------------------------------------------
>>>>>
>>>>> Merging boundaries...
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> -----------------------------------------------------
>>>>>
>>>>> Removing dangles...
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> -----------------------------------------------------
>>>>>
>>>>> Building areas...
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> 95 areas built
>>>>>
>>>>> 8 isles built
>>>>>
>>>>> Number of nodes: 2771
>>>>>
>>>>> Number of primitives: 7307
>>>>>
>>>>> Number of points: 0
>>>>>
>>>>> Number of lines: 0
>>>>>
>>>>> Number of boundaries: 7307
>>>>>
>>>>> Number of centroids: 0
>>>>>
>>>>> Number of areas: 95
>>>>>
>>>>> Number of isles: 8
>>>>>
>>>>> -----------------------------------------------------
>>>>>
>>>>> Removing bridges...
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> -----------------------------------------------------
>>>>>
>>>>> Registering primitives...
>>>>>
>>>>> 231 primitives registered
>>>>>
>>>>> 7594 vertices registered
>>>>>
>>>>> Building areas...
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> 95 areas built
>>>>>
>>>>> 8 isles built
>>>>>
>>>>> Attaching islands...
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> Number of nodes: 144
>>>>>
>>>>> Number of primitives: 231
>>>>>
>>>>> Number of points: 0
>>>>>
>>>>> Number of lines: 0
>>>>>
>>>>> Number of boundaries: 231
>>>>>
>>>>> Number of centroids: 0
>>>>>
>>>>> Number of areas: 95
>>>>>
>>>>> Number of isles: 8
>>>>>
>>>>> -----------------------------------------------------
>>>>>
>>>>> Finding centroids for OGR layer <r848659>...
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> -----------------------------------------------------
>>>>>
>>>>> Writing centroids...
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> -----------------------------------------------------
>>>>>
>>>>> 95 input polygons
>>>>>
>>>>> Total area: 1.28981E+006 (95 areas)
>>>>>
>>>>> -----------------------------------------------------
>>>>>
>>>>> Copying features...
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> WARNING: Unable to delete file
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> 'C:/Users/ediez1/AppData/Local/Temp/Rtmpg10lvi/filec2473b0126/filec24129b63ac/.tmp/unknown/vector/tmp_10484/coor'
>>>>>
>>>>> Building topology for vector map <***@filec24129b63ac>...
>>>>>
>>>>> Registering primitives...
>>>>>
>>>>> 326 primitives registered
>>>>>
>>>>> 7689 vertices registered
>>>>>
>>>>> Building areas...
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> 95 areas built
>>>>>
>>>>> 8 isles built
>>>>>
>>>>> Attaching islands...
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> Attaching centroids...
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> Number of nodes: 144
>>>>>
>>>>> Number of primitives: 326
>>>>>
>>>>> Number of points: 0
>>>>>
>>>>> Number of lines: 0
>>>>>
>>>>> Number of boundaries: 231
>>>>>
>>>>> Number of centroids: 95
>>>>>
>>>>> Number of areas: 95
>>>>>
>>>>> Number of isles: 8
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> execGRASS("v.clean", flags = c("overwrite"), input = "pol1",
>>>>>
>>>>>>
>>>>>>
>>>>> + output = "clnpol", tool = "rmarea", threshold = 3000)
>>>>>
>>>>> --------------------------------------------------
>>>>>
>>>>> Tool: Threshold
>>>>>
>>>>> Remove small areas: 3000
>>>>>
>>>>> --------------------------------------------------
>>>>>
>>>>> Copying features...
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> Rebuilding parts of topology...
>>>>>
>>>>> Building topology for vector map <***@filec24129b63ac>...
>>>>>
>>>>> Registering primitives...
>>>>>
>>>>> 326 primitives registered
>>>>>
>>>>> 7689 vertices registered
>>>>>
>>>>> Building areas...
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> 95 areas built
>>>>>
>>>>> 8 isles built
>>>>>
>>>>> Attaching islands...
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> Attaching centroids...
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> Number of nodes: 144
>>>>>
>>>>> Number of primitives: 326
>>>>>
>>>>> Number of points: 0
>>>>>
>>>>> Number of lines: 0
>>>>>
>>>>> Number of boundaries: 231
>>>>>
>>>>> Number of centroids: 95
>>>>>
>>>>> Number of areas: 95
>>>>>
>>>>> Number of isles: 8
>>>>>
>>>>> --------------------------------------------------
>>>>>
>>>>> Tool: Remove small areas
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> 55 areas of total size 29487.1 removed
>>>>>
>>>>> --------------------------------------------------
>>>>>
>>>>> Rebuilding topology for output vector map...
>>>>>
>>>>> Building topology for vector map <***@filec24129b63ac>...
>>>>>
>>>>> Registering primitives...
>>>>>
>>>>> 212 primitives registered
>>>>>
>>>>> 6840 vertices registered
>>>>>
>>>>> Building areas...
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> 40 areas built
>>>>>
>>>>> 4 isles built
>>>>>
>>>>> Attaching islands...
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> Attaching centroids...
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> Number of nodes: 136
>>>>>
>>>>> Number of primitives: 212
>>>>>
>>>>> Number of points: 0
>>>>>
>>>>> Number of lines: 0
>>>>>
>>>>> Number of boundaries: 172
>>>>>
>>>>> Number of centroids: 40
>>>>>
>>>>> Number of areas: 40
>>>>>
>>>>> Number of isles: 4
>>>>>
>>>>> cln.pol <- readVECT("clnpol")
>>>>>
>>>>>>
>>>>>>
>>>>> Error: !is.null(driver) is not TRUE
>>>>>
>>>>> cln.pol <- readVECT("clnpol", driver = "ESRI Shapefile")
>>>>>
>>>>>>
>>>>>>
>>>>> Error in scan(file, what, nmax, sep, dec, quote, skip, nlines,
>>>>> na.strings, :
>>>>>
>>>>> line 4 did not have 2 elements
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> sessionInfo()
>>>>>
>>>>>>
>>>>>>
>>>>> R version 3.2.2 (2015-08-14)
>>>>>
>>>>> Platform: x86_64-w64-mingw32/x64 (64-bit)
>>>>>
>>>>> Running under: Windows 7 x64 (build 7601) Service Pack 1
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> locale:
>>>>>
>>>>> [1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United
>>>>> States.1252 LC_MONETARY=English_United States.1252
>>>>>
>>>>> [4] LC_NUMERIC=C LC_TIME=English_United
>>>>> States.1252
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> attached base packages:
>>>>>
>>>>> [1] stats graphics grDevices utils datasets methods base
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> other attached packages:
>>>>>
>>>>> [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
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> loaded via a namespace (and not attached):
>>>>>
>>>>> [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
>>>>>
>>>>> [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
>>>>>
>>>>> [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
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> _______________________________________________
>>>>> grass-stats mailing list
>>>>> grass-***@lists.osgeo.org
>>>>> http://lists.osgeo.org/mailman/listinfo/grass-stats
>>>>>
>>>>>
>>>>>
>>>> --
>>> Roger Bivand
>>> Department of Economics, Norwegian School of Economics,
>>> Helleveien 30, N-5045 Bergen, Norway.
>>> voice: +47 55 95 93 55; fax +47 55 95 91 00
>>> e-mail: ***@nhh.no
>>>
>>>
>>
> --
> Roger Bivand
> Department of Economics, Norwegian School of Economics,
> Helleveien 30, N-5045 Bergen, Norway.
> voice: +47 55 95 93 55; fax +47 55 95 91 00
> e-mail: ***@nhh.no
>
Roger Bivand
2015-10-10 16:57:35 UTC
Permalink
On Sat, 10 Oct 2015, Eduardo Diez wrote:

> This is what i got:
>
>> vinfo0 <- execGRASS("v.info", flags="c", map=zm.gnrl)INTEGER|cat
> INTEGER|ID
> INTEGER|GRIDCODE
> Displaying column types/names for database connection of layer <1>:
>
>
> And trying to read back the original polygon (without v.clean):
>
>> zm.fnl <- readVECT(zm.pol)Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings, :
> line 4 did not have 2 elements
>

This is coming from:

G_message(_("Displaying column types/names for database connection of
layer <%s>:"), field_opt);

line 134 in vector/v.info/print.c.

For me in nc_basic, for schools, I do not see the message with:

vinfo0 <- execGRASS("v.info", flags="c", map="schools", layer="1",
intern=TRUE)

which is what is being used in vColumns. Is there an alternative to v.info
that may be less error-prone?

Roger

>
>
>
>
> 2015-10-10 13:12 GMT-03:00 Roger Bivand <***@nhh.no>:
>
>> On Sat, 10 Oct 2015, Eduardo Diez wrote:
>>
>> Apparently "v.info" through execGRASS is expecting the "layer" argument to
>>> be a string rather than an integer.
>>>
>>
>> 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):
>>
>> vinfo0 <- execGRASS("v.info", flags="c", map=zm.gnrl)
>>
>> My guess is that v.info is saying that this map is broken, or suffering
>> from something that vColumns does not know about.
>>
>> v.info -c map=
>>
>> 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).
>>
>> Does readVECT() work if you do not use v.clean? Is v.clean having a side
>> effect of causing v.info -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?)?
>>
>> Roger
>>
>>
>

--
Roger Bivand
Department of Economics, Norwegian School of Economics,
Helleveien 30, N-5045 Bergen, Norway.
voice: +47 55 95 93 55; fax +47 55 95 91 00
e-mail: ***@nhh.no
Roger Bivand
2015-10-11 14:28:35 UTC
Permalink
On Sat, 10 Oct 2015, Roger Bivand wrote:

> On Sat, 10 Oct 2015, Eduardo Diez wrote:
>
>> This is what i got:
>>
>>> vinfo0 <- execGRASS("v.info", flags="c", map=zm.gnrl)INTEGER|cat
>> INTEGER|ID
>> INTEGER|GRIDCODE
>> Displaying column types/names for database connection of layer <1>:
>>
>>
>> And trying to read back the original polygon (without v.clean):
>>
>>> zm.fnl <- readVECT(zm.pol)Error in scan(file, what, nmax, sep, dec, quote,
> skip, nlines, na.strings, :
>> line 4 did not have 2 elements
>>
>
> This is coming from:
>
> G_message(_("Displaying column types/names for database connection of
> layer <%s>:"), field_opt);
>
> line 134 in vector/v.info/print.c.
>
> For me in nc_basic, for schools, I do not see the message with:
>
> vinfo0 <- execGRASS("v.info", flags="c", map="schools", layer="1",
> intern=TRUE)
>
> which is what is being used in vColumns. Is there an alternative to v.info
> that may be less error-prone?

The development Windows binary of rgrass7 at:

http://win-builder.r-project.org/9YK08bQi1ldt

is an attempt to address a problem I cannot reproduce (with GRASS 7.0.1
Windows standalone) - instead of assuming two-column output, it drops
lines with != 2 columns and issues a warning if they were found.

There is a further weakness in the readVECT code involving a conditional
assumption that the db driver is sqlite - is there any way to check from
outside which driver is being used?

Roger

>
> Roger
>
>>
>>
>>
>>
>> 2015-10-10 13:12 GMT-03:00 Roger Bivand <***@nhh.no>:
>>
>>> On Sat, 10 Oct 2015, Eduardo Diez wrote:
>>>
>>> Apparently "v.info" through execGRASS is expecting the "layer" argument to
>>>> be a string rather than an integer.
>>>>
>>>
>>> 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):
>>>
>>> vinfo0 <- execGRASS("v.info", flags="c", map=zm.gnrl)
>>>
>>> My guess is that v.info is saying that this map is broken, or suffering
>>> from something that vColumns does not know about.
>>>
>>> v.info -c map=
>>>
>>> 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).
>>>
>>> Does readVECT() work if you do not use v.clean? Is v.clean having a side
>>> effect of causing v.info -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?)?
>>>
>>> Roger
>>>
>>>
>>
>
>

--
Roger Bivand
Department of Economics, Norwegian School of Economics,
Helleveien 30, N-5045 Bergen, Norway.
voice: +47 55 95 93 55; fax +47 55 95 91 00
e-mail: ***@nhh.no
Markus Neteler
2015-10-11 16:23:34 UTC
Permalink
On Sun, Oct 11, 2015 at 4:28 PM, Roger Bivand <***@nhh.no> wrote:
...
> There is a further weakness in the readVECT code involving a conditional
> assumption that the db driver is sqlite - is there any way to check from
> outside which driver is being used?

db.connect - Prints/sets general DB connection for current mapset.

It reads/stores the information in the file
<location>/<mapset>/VAR
which is a parsable ASCII file, using the variables
DB_DRIVER
DB_DATABASE

Best
Markus
Eduardo Diez
2015-10-11 16:41:26 UTC
Permalink
With today's development version it works with the warning you mentioned.

> zm.fnl <- readVECT(zm.gnrl)Exporting 29 areas (may take some time)...

VOUTOG~1 complete. 29 features (Polygon type) written to <dc2ad04>
(ESRI_Shapefile format).
OGR data source with driver: ESRI Shapefile
Source: "C:/Users/ediez1/AppData/Local/Temp/RtmpW8PKp3/file2b88c7f0f107d/file2b88c71f92564/.tmp/unknown",
layer: "dc2ad04"
with 29 features
It has 3 fieldsWarning message:In vColumns(vname) : vColumns: v.info
-c output not all in two columns


Thanks a lot for all the time invested in developing and mantaining these
wonderful tools everyone can use.

A side question: is there a way of performing the same thing i'm trying to
do from GRASS (i.e. removing specific sized polygons by including them into
larger ones) from plain R without needing to call external functions?

Thanks again
Eduardo


2015-10-11 11:28 GMT-03:00 Roger Bivand <***@nhh.no>:

> On Sat, 10 Oct 2015, Roger Bivand wrote:
>
> On Sat, 10 Oct 2015, Eduardo Diez wrote:
>>
>> This is what i got:
>>>
>>> vinfo0 <- execGRASS("v.info", flags="c", map=zm.gnrl)INTEGER|cat
>>>>
>>> INTEGER|ID
>>> INTEGER|GRIDCODE
>>> Displaying column types/names for database connection of layer <1>:
>>>
>>>
>>> And trying to read back the original polygon (without v.clean):
>>>
>>> zm.fnl <- readVECT(zm.pol)Error in scan(file, what, nmax, sep, dec,
>>>> quote,
>>>>
>>> skip, nlines, na.strings, :
>>
>>> line 4 did not have 2 elements
>>>
>>>
>> This is coming from:
>>
>> G_message(_("Displaying column types/names for database connection of
>> layer <%s>:"), field_opt);
>>
>> line 134 in vector/v.info/print.c.
>>
>> For me in nc_basic, for schools, I do not see the message with:
>>
>> vinfo0 <- execGRASS("v.info", flags="c", map="schools", layer="1",
>> intern=TRUE)
>>
>> which is what is being used in vColumns. Is there an alternative to
>> v.info that may be less error-prone?
>>
>
> The development Windows binary of rgrass7 at:
>
> http://win-builder.r-project.org/9YK08bQi1ldt
>
> is an attempt to address a problem I cannot reproduce (with GRASS 7.0.1
> Windows standalone) - instead of assuming two-column output, it drops lines
> with != 2 columns and issues a warning if they were found.
>
> There is a further weakness in the readVECT code involving a conditional
> assumption that the db driver is sqlite - is there any way to check from
> outside which driver is being used?
>
> Roger
>
>
>
>> Roger
>>
>>
>>>
>>>
>>>
>>> 2015-10-10 13:12 GMT-03:00 Roger Bivand <***@nhh.no>:
>>>
>>> On Sat, 10 Oct 2015, Eduardo Diez wrote:
>>>>
>>>> Apparently "v.info" through execGRASS is expecting the "layer"
>>>> argument to
>>>>
>>>>> be a string rather than an integer.
>>>>>
>>>>>
>>>> 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):
>>>>
>>>> vinfo0 <- execGRASS("v.info", flags="c", map=zm.gnrl)
>>>>
>>>> My guess is that v.info is saying that this map is broken, or suffering
>>>> from something that vColumns does not know about.
>>>>
>>>> v.info -c map=
>>>>
>>>> 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).
>>>>
>>>> Does readVECT() work if you do not use v.clean? Is v.clean having a side
>>>> effect of causing v.info -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?)?
>>>>
>>>> Roger
>>>>
>>>>
>>>>
>>>
>>
>>
> --
> Roger Bivand
> Department of Economics, Norwegian School of Economics,
> Helleveien 30, N-5045 Bergen, Norway.
> voice: +47 55 95 93 55; fax +47 55 95 91 00
> e-mail: ***@nhh.no
>
>
Roger Bivand
2015-10-11 19:49:03 UTC
Permalink
On Sun, 11 Oct 2015, Eduardo Diez wrote:

> With today's development version it works with the warning you mentioned.
>
>> zm.fnl <- readVECT(zm.gnrl)Exporting 29 areas (may take some time)...
>
> VOUTOG~1 complete. 29 features (Polygon type) written to <dc2ad04>
> (ESRI_Shapefile format).
> OGR data source with driver: ESRI Shapefile
> Source: "C:/Users/ediez1/AppData/Local/Temp/RtmpW8PKp3/file2b88c7f0f107d/file2b88c71f92564/.tmp/unknown",
> layer: "dc2ad04"
> with 29 features
> It has 3 fieldsWarning message:In vColumns(vname) : vColumns: v.info
> -c output not all in two columns

Please try:

http://win-builder.r-project.org/miws6tzuLCCJ

for a new version that should report the !=2 columns lines, and
accommodates a safety fix to use Markus' suggestion to retrieve the db
type, and drop the fix for long file names if the GRASS db driver is nor
sqlite.

Roger

>
>
> Thanks a lot for all the time invested in developing and mantaining these
> wonderful tools everyone can use.
>
> A side question: is there a way of performing the same thing i'm trying to
> do from GRASS (i.e. removing specific sized polygons by including them into
> larger ones) from plain R without needing to call external functions?
>
> Thanks again
> Eduardo
>
>
> 2015-10-11 11:28 GMT-03:00 Roger Bivand <***@nhh.no>:
>
>> On Sat, 10 Oct 2015, Roger Bivand wrote:
>>
>> On Sat, 10 Oct 2015, Eduardo Diez wrote:
>>>
>>> This is what i got:
>>>>
>>>> vinfo0 <- execGRASS("v.info", flags="c", map=zm.gnrl)INTEGER|cat
>>>>>
>>>> INTEGER|ID
>>>> INTEGER|GRIDCODE
>>>> Displaying column types/names for database connection of layer <1>:
>>>>
>>>>
>>>> And trying to read back the original polygon (without v.clean):
>>>>
>>>> zm.fnl <- readVECT(zm.pol)Error in scan(file, what, nmax, sep, dec,
>>>>> quote,
>>>>>
>>>> skip, nlines, na.strings, :
>>>
>>>> line 4 did not have 2 elements
>>>>
>>>>
>>> This is coming from:
>>>
>>> G_message(_("Displaying column types/names for database connection of
>>> layer <%s>:"), field_opt);
>>>
>>> line 134 in vector/v.info/print.c.
>>>
>>> For me in nc_basic, for schools, I do not see the message with:
>>>
>>> vinfo0 <- execGRASS("v.info", flags="c", map="schools", layer="1",
>>> intern=TRUE)
>>>
>>> which is what is being used in vColumns. Is there an alternative to
>>> v.info that may be less error-prone?
>>>
>>
>> The development Windows binary of rgrass7 at:
>>
>> http://win-builder.r-project.org/9YK08bQi1ldt
>>
>> is an attempt to address a problem I cannot reproduce (with GRASS 7.0.1
>> Windows standalone) - instead of assuming two-column output, it drops lines
>> with != 2 columns and issues a warning if they were found.
>>
>> There is a further weakness in the readVECT code involving a conditional
>> assumption that the db driver is sqlite - is there any way to check from
>> outside which driver is being used?
>>
>> Roger
>>
>>
>>
>>> Roger
>>>
>>>
>>>>
>>>>
>>>>
>>>> 2015-10-10 13:12 GMT-03:00 Roger Bivand <***@nhh.no>:
>>>>
>>>> On Sat, 10 Oct 2015, Eduardo Diez wrote:
>>>>>
>>>>> Apparently "v.info" through execGRASS is expecting the "layer"
>>>>> argument to
>>>>>
>>>>>> be a string rather than an integer.
>>>>>>
>>>>>>
>>>>> 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):
>>>>>
>>>>> vinfo0 <- execGRASS("v.info", flags="c", map=zm.gnrl)
>>>>>
>>>>> My guess is that v.info is saying that this map is broken, or suffering
>>>>> from something that vColumns does not know about.
>>>>>
>>>>> v.info -c map=
>>>>>
>>>>> 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).
>>>>>
>>>>> Does readVECT() work if you do not use v.clean? Is v.clean having a side
>>>>> effect of causing v.info -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?)?
>>>>>
>>>>> Roger
>>>>>
>>>>>
>>>>>
>>>>
>>>
>>>
>> --
>> Roger Bivand
>> Department of Economics, Norwegian School of Economics,
>> Helleveien 30, N-5045 Bergen, Norway.
>> voice: +47 55 95 93 55; fax +47 55 95 91 00
>> e-mail: ***@nhh.no
>>
>>
>

--
Roger Bivand
Department of Economics, Norwegian School of Economics,
Helleveien 30, N-5045 Bergen, Norway.
voice: +47 55 95 93 55; fax +47 55 95 91 00
e-mail: ***@nhh.no
Eduardo Diez
2015-10-11 21:08:14 UTC
Permalink
Here's the return from the latest version:

> zm.fnl <- readVECT(zm.gnrl)Exporting 29 areas (may take some time)...

VOUTOG~1 complete. 29 features (Polygon type) written to <k4610e1>
(ESRI_Shapefile format).
OGR data source with driver: ESRI Shapefile
Source: "C:/Users/ediez1/AppData/Local/Temp/Rtmp0MDfLZ/file2b9e445e7487a/file2b9e47fcf5925/.tmp/unknown",
layer: "k4610e1"
with 29 features
It has 3 fieldsWarning message:In vColumns(vname) : vColumns: v.info
-c output not in two columns:
Displaying column types/names for database connection of layer <1>:


Regards


2015-10-11 16:49 GMT-03:00 Roger Bivand <***@nhh.no>:

> On Sun, 11 Oct 2015, Eduardo Diez wrote:
>
> With today's development version it works with the warning you mentioned.
>>
>> zm.fnl <- readVECT(zm.gnrl)Exporting 29 areas (may take some time)...
>>>
>>
>> VOUTOG~1 complete. 29 features (Polygon type) written to <dc2ad04>
>> (ESRI_Shapefile format).
>> OGR data source with driver: ESRI Shapefile
>> Source:
>> "C:/Users/ediez1/AppData/Local/Temp/RtmpW8PKp3/file2b88c7f0f107d/file2b88c71f92564/.tmp/unknown",
>> layer: "dc2ad04"
>> with 29 features
>> It has 3 fieldsWarning message:In vColumns(vname) : vColumns: v.info
>> -c output not all in two columns
>>
>
> Please try:
>
> http://win-builder.r-project.org/miws6tzuLCCJ
>
> for a new version that should report the !=2 columns lines, and
> accommodates a safety fix to use Markus' suggestion to retrieve the db
> type, and drop the fix for long file names if the GRASS db driver is nor
> sqlite.
>
> Roger
>
>
>
>>
>> Thanks a lot for all the time invested in developing and mantaining these
>> wonderful tools everyone can use.
>>
>> A side question: is there a way of performing the same thing i'm trying to
>> do from GRASS (i.e. removing specific sized polygons by including them
>> into
>> larger ones) from plain R without needing to call external functions?
>>
>> Thanks again
>> Eduardo
>>
>>
>> 2015-10-11 11:28 GMT-03:00 Roger Bivand <***@nhh.no>:
>>
>> On Sat, 10 Oct 2015, Roger Bivand wrote:
>>>
>>> On Sat, 10 Oct 2015, Eduardo Diez wrote:
>>>
>>>>
>>>> This is what i got:
>>>>
>>>>>
>>>>> vinfo0 <- execGRASS("v.info", flags="c", map=zm.gnrl)INTEGER|cat
>>>>>
>>>>>>
>>>>>> INTEGER|ID
>>>>> INTEGER|GRIDCODE
>>>>> Displaying column types/names for database connection of layer <1>:
>>>>>
>>>>>
>>>>> And trying to read back the original polygon (without v.clean):
>>>>>
>>>>> zm.fnl <- readVECT(zm.pol)Error in scan(file, what, nmax, sep, dec,
>>>>>
>>>>>> quote,
>>>>>>
>>>>>> skip, nlines, na.strings, :
>>>>>
>>>>
>>>> line 4 did not have 2 elements
>>>>>
>>>>>
>>>>> This is coming from:
>>>>
>>>> G_message(_("Displaying column types/names for database connection
>>>> of
>>>> layer <%s>:"), field_opt);
>>>>
>>>> line 134 in vector/v.info/print.c.
>>>>
>>>> For me in nc_basic, for schools, I do not see the message with:
>>>>
>>>> vinfo0 <- execGRASS("v.info", flags="c", map="schools", layer="1",
>>>> intern=TRUE)
>>>>
>>>> which is what is being used in vColumns. Is there an alternative to
>>>> v.info that may be less error-prone?
>>>>
>>>>
>>> The development Windows binary of rgrass7 at:
>>>
>>> http://win-builder.r-project.org/9YK08bQi1ldt
>>>
>>> is an attempt to address a problem I cannot reproduce (with GRASS 7.0.1
>>> Windows standalone) - instead of assuming two-column output, it drops
>>> lines
>>> with != 2 columns and issues a warning if they were found.
>>>
>>> There is a further weakness in the readVECT code involving a conditional
>>> assumption that the db driver is sqlite - is there any way to check from
>>> outside which driver is being used?
>>>
>>> Roger
>>>
>>>
>>>
>>> Roger
>>>>
>>>>
>>>>
>>>>>
>>>>>
>>>>> 2015-10-10 13:12 GMT-03:00 Roger Bivand <***@nhh.no>:
>>>>>
>>>>> On Sat, 10 Oct 2015, Eduardo Diez wrote:
>>>>>
>>>>>>
>>>>>> Apparently "v.info" through execGRASS is expecting the "layer"
>>>>>> argument to
>>>>>>
>>>>>> be a string rather than an integer.
>>>>>>>
>>>>>>>
>>>>>>> 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):
>>>>>>
>>>>>> vinfo0 <- execGRASS("v.info", flags="c", map=zm.gnrl)
>>>>>>
>>>>>> My guess is that v.info is saying that this map is broken, or
>>>>>> suffering
>>>>>> from something that vColumns does not know about.
>>>>>>
>>>>>> v.info -c map=
>>>>>>
>>>>>> 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).
>>>>>
>>>>>>
>>>>>> Does readVECT() work if you do not use v.clean? Is v.clean having a
>>>>>> side
>>>>>> effect of causing v.info -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?)?
>>>>>>
>>>>>> Roger
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>
>>>> --
>>> Roger Bivand
>>> Department of Economics, Norwegian School of Economics,
>>> Helleveien 30, N-5045 Bergen, Norway.
>>> voice: +47 55 95 93 55; fax +47 55 95 91 00
>>> e-mail: ***@nhh.no
>>>
>>>
>>>
>>
> --
> Roger Bivand
> Department of Economics, Norwegian School of Economics,
> Helleveien 30, N-5045 Bergen, Norway.
> voice: +47 55 95 93 55; fax +47 55 95 91 00
> e-mail: ***@nhh.no
>
>
Markus Neteler
2015-10-10 16:43:44 UTC
Permalink
On Sat, Oct 10, 2015 at 5:45 PM, Eduardo Diez <***@gmx.com> wrote:
>
> Apparently "v.info" through execGRASS is expecting the "layer" argument to be a string rather than an integer.


Yes, layer is a string:

v.info --interface-description
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE task SYSTEM "grass-interface.dtd">
<task name="v.info">
<description>
Outputs basic information about a vector map.
</description>
...
<parameter name="layer" type="string" required="no" multiple="no">
<label>
Layer number or name
</label>


Best
Markus
Roger Bivand
2015-10-12 11:14:15 UTC
Permalink
On Sat, 10 Oct 2015, Markus Neteler wrote:

> On Sat, Oct 10, 2015 at 5:45 PM, Eduardo Diez <***@gmx.com> wrote:
>>
>> Apparently "v.info" through execGRASS is expecting the "layer" argument to be a string rather than an integer.
>
>
> Yes, layer is a string:

But not in v.db.addtable:

<parameter name="layer" type="integer" required="no"
multiple="no">
<description>
Layer number where to add new attribute table
</description>
<default>
1
</default>
<guisection>
Definition
</guisection>
</parameter>

though I'm not aware of others (this in 7.0.1).

Roger

>
> v.info --interface-description
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE task SYSTEM "grass-interface.dtd">
> <task name="v.info">
> <description>
> Outputs basic information about a vector map.
> </description>
> ...
> <parameter name="layer" type="string" required="no" multiple="no">
> <label>
> Layer number or name
> </label>
>
>
> Best
> Markus
>

--
Roger Bivand
Department of Economics, Norwegian School of Economics,
Helleveien 30, N-5045 Bergen, Norway.
voice: +47 55 95 93 55; fax +47 55 95 91 00
e-mail: ***@nhh.no
Loading...