[R-sig-Geo] spplot help, please
Ákos Bede-Fazekas
bfalevlist at gmail.com
Sun Oct 22 11:14:42 CEST 2017
Dear Marvin,
second argument of substring() is wrong. Change it from 14 to 9:
> GA$names <- substring(GA$names, 9, nchar(GA$names))
> match(cntys, GA$names)
[1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
18
[19] 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
36
[37] 37 38 39 40 41 42 43 NA 45 46 47 48 49 50 51 52 53
54
[55] 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
72
[73] 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
90
[91] 91 92 93 96 97 98 94 95 99 100 101 102 103 104 105 106 107
108
[109] 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125
126
[127] 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143
144
[145] 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159
HTH,
Ákos Bede-Fazekas
2017-10-22 11:01 GMT+02:00 Bede-Fazekas Ákos <bfalevlist at gmail.com>:
> 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> <marvinsharma at yahoo.com>
> Válaszcím: Marvin Sharma <marvinsharma at yahoo.com> <marvinsharma at yahoo.com>
> Címzett: Bede-Fazekas Ákos <bfalevlist at gmail.com> <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> <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> <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
> > 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
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>
>
>
>
>
[[alternative HTML version deleted]]
More information about the R-sig-Geo
mailing list