[R-sig-Geo] Fwd: Re: spplot help, please
Bede-Fazekas Ákos
bfalevlist at gmail.com
Sun Oct 22 11:01:03 CEST 2017
E-mail of Marvin Sharva, accidentally addressed only to me, is forwarded
below.
Ákos
-------- Továbbított üzenet --------
Tárgy: Re: [R-sig-Geo] spplot help, please
Dátum: Sat, 21 Oct 2017 13:57:04 +0000 (UTC)
Feladó: Marvin Sharma <marvinsharma at yahoo.com>
Válaszcím: Marvin Sharma <marvinsharma at yahoo.com>
Címzett: Bede-Fazekas Ákos <bfalevlist at gmail.com>
Dear Bede-Fazekas, Edzer, and Florian, and the list,
The following code produces the plot without the state map of georgia. I
got some help from the old thread answered few years ago, but could not
match the state names and counties names, see code below.
library(spgwr)
library(spdep)
library(maps)
library(maptools)
data<-read.csv("C:/Users/md_sh/Desktop/try.csv",header=TRUE)
map = SpatialPointsDataFrame(data=data,
coords=cbind(data$Longitude,data$Latitude))
GA.adapt.gauss <- gwr.sel(y~x,data=map,adapt=TRUE)
res.adpt <- gwr(y~x,data=map,adapt=GA.adapt.gauss)
res.adpt$SDF$ols.e <- residuals(lm(y~x,data=map))
spplot(res.adpt$SDF, c("ols.e", "gwr.e"),main="Residuals from OLS and GWR")
#This provides plot without the state map! sorry!
GA <- map("county", "georgia", plot=FALSE, fill=TRUE)
cntys <- tolower(as.character(data$county))
GA$names <- substring(GA$names, 14, nchar(GA$names))
match(cntys, GA$names)##It does not match!
Thanks much,
Marvin
On Saturday, October 21, 2017 9:39 AM, Marvin Sharma
<marvinsharma at yahoo.com> wrote:
Hello Bede-Fazekas,
This code provides the residuals, and residual plot without the state
map I want the residuals withing the Georgia state map.
Could you see where I need to make change?
Marvin
On Saturday, October 21, 2017 1:53 AM, Bede-Fazekas Ákos
<bfalevlist at gmail.com> wrote:
Hi Marvin,
this code works fine just as it should work. Which "state map" you need?
A basemap with terrain/roads/cities/borders? In this case there are
several possibilities to do that. Have a look at these links, they may
solve your problem:
https://pakillo.github.io/R-GIS-tutorial/#gmap
http://www.nickeubank.com/wp-content/uploads/2015/10/RGIS3_MakingMaps_part1_mappingVectorData.html
(Section "4.2 Basemaps with spplot")
HTH,
Ákos Bede-Fazekas
Hungarian Academy of Sciences
2017.10.21. 3:29 keltezéssel, Marvin Sharma via R-sig-Geo írta:
> 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.
>
> 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 <mailto:R-sig-Geo at r-project.org>
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
[[alternative HTML version deleted]]
_______________________________________________
R-sig-Geo mailing list
R-sig-Geo at r-project.org <mailto:R-sig-Geo at r-project.org>
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
[[alternative HTML version deleted]]
More information about the R-sig-Geo
mailing list