[R-sig-Geo] interacting with plots
Greg Snow
538280 at gmail.com
Thu Aug 16 18:33:10 CEST 2012
You could try something like:
library(rgdal)
library(sp)
scot_BNG <- readOGR(dsn=dsn, layer="scot_BNG")
plot(scot_BNG)
tmp <- SpatialPoints(locator(1))
proj4string(tmp) <- proj4string(scot_BNG)
over(tmp, scot_BNG)
# or
tmp2 <- over(scot_BNG, tmp)
plot( scot_BNG[!is.na(tmp2),], add=TRUE, col='green')
Does that do what you want?
On Thu, Aug 16, 2012 at 9:05 AM, Frazier, Tyler James
<tyler.j.frazier at tu-berlin.de> wrote:
> Hello,
>
> I am new to this group and am still working to figure out many things. I have a kind of basic question, regarding using R and interacting with plots. I have been exploring using the spplot in the sp package as a means to interact with plots, but haven't figured out how to use the function to identify specific attributes associated with an individual polygons. My code is really basic, I simply
>
> ea <- readOGR(".","ghana_eas_ft")
> plot(ea)
>
> is it possible to plot the map in a way where I can use the cursor in R to chose and identify attributes associated with a polygon. Also here is the output of str(ea) which follows with a lot of information after the @polygons which I assume is part of the sp class structure.
>
> Formal class 'SpatialPolygonsDataFrame' [package "sp"] with 5 slots
> ..@ data :'data.frame': 12438 obs. of 3 variables:
> .. ..$ EA_NOS : Factor w/ 1133 levels "001-005, 340-342",..: 1110 986 985 976 982 983 978 741 974 975 ...
> .. ..$ REG_CODE : Factor w/ 10 levels "01","02","03",..: 1 1 1 1 1 1 1 1 1 1 ...
> .. ..$ DIST_CODE: Factor w/ 18 levels "01","02","03",..: 9 9 9 9 9 9 9 9 9 9 ...
> ..@ polygons :List of 12438
>
> I am wondering if there are newer packages which provide the identify function for polygons. Currently I am referencing the Applied Spatial Data Analysis with R text.
>
> Thanks!
> Ty
>
> ---------------------------------------------------
> Dr. Tyler Frazier, AICP
> Senior Research Scientist
> Department of Transportation System Planning and Telematics
> Technische Universität Berlin
> Sekretariat SG 12
> Salzufer 17-19
> 10587 Berlin
> fon: +49 30 314 22418
> fax: +49 30 314 26269
> www.vsp.tu-berlin.de<http://www.vsp.tu-berlin.de>
> www.matsim.org<http://www.matsim.org>
>
>
>
>
>
>
> [[alternative HTML version deleted]]
>
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>
--
Gregory (Greg) L. Snow Ph.D.
538280 at gmail.com
More information about the R-sig-Geo
mailing list