[R-sig-Geo] How to do Zonal Statistics after Kriging in R given Shapefile of Polygon

Edzer Pebesma edzer.pebesma at uni-muenster.de
Thu Sep 12 17:02:52 CEST 2013


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

After receiving a reproducible script & data from James (off-list), I
found the problem was generated by newdata (town) being a
SpatialPolygons object. In that case, as the Details: section of
?predict.gstat explains, gstat will try to make block kriging
estimates for each of the polygons. It will then complain about doing
block kriging in longlat (observations and newdata are longlat). I'm
not sure whether this complaint is fully justified in this case, but
you could spTransform both to a projected coordinate reference system
to avoid this, I think.

On 09/12/2013 08:30 AM, James Matthew Miraflor wrote:
> Thanks Jesse!
> 
> I tried out your suggestion (after making sure that the projection
> is the same), and I got this error message.
> 
>> kr <- krige(POVERTY_INCIDENCE~1, muni.sp, newdata=town,
>> model=v.fin)[using ordinary kriging]Error in predict.gstat(g,
>> newdata = newdata, block = block, nsim = nsim,  :
> gstat: value not allowed for: block kriging for long-lat data
> undefined
> 
> 
> Do you know how to fix this?
> 
> James
> 
> 
> 
> On Sat, Aug 3, 2013 at 5:51 AM, Jesse Berman
> <berman.jesse at gmail.com> wrote:
> 
>> James,
>> 
>> Have you considered block kriging with gstat?  This will allow a
>> smoothed estimate of an area average (e.g. a county or town
>> boundary) as opposed to over a fine grid.
>> 
>> It's relatively simple, as you merely set the town boundary as
>> your 'newdata,' although you will have to make sure it's in the
>> same projection as your points.
>> 
>> kr <- krige(POVERTY_INCIDENCE~1, muni.sp, newdata=town,
>> model=v.fin) spplot(kr, "var1.pred", col.regions =
>> rev(topo.colors(20)))
>> 
>> Jesse
>> 
>> 
>> 
>> 
>> ----- -------------------------------------------------------- 
>> Jesse D Berman, PhD Johns Hopkins Bloomberg School of Public
>> Health Department of Environmental Health Sciences Post-Doc -- 
>> View this message in context: 
>> http://r-sig-geo.2731867.n2.nabble.com/How-to-do-Zonal-Statistics-after-Kriging-in-R-given-Shapefile-of-Polygon-tp7584330p7584332.html
>>
>> 
Sent from the R-sig-geo mailing list archive at Nabble.com.
>> 
>> _______________________________________________ R-sig-Geo mailing
>> list R-sig-Geo at r-project.org 
>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>> 
> 
> 
> 

- -- 
Edzer Pebesma
Institute for Geoinformatics (ifgi), University of Münster
Heisenbergstraße 2, 48149 Münster, Germany. Phone: +49 251
83 33081, Fax: +49 251 8339763 http://ifgi.uni-muenster.de
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQEcBAEBAgAGBQJSMdecAAoJEM1OCHCtOnfxD0oH/3TV7tLxJ6ljrBJ07RjPfIB0
bbKz+UvuMTUFFMt1XySkKIxX1DKg/337a7LmVxQk1mhFM3ufRJ0ROPL1rGEwfr+z
jzcB4nN6XSKtPuisMTBA10dksSeu0qVV27kyGQ5+mAw8Ilcjj/uTTHj4uRw1NiNP
43F2Kh1HcPNK4VWVPOLkznXV+YfOuBZFhPg2WzgSIHWVY4FFo7Bz5iCox2FjPoi1
2EA3u5Fq67o6j3skxNF8lk+CoOeNJl8jew7YYQGCWNsm3AgTkOQe0VXPE7hxfCn3
zBxkUn6gBJQNSGiZXyczFUCB8JW9gpNsiW18P7uJLttpN5x3TjQtJzIEWaFnN9Y=
=xF9G
-----END PGP SIGNATURE-----



More information about the R-sig-Geo mailing list