Skip to content
Prev 6548 / 29559 Next

create polygons from a SpatialPixelDataFrame

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