[R-sig-Geo] kriging limits

O'Hanlon, Simon J simon.ohanlon at imperial.ac.uk
Tue Oct 30 10:34:25 CET 2012


Dear Marco,
You can download shapefile of the world in varying resolutions at http://www.naturalearthdata.com/ Check under the links marked 'cultural'.

They  come with country boundaries but I think you can easily melt these using rgeos:::gUnaryUnion

Thanks,

Simon

-----Original Message-----
From: r-sig-geo-bounces at r-project.org [mailto:r-sig-geo-bounces at r-project.org] On Behalf Of marco milella
Sent: 29 October 2012 22:12
To: r-sig-geo
Subject: Re: [R-sig-Geo] kriging limits

Dear Rob,

thanks for the help. However, my shp file is a SpatialLinesDataFrame, so things not work (blue plot). On the other hand, I tried with an old map of Europe (SpatialPolygonsDataFrame) and it works fine. Do any of you know where to find SpatialPolygonsDataframe .shp file of all world (possibly without coutries boundaries)?
Thanks in advance for any feedback
marco

2012/10/29 Rob Robinson <rob.robinson at bto.org>

> Marco,
>  'colouring' only the land is relatively easy, kriging over just the 
> land is much harder... To do the former, all you need to to do is plot 
> your kriged map, then plot a 'mask' over the sea area. To create the 
> mask, you need something like the snippet below
>
> world<-readShapeSpatial("10m_coastline.shp")
>
> library(rgeos)
> g3<-readWKT("POLYGON((-180 -90,-180 90,180 90,180 -90,-180 -90))")
> sea_mask<-gDifference(g3,world)
> plot(sea_mask, col='blue', border='transparent', add=T)
>
> hope that helps
> cheers
> rob
>
>
>
> **************  Find out about Britain's birds - www.bto.org/birdfacts
> **************
>
> Dr Rob Robinson, Principal Ecologist
> British Trust for Ornithology, The Nunnery, Thetford, Norfolk, IP24 2PU
> Ph: +44 (0)1842 750050     E: rob.robinson at bto.org
> Fx: +44 (0)1842 750030     W: www.bto.org/about-bto/our-staff/rob-robinson
>
> ====== "How can anyone be enlightened, when truth is so poorly lit" 
> =======
>
>
>
>
> On 28 October 2012 13:25, marco milella <vrukol at gmail.com> wrote:
>
>> Dear all,
>>
>> I'm a relatively new with R. However, I realized from colleagues the 
>> great capabilities of R or analyzing geo data.
>> I'm interested in performing an ordinary kriging to interpolate z 
>> value on a world map sarting from a dataset that (unfortunately) 
>> includes rather few observations (13 locations worldwide).
>> my problems are the following:
>>
>> 1) the obtained plot extend the kriging to seas and i would like to 
>> "color"
>> only lands
>> 2)I can't find a way to illustrate the kriging in a more "wave (or 
>> bands) of colors rather that in a extremely smooth way as you see in 
>> the attached figure
>>
>>
>>
>> below my commands
>>
>>   library(maptools);library(fields);library(maps);library(geoR)
>> #here I import a .shp file representing world coastlines downloaded 
>> from http://www.soest.hawaii.edu/pwessel/gshhs/index.html
>>   world<-readShapeSpatial("10m_coastline.shp")
>> #now I import my dataset (value.txt), including 13 rows (each 
>> location) and
>> 3 columns (Lat, Long, value)
>>   dati<-read.table("value.txt",header=TRUE)
>>   attach (dati)
>>   s<-cbind(Long,Lat);
>>   ml <- likfit(data=dati[,3],coords=s,
>>                fix.nugget=F,cov.model="exponential",
>>                ini = c(30, 5),nugget=5);
>>   sp1<-seq(min(s[,1]),max(s[,1]),length=500);
>>   sp2<-seq(min(s[,2]),max(s[,2]),length=500);
>>   sp<-expand.grid(sp1,sp2);
>>   inCA<-map.where("state",x=sp[,1],y=sp[,2]);
>>   inCA<-inCA=="world"
>>   pred<-krige.conv(data=dati[,3],coords=s,locations=sp,
>>                    krige=krige.control(cov.model="exponential",
>>                                        cov.pars=c(26.19,13.7),
>>                                        nugget=4.5763));
>>   image.plot(sp1,sp2,matrix(pred$predict,500,500),zlim=range(dati[,3]))
>>   map("world",add=T)
>>
>>         [[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]]

_______________________________________________
R-sig-Geo mailing list
R-sig-Geo at r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo



More information about the R-sig-Geo mailing list