[R-sig-Geo] !SPAM: Re: Help with re-sampling a matrix: akin to cutting a cloth/paper into small pieces without interpolating
educheyne at avia-gis.be
Fri Jul 2 14:21:00 CEST 2010
if you use the package maptools you should be able to create an image with the resolution that you want
something like data.im.resampled<-as.im(matrix,dimyx=(floor(data.im$dim)*5))
for an image with a resolutin in x and y 5 times more fine
On 2 Jul 2010, at 13:47, Emmanuel Jjunju wrote:
> #I have data in a matrix with longitude (x coordinates) regularly spaced at
> 2.8 degrees and lat (y coordinates) at 2.5 degrees.I want to Resample my
> matrix z to a different resolution of say 1x1 in R without using
> interpolation (e.g inter in Akima package) because this distorts the data
> i.e. The data should not vary smoothly in space. What I want is analogous to
> resample in a GIS withoout smoothing, something like assigning the new pixel
> with the average or maximum of the contents in the pixel location. Ideally
> think of it like cutting a piece of cloth into tiny bits that retain the
> z<-matrix(runif(length(x)*length(y)),length(x),length(y))# my original
> image(x,y,z,col=cm.colors(20))# plots the data as is
> #Using Interpolation with Akima Interp
> xd<-seq(29,36,1)# new lon
> yd<-seq(-4,6,1) # new lat
> image(xd,yd,zd$z,col=cm.colors(20))# shows that interpolation has distorted
> the spatial pattern. What i want is similar pattern but with finer grid.
> Interp clearly cannot do this.
> # so how do i resample without changing the pattern.
> <a href="http://inside-r.org/download" title="Download R"><img src="
> border="0" /></a>
> [[alternative HTML version deleted]]
> R-sig-Geo mailing list
> R-sig-Geo at stat.math.ethz.ch
More information about the R-sig-Geo