[R-sig-Geo] create polygons from a SpatialPixelDataFrame
Maxime Pauwels
Maxime.Pauwels at univ-lille1.fr
Fri Sep 25 17:57:00 CEST 2009
Dear all,
Is there a simple way to create polygons from a SpatialPixelDataFrame?
Here is my script (data are in attached file):
projrpM<-read.table("NAproj.txt", header=T)
coordinates(projrpM)=~long+lat
gridded(projrpM)=TRUE
proj4string(projrpM)<-CRS("+proj=longlat")
#Get contour lines
projimgrpM<-as(projrpM, "SpatialGridDataFrame")
projimg1rpM<-as.image.SpatialGridDataFrame(projimgrpM["V1"])
projCLrpM<-contourLines(projimg1rpM, levels=0.000186)
projCLSLrpM<-ContourLines2SLDF(projCLrpM)
projlnsrpM<-list("sp.lines", projCLSLrpM, lwd=2, col="white",lty=1)
#Display results
spplot(projrp, scales=list(draw=T), xlim=c(-5, 30), ylim=c(40, 55),
cuts=12, pretty=T, col.regions=gray(180:40/200), sp.layout=list(projlnsrpM))
I'd like to fill the area delimited by white lines (attribute values
superior to levels=0.000186) in white. I could do using "cuts=", but my
idea is to create an object I could add on another spplot, using
sp.layout function
Could you help?
Many thanks
max
--
Maxime Pauwels
Researcher ID: http://www.researcherid.com/rid/A-1745-2009
Laboratoire de Génétique et Evolution des Populations Végétales
UMR CNRS 8016
Université de Lille, USTL-Lille1
http://gepv.univ-lille1.fr
Tel : +33 3 20 43 40 76
Fax : +33 3 20 43 69 79
«Impose ta chance, serre ton bonheur et va vers ton risque. A te
regarder, ils s’habitueront.»
René Char
More information about the R-sig-Geo
mailing list