spplot help, please
The others are right, there is no state map in your code that you might
add to the points plot.
After a quick inspection of which geographic area we are dealing with,
here is one possible - and quite basic - solution on how to add state
polygons of the US (if that is what you intend to do) to your plot:
## download state polygons for the us
library(raster)
usa = getData("GADM", country = "USA", level = 1)
## create subset of state polygons (otherwise spplot() will take quite
long)
proj4string(res.adpt$SDF) = "+init=epsg:4326"
ext = extend(extent(res.adpt$SDF), 2.5)
states = crop(usa, ext)
## add state boundaries using 'sp.layout'
p = spplot(res.adpt$SDF, c("ols.e","gwr.e"), main = "Residuals",
?????????? sp.layout = list("sp.polygons", states))
p
Alternatively, you could also use latticeExtra::layer() instead of
'sp.layout'. Simply have a look at the help pages for further details.
Cheers,
Florian
Am 21.10.2017 um 10:58 schrieb Edzer Pebesma:
On 10/21/2017 03:29 AM, Marvin Sharma via R-sig-Geo wrote:
Hi, I wanted to plot the spplot of my model residuals. The plot works fine, but the state map does not appear. Code is given below and the data are attached. I would greatly appreciate any help in this.
I can't see where you're trying to plot/add a state map, in the example below.
Marvin
library(spgwr)
library(spdep)
library(maps)
library(maptools)
data<-read.csv("try.csv",header=TRUE)
coords=cbind(data$Longitude,data$Latitude)
g.adapt.gauss <- gwr.sel(y~x, data,coords,adapt=TRUE)
res.adpt <- gwr(y~x, data,coords, adapt=g.adapt.gauss)
brks <- c(-0.25, 0, 0.01, 0.025, 0.075)
cols <- grey(5:2/6)
res.adpt$SDF$ols.e <- residuals(lm(y~x, data))
spplot(res.adpt$SDF, c("ols.e","gwr.e"),main="Residuals")
_______________________________________________ R-sig-Geo mailing list R-sig-Geo at r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Dr. Florian Detsch Environmental Informatics Department of Geography Philipps-Universit?t Marburg Deutschhausstra?e 12 35032 (parcel post: 35037) Marburg, Germany Phone: +49 (0) 6421 28-25323 Web: http://www.uni-marburg.de/fb19/fachgebiete/umweltinformatik/detschf/index.html