Description Usage Arguments Value Note Author(s) Examples
readVECT
moves one GRASS 6+ vector object file with attribute
data through a temporary shapefile to a Spatial*DataFrame object of
type determined by the GRASS 6+ vector object; writeVECT
moves
a Spatial*DataFrame object through a temporary shapefile to a GRASS
vector object file. vect2neigh
returns neighbour pairs with
shared boundary length as described by Markus Neteler, in
https://stat.ethz.ch/pipermail/r-sig-geo/2005-October/000616.html. cygwin_clean_temp
can be called to try to clean the GRASS mapset-specific temporary directory under cygwin.
The functions readVECT
and readVECT6
as well as writeVECT
and writeVECT6
are identical and the functions ending with
...6
are maintained only for backward compatibility and might be deprecated.
1 2 3 4 5 6 7 8 9 10 | readVECT(vname, layer, type=NULL, plugin=NULL, remove.duplicates = TRUE,
ignore.stderr = NULL, with_prj=TRUE, with_c=FALSE, mapset=NULL,
pointDropZ=FALSE, driver="ESRI Shapefile")
writeVECT(SDF, vname, v.in.ogr_flags=NULL, ignore.stderr = NULL,
driver="ESRI Shapefile")
vInfo(vname, layer, ignore.stderr = NULL)
vColumns(vname, layer, ignore.stderr = NULL)
vDataCount(vname, layer, ignore.stderr = NULL)
vect2neigh(vname, ID=NULL, ignore.stderr = NULL, remove=TRUE, vname2=NULL,
units="k")
|
vname |
A GRASS 6+ vector file name |
layer |
a layer name (integer in GRASS 6, string in GRASS 7); if missing set to default of 1 |
type |
override type detection when multiple types are non-zero, passed to v.out.ogr |
plugin |
default NULL for auto-detection, may be set to FALSE to avoid or TRUE if the plugin is known to be available; if the plugin is used, no further arguments other than mapset are respected |
remove.duplicates |
In line and area vector objects, multiple geometrical features may be associated with a single cat number, leading to duplication of data rows; this argument attempts to combine the geometrical features so that they match a single data row |
ignore.stderr |
default NULL, taking the value set by |
with_prj |
default TRUE, write ESRI-style PRJ file for transfered data |
with_c |
default TRUE in GRASS 6, FALSE in GRASS 7; if TRUE in GRASS 6 or FALSE in GRASS 7, export features with category (labeled) only; if not default, all features are exported, including GRASS “islands” which are probably spurious exterior rings filling holes. |
mapset |
if plugin is TRUE, the mapset of the file to be imported may be changed from the current mapset by passing a character string |
pointDropZ |
default FALSE, if TRUE, discard third coordinates for point geometries; third coordinates are alway discarded for line and polygon geometries |
driver |
default |
SDF |
A Spatial*DataFrame to be moved to GRASS6 as a vector object, for SpatialPointsDataFrame, SpatialLinesDataFrame, and SpatialPolygonsDataFrame objects |
v.in.ogr_flags |
Character vector containing additional optional flags and/or options for v.in.ogr, particularly "o" and "overwrite" |
ID |
A valid DB column name for unique identifiers (optional) |
remove |
default TRUE, remove copied vectors created in |
vname2 |
If on a previous run, remove was FALSE, the name of the temporary vector may be given to circumvent its generation |
units |
default “k”; see GRASS |
readVECT
imports a GRASS6+ vector object into a Spatial*DataFrame object with the type determined by the type of the GRASS6 vector object; vect2neigh
returns a data frame object with left and right neighbours and boundary lengths, also given class GRASSneigh and spatial.neighbour (as used in spdep). The incantation to retrieve the neighbours list is sn2listw(vect2neigh())$neighbours
, and to retrieve the boundary lengths: sn2listw(vect2neigh())$weights
. The GRASSneigh object has two other useful attributes: external is a vector giving the length of shared boundary between each polygon and the external area, and total giving each polygon's total boundary length.
Note that GRASS6 vectors should be rebuilt by running “v.build.all” in each mapset.
Please note that the OGR drivers used may not handle missing data gracefully. From rgdal release 0.5-27, missing values are taken as unset OGR field values. If the OGR driver encodes them in this way, NAs will be moved across the interface correctly from R to GRASS, and from GRASS to R using the OGR GRASS vector plugin. Work is continuing to correct v.out.ogr so that it emits unset fields, which affects users with no OGR GRASS plugin for the present. Thanks to Dylan Beaudette for helping with missing data handling.
Please also note that, on Windows and Cygwin systems, the temporary shapefiles are not removed by the interface functions, nor can GRASS remove them on termination - they must for the time being be removed manually. Windows believes that the GDAL/OGR library is still using them.
Roger S. Bivand, e-mail: Roger.Bivand@nhh.no.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | if (nchar(Sys.getenv("GISRC")) > 0) {
require(rgdal)
ois <- get.ignore.stderrOption()
set.ignore.stderrOption(TRUE)
if (execGRASS("g.version", intern=TRUE) > "GRASS 7") {
execGRASS("v.info", map="bugsites", layer="1")
} else {
execGRASS("v.info", map="bugsites", layer=1L)
}
print(vInfo("bugsites"))
bugs <- readVECT("bugsites", plugin=NULL)
print(summary(bugs))
bugs1 <- readVECT("bugsites", plugin=FALSE)
print(summary(bugs1))
writeVECT(bugs, "newbugs", v.in.ogr_flags=c("o", "overwrite"))
if (execGRASS("g.version", intern=TRUE) > "GRASS 7") {
execGRASS("v.info", map="newbugs", layer="1")
} else {
execGRASS("v.info", map="newbugs", layer=1L)
}
nbugs <- readVECT("newbugs")
print(summary(nbugs))
print(vInfo("roads"))
roads <- readVECT("roads")
print(summary(roads))
set.ignore.stderrOption(ois)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.