https://stat.ethz.ch/mailman/listinfo/r-sig-geo
or, via email, send a message with subject or body 'help' to
r-sig-geo-request at r-project.org
You can reach the person managing the list at
r-sig-geo-owner at r-project.org
When replying, please edit your Subject line so it is more specific
than "Re: Contents of R-sig-Geo digest..."hpjtk c nhutb
Today's Topics:
1. ifelse with multiple rasters (Laura Poggio)
2. Fwd: ifelse with multiple rasters (Laura Poggio)
3. Re: Fwd: ifelse with multiple rasters (Jonathan Greenberg)
4. How to do an anamorphosis on R? (Gilles Benjamin Leduc)
5. Re: Fwd: ifelse with multiple rasters (Laura Poggio)
6. Extract time series value for a given coodinate from an
unusual NetCDF file (ping yang)
----------------------------------------------------------------------
Message: 1
Date: Mon, 24 Feb 2014 14:15:22 +0000
From: Laura Poggio <laura.poggio at gmail.com>
To: R geo forum <r-sig-geo at stat.math.ethz.ch>
Subject: [R-sig-Geo] ifelse with multiple rasters
Message-ID:
<CAKmfgFPL1PKzx0DGBYRGQXM5gGhzbAzB8fDceYoT8vW6JmeFLA at mail.gmail.com>
Content-Type: text/plain
Dear list,
I am struggling to find a way to do a simple if statement with multiple
rasters in raster.
For example:
ifelse(rst_a==0 & rst_B=1,2,0)
Which is the simplest and most efficient way to implement it? especially
when considering large (>10,000,000 cells) rasters?
Thank you in advance
Laura
[[alternative HTML version deleted]]
------------------------------
Message: 2
Date: Mon, 24 Feb 2014 14:16:33 +0000
From: Laura Poggio <laura.poggio at gmail.com>
To: r-sig-geo at r-project.org
Subject: [R-sig-Geo] Fwd: ifelse with multiple rasters
Message-ID:
<CAKmfgFNOZpi0QR4KPrCddAf9O12rYKv0EAeSu5Rom7qVfPWRSA at mail.gmail.com>
Content-Type: text/plain
Dear list,
I am struggling to find a way to do a simple if statement with multiple
rasters in raster.
For example:
ifelse(rst_a==0 & rst_B=1,2,0)
Which is the simplest and most efficient way to implement it? especially
when considering large (>10,000,000 cells) rasters?
Thank you in advance
Laura
[[alternative HTML version deleted]]
------------------------------
Message: 3
Date: Mon, 24 Feb 2014 08:50:06 -0600
From: Jonathan Greenberg <jgrn at illinois.edu>
To: Laura Poggio <laura.poggio at gmail.com>
Cc: "r-sig-geo at r-project.org" <r-sig-geo at r-project.org>
Subject: Re: [R-sig-Geo] Fwd: ifelse with multiple rasters
Message-ID:
<CABG0rfuEW28tOCMm841mAjVgZaZHkTBBJdSn9Lein1i75byrXw at mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1
Laura:
If this is a straight masking procedure, you can do some
multiplication tricks in raster like:
output = rst_a*rst_B*2
or look at
?overlay
or take a look at
?mask
I suspect mask and overlay are faster than the raster algebra
statement (Robert, is this correct?)
If you want to use rasterEngine for parallel processing, you can do
something like this:
library(spatial.tools)
# Set X to the number of CPUs you want top use and uncomment this for
parallel processing:
# sfQuickInit(cpus=X)
rst_test <- function(rst_a,rst_B)
{
return(ifelse(rst_a==0 & rst_B==1,2,0))
}
# Fill in the rasters you intend to use here:
raster_check <-
rasterEngine(rst_a=someraster,rst_B=someotherraster,fun=rst_test)
# Uncomment to stop the parallel engine if need be:
# sfQuickStop()
--j
On Mon, Feb 24, 2014 at 8:16 AM, Laura Poggio <laura.poggio at gmail.com> wrote:
Dear list,
I am struggling to find a way to do a simple if statement with multiple
rasters in raster.
For example:
ifelse(rst_a==0 & rst_B=1,2,0)
Which is the simplest and most efficient way to implement it? especially
when considering large (>10,000,000 cells) rasters?
Thank you in advance
Laura
[[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
--
Jonathan A. Greenberg, PhD
Assistant Professor
Global Environmental Analysis and Remote Sensing (GEARS) Laboratory
Department of Geography and Geographic Information Science
University of Illinois at Urbana-Champaign
259 Computing Applications Building, MC-150
605 East Springfield Avenue
Champaign, IL 61820-6371
Phone: 217-300-1924
http://www.geog.illinois.edu/~jgrn/
AIM: jgrn307, MSN: jgrn307 at hotmail.com, Gchat: jgrn307, Skype: jgrn3007
------------------------------
Message: 4
Date: Mon, 24 Feb 2014 15:24:35 +0000
From: "Gilles Benjamin Leduc" <gbl1 at hi.is>
To: R-sig-Geo at r-project.org
Subject: [R-sig-Geo] How to do an anamorphosis on R?
Message-ID: <3011-530b6400-7f-7f728600 at 71854736>
Content-Type: text/plain; charset="utf-8"
Hi all,
I would like to make an anamorphosis map, id est, a map where some other distance measurement are used instead geographical distance. In my case I would like to plot an anamorphosis of Iceland using genetical distence insteand of geographical distence.
I have got .shp maps and equivalents.
How to make such a distortion?
Best regards
Benjamin
------------------------------
Message: 5
Date: Mon, 24 Feb 2014 15:50:10 +0000
From: Laura Poggio <laura.poggio at gmail.com>
To: Jonathan Greenberg <jgrn at illinois.edu>
Cc: "r-sig-geo at r-project.org" <r-sig-geo at r-project.org>
Subject: Re: [R-sig-Geo] Fwd: ifelse with multiple rasters
Message-ID:
<CAKmfgFPBUrzqa9PS26R62YEP8EtNWUqz9fuaXjYwR-eQZWzZXQ at mail.gmail.com>
Content-Type: text/plain
Dear Jonathan,
thank you very much. I will have a closer look to overlay, but I think that
your example with Spatial.tools is the most straightforward for the way I
think... and it can be used with multiple processors.
Thanks
Laura
On 24 February 2014 14:50, Jonathan Greenberg <jgrn at illinois.edu> wrote:
Laura:
If this is a straight masking procedure, you can do some
multiplication tricks in raster like:
output = rst_a*rst_B*2
or look at
?overlay
or take a look at
?mask
I suspect mask and overlay are faster than the raster algebra
statement (Robert, is this correct?)
If you want to use rasterEngine for parallel processing, you can do
something like this:
library(spatial.tools)
# Set X to the number of CPUs you want top use and uncomment this for
parallel processing:
# sfQuickInit(cpus=X)
rst_test <- function(rst_a,rst_B)
{
return(ifelse(rst_a==0 & rst_B==1,2,0))
}
# Fill in the rasters you intend to use here:
raster_check <-
rasterEngine(rst_a=someraster,rst_B=someotherraster,fun=rst_test)
# Uncomment to stop the parallel engine if need be:
# sfQuickStop()
--j
On Mon, Feb 24, 2014 at 8:16 AM, Laura Poggio <laura.poggio at gmail.com>
wrote:
Dear list,
I am struggling to find a way to do a simple if statement with multiple
rasters in raster.
For example:
ifelse(rst_a==0 & rst_B=1,2,0)
Which is the simplest and most efficient way to implement it? especially
when considering large (>10,000,000 cells) rasters?
Thank you in advance
Laura
[[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
--
Jonathan A. Greenberg, PhD
Assistant Professor
Global Environmental Analysis and Remote Sensing (GEARS) Laboratory
Department of Geography and Geographic Information Science
University of Illinois at Urbana-Champaign
259 Computing Applications Building, MC-150
605 East Springfield Avenue
Champaign, IL 61820-6371
Phone: 217-300-1924
http://www.geog.illinois.edu/~jgrn/
AIM: jgrn307, MSN: jgrn307 at hotmail.com, Gchat: jgrn307, Skype: jgrn3007
[[alternative HTML version deleted]]
------------------------------
Message: 6
Date: Mon, 24 Feb 2014 21:27:55 -0600
From: ping yang <pingyang.whu at gmail.com>
To: r-sig-geo <r-sig-geo at r-project.org>
Subject: [R-sig-Geo] Extract time series value for a given coodinate
from an unusual NetCDF file
Message-ID:
<CAK8gSG9+gqx6W=496oHysYnm9qiPdkAkt5UcGwL6opxsDY18QA at mail.gmail.com>
Content-Type: text/plain
Hi r-sig-geo,
previously I used following code to extract time series value for a given
coodinate from a netcdf file:
require(raster)
require(ncdf)
require(sp)
X1 <- -90.5167
Y1 <- 33.45
MS <- cbind(X1,Y1)
p <- SpatialPoints(MS)
year <- 1981
setwd("e:/PRISM/NetCDF/")
filename <- paste("PRISM_MS")
pptfile <- paste("ppt","_",year,".nc",sep='')
b_ppt <- brick(pptfile,varname='ppt')
ppt <- extract(b_ppt,coordinates(p))
it was successful. However, when I use the same method for another NetCDF
(which has unusual dimension), i got errors, then I check the difference,
it showed that the dimension for the two files are different:
The file is working has following information:
Netcdf file 1:
class : RasterBrick
*dimensions : 621, 1405, 872505, 365 (nrow, ncol, ncell, nlayers)*
resolution : 0.04166667, 0.04166667 (x, y)
extent : -125.0208, -66.47917, 24.0625, 49.9375 (xmin, xmax, ymin,
ymax)
coord. ref. : +proj=longlat +datum=NAD83 +no_defs +ellps=GRS80
+towgs84=0,0,0
data source : e:\PRISM\NetCDF\ppt_1981.nc
names : X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X12, X13, X14,
X15, ...
unknown : 1, 365 (min, max)
varname : ppt
The one is not working with above code has following information
NetCDF file 2:
class : RasterBrick
*dimensions : 1386, 365, 505890, 585 (nrow, ncol, ncell, nlayers) *
resolution : 1, 0.041666 (x, y)
extent : 29584.5, 29949.5, -124.793, -67.04392 (xmin, xmax, ymin,
ymax)
coord. ref. : +proj=longlat +datum=WGS84
data source : e:\UoIGriddedWeather\pr_1981.nc
names : X49.3960227966309, X49.3543586730957, X49.3126907348633,
X49.2710266113281, X49.2293586730957, X49.1876945495605, X49.1460266113281,
X49.104362487793, X49.0626945495605, X49.0210304260254, X48.979362487793,
X48.9376983642578, X48.8960304260254, X48.8543663024902, X48.8126983642578,
...
degrees_north: 25.0630779266357, 49.3960227966309 (min, max)
varname : precipitation_amount
The dimension in the NetCDF file 2 is not correct. should be 585, 1386,
505890,365.
Has someone encountered the same problem before? How to resolve this?
Look forward suggestions and solutions.
Thanks,
Ping
[[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
End of R-sig-Geo Digest, Vol 126, Issue 22
******************************************