[R-sig-Geo] Overlaying spplots

Edzer Pebesma edzer.pebesma at uni-muenster.de
Thu Mar 27 11:05:52 CET 2008


Dear Friderike, please try adding the argument

sp.layout = list("sp.polygons", EA)

to the final spplot call.
--
Edzer

Friderike Oehler wrote:
> Dear R Users,
>
> I am struggeling to plot the z-column-values of a SpatialPointsDataFrame over a
> polygon shapefile map SpatialPolygonsDataFrame) representing country borders. I
> would like to use spplot in order to keep the scales. I followed the path that I
> found in the help archive (http://thread.gmane.org/gmane.comp.lang.r.geo/2063).
> This works fine to superimpose my points over the countries, however it does not
> allow the z-values of the points to be shown.
>
> The ADD=TRUE option does not seem to work for spplot. (Right or wrong?)
>
> I also tried with levelplots and panel-functions, without success (admittedly I
> am not an expert using these functions.) Without success were also my tries
> using "overlay".
>
> Any help would be much appreciated.
> Many thanks in advance,
> Friderike
>
> # This is the shapefile:
> EA=readShapePoly('C:/data/grassdata/EastAfrica/EastAfricaAdmin0',
> proj4string=CRS("+proj=longlat +datum=WGS84"), force_ring=TRUE)
> names(EA)
>  [1] "CAT"        "AREA"       "PERIMETER"  "G2006_2_"   "G2006_2_ID"
> "ADM2_CODE"  "ADM0_CODE"  "ADM0_NAME"  "ADM1_NAME"  "ADM1_CODE"  "ADM2_NAME" 
> [12] "LAST_UPDAT" "CONTINENT"  "REGION"   
>
> # This shows the shapefile
> spplot(EA, zcol='ADM0_CODE', scales=list(draw=TRUE), xlim=c(30,52),
> ylim=c(-10,18), col.regions='transparent', colorkey=FALSE)
>
> # This is the SpatialPointsDataFrame:
>  str(notinv)
> Formal class 'SpatialPointsDataFrame' [package "sp"] with 5 slots
>   ..@ data       :'data.frame': 1209 obs. of  1 variable:
>   .. ..$ FQ: int [1:1209] 2 2 4 1 1 1 2 1 1 3 ...
>   ..@ coords.nrs : int [1:2] 1 2
>   ..@ coords     : num [1:1209, 1:2] 35.5 36.5 37.5 35.5 36.5 37.5 38.5 40.5
> 36.5 37.5 ...
>   .. ..- attr(*, "dimnames")=List of 2
>   .. .. ..$ : NULL
>   .. .. ..$ : chr [1:2] "LON" "LAT"
>   ..@ bbox       : num [1:2, 1:2] -17.5 -3.5 92.5 38.5
>   .. ..- attr(*, "dimnames")=List of 2
>   .. .. ..$ : chr [1:2] "LON" "LAT"
>   .. .. ..$ : chr [1:2] "min" "max"
>   ..@ proj4string:Formal class 'CRS' [package "sp"] with 1 slots
>   .. .. ..@ projargs: chr NA
>
>  # And that's what it looks like:
> spplot(notinv, zcol='FQ', cuts=seq(1,max(Knotinvfreq$FQ),5), xlim=c(30,52),
> ylim=c(-10,18), key.space='bottom', scales=list(draw=TRUE),
> col.regions=terrain.colors(64,alpha=1))
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>




More information about the R-sig-Geo mailing list