[R-sig-Geo] long 0-360, shift to -180 to 180
Michael Loranty
mloranty at whrc.org
Thu Mar 10 14:58:37 CET 2011
Hi Andy,
I think the rotate function in the raster package might be what you're
looking for.
Hope things are well with you.
-Mike
dat <- matrix(data = 1:100, nrow=360, ncol = 360)
> bar <-
raster(dat,xmn=0,xmx=356.25,ymn=-87.159094555863,ymx=87.159094555863,
+ crs="+proj=longlat +datum=WGS84")
> bar
class : RasterLayer
filename :
nrow : 360
ncol : 360
ncell : 129600
min value : 1
max value : 100
projection : +proj=longlat +datum=WGS84
extent : 0, 356.25, -87.1591, 87.1591 (xmin, xmax, ymin, ymax)
resolution : 0.9895833, 0.4842172 (x, y)
> bar2 <- rotate(bar)
> bar2
class : RasterLayer
filename :
nrow : 360
ncol : 360
ncell : 129600
min value : 1
max value : 100
projection : +proj=longlat +datum=WGS84
extent : -178.125, 178.125, -87.1591, 87.1591 (xmin, xmax, ymin,
ymax)
resolution : 0.9895833, 0.4842172 (x, y)
On Mar 10, 2011, at 6:00 AM, r-sig-geo-request at r-project.org wrote:
>
> Message: 18
> Date: Wed, 9 Mar 2011 16:18:17 -0800
> From: Andy Bunn <Andy.Bunn at wwu.edu>
> To: "r-sig-geo at r-project.org" <r-sig-geo at r-project.org>
> Subject: [R-sig-Geo] long 0-360, shift to -180 to 180
> Message-ID:
> <7E6EA3F4372E474F8F3F850DD262FDA9125D914C82 at ExchMailbox3.univ.dir.wwu.edu
> >
>
> Content-Type: text/plain; charset="us-ascii"
>
> I have a raster with longitude data over 0 to 360.
>
> bar <- raster(t(foo[,,
> 1]),xmn=0,xmx=356.25,ymn=-87.159094555863,ymx=87.159094555863,
> crs="+proj=longlat +datum=WGS84")
>
> I'd like to shift those longitudes to -180 to 180. I tried paying
> with the +long_wrap argument to crs but to no avail. Can somebody
> help? I'll need to overlay and extract data from the negative side
> (e.g., 100W or -100) and it would be nice to have the coordinates
> the same.
>
> Thanks in advance,
> Andy
>
>
>> -----Original Message-----
>> From: r-sig-geo-bounces at r-project.org [mailto:r-sig-geo-bounces at r-
>> project.org] On Behalf Of Tom Gottfried
>> Sent: Wednesday, March 09, 2011 1:40 PM
>> To: r-sig-geo at r-project.org
>> Subject: Re: [R-sig-Geo] predicting values from variofit function
>>
>> Hi Anna,
>>
>> Am 09.03.2011 21:25, schrieb Anna Gretschel:
>>> Dear List,
>>>
>>> I have fitted a spherical function to my variogram using
>> "variofit(...)"
>>> from GeoR. Now I would like to predict some data with the function
>>> "predict(object,...)" from package stats.
>>
>> Note that predict() is a generic function (see
>> http://cran.r-project.org/doc/manuals/R-intro.html#Object-orientation)
>> .
>> I don't think there is a method in geoR that does what you want.
>>
>>> Does anyone know wether this
>>> works and if it does how to do it?
>>
>> The package gstat has a method for objects of class gstat (see ?
>> gstat,
>> ?predict.gstat and the ASDAR book). You can coerce your variogram fit
>> from geoR to the respective class used in package gstat with
>> as.vgm.variomodel(). You can do kriging with krige.conv() from geoR
>> too.
>> But I think you have more options in gstat.
>>
>> regards,
>> Tom
>>
>>>
>>> Thanks a lot!
>>> Anna
>>>
>>> _______________________________________________
>>> R-sig-Geo mailing list
>>> R-sig-Geo at r-project.org
>>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>>
>> _______________________________________________
>> R-sig-Geo mailing list
>> R-sig-Geo at r-project.org
>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>
>
>
> ------------------------------
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>
>
> End of R-sig-Geo Digest, Vol 91, Issue 10
> *****************************************
>
More information about the R-sig-Geo
mailing list