Description Usage Arguments Value Background Note Author(s) See Also Examples
Click near a line segment of a shapefile, and it's attribute(s) are displayed in the console. Currently only works for objects of class SpatialLinesDataFrame.
1 2 | showAttribute(object, object_psp=as.psp(object),
coltoshow=1:ncol(object), ID_col=1, notify=TRUE)
|
object |
object of class SpatialLinesDataFrame. Not tested for other objects yet! |
object_psp |
convert SpatialLinesDataFrame to line segment pattern. slow conversion, rather define it outside the function, especially when using the function more than once. DEFAULT: as.psp(object) |
coltoshow |
character vector. column(s) of attribute table to be showed. Should technically work with number(s) as well, not tested yet. DEFAULT: 1:ncol(object) |
ID_col |
Column to be used for identification. Not fully understood yet... DEFAULT: 1 |
notify |
logical. Are you to be told what to do in the console?. DEFAULT: TRUE |
none returned. print
s attrributes of selected item.
My colleague argues that arcGIS is better than R, because you can click on a line segment and see it's attributes. I took on the challenge to prove that R can do this just as well...
I have never used Line-Shapefiles in R before, so I doubt this is highly transferable.
Any Feedback is welcome!
The blue "selection" is overdrawn in white when par("bg") == "transparent" (the default)
I have some vague ideas about adding some kind of TCL-TK GU-Interface and allowing to click on another segment, and the info in the interface is updated automatically.
But I don't really know yet how to get that done...
Berry Boessenkool, berry-b@gmx.de, Nov. 2012
changeAttribute
, shapeZoom
, readShapeSpatial
in the package maptools.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | # see ?changeAttribute for more information
# Read Shapefile:
## Not run:
library(maptools)
library(spatstat)
xx <- readShapeLines(system.file("shapes/fylk-val.shp", package="maptools")[1],
proj4string=CRS("+proj=utm +zone=33 +datum=WGS84"))
xx_psp <- as.psp(xx) # slow for bigger shapefiles, so take it out of the function
# if object_psp is not given, it will be calculated each time...
plot(xx)
showAttribute(xx)
showAttribute(xx, xx_psp)
showAttribute(xx, xx_psp, 3:6)
showAttribute(xx, xx_psp, notify=FALSE) # Finish with "Enter"
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.