showAttribute: Show attribute of ESRI-Shapefile line segment selected by...

Description Usage Arguments Value Background Note Author(s) See Also Examples

Description

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.

Usage

1
2
showAttribute(object, object_psp=as.psp(object),
coltoshow=1:ncol(object), ID_col=1, notify=TRUE)

Arguments

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

Value

none returned. prints attrributes of selected item.

Background

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

Note

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

Author(s)

Berry Boessenkool, berry-b@gmx.de, Nov. 2012

See Also

changeAttribute, shapeZoom, readShapeSpatial in the package maptools.

Examples

 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)

brry/shapeInteractive documentation built on May 13, 2019, 7:54 a.m.