[R-sig-Geo] Working with raster data in R
Wall, Wade A ERDC-RDE-CERL-IL
Wade.A.Wall at usace.army.mil
Wed Jun 6 22:28:30 CEST 2012
Thank you for your assistance, and apologies for not posting an example.
Wade
-----Original Message-----
From: steven mosher [mailto:moshersteven at gmail.com]
Sent: Wednesday, June 06, 2012 3:12 PM
To: Wall, Wade A ERDC-RDE-CERL-IL
Cc: r-sig-geo at r-project.org
Subject: Re: [R-sig-Geo] Working with raster data in R
The best way to get help is to build a "toy" working example of the problem you face.
1. Create two rasters, where one is the subset of the other.
2. post that code here and what you tried.
3 decribe what you want to do in a bit more detail.
You will find that if you post working code and your attemps to solve the problem ( as the rules for posting suggest ) that you will get help. So,
First <- raster(xmn = -180, xmx = 180, ymn = -90, ymx = 90,
ncol = 72, nrow = 36,
crs = "+proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0")
First[]<-runif(ncell(First))
Second <- crop(First, extent(-70,-50,20,40))
## put some different values in second
Second[]<-runif(ncell(Second))
##
#now extract the values from the first raster based on the extent of the second
Extracted <- extract(First,extent(Second),cellnumbers=TRUE)
That's a start.
On Wed, Jun 6, 2012 at 10:46 AM, Wall, Wade A ERDC-RDE-CERL-IL <Wade.A.Wall at usace.army.mil> wrote:
Hi all,
I am new to working with raster data, so forgive my ignorance up front.
I have two raster files that I have imported into R using raster(). The second raster file is a subset of grids within the first raster file that covers an area. I would like to create an object (dataframe?) with the values from the first raster based on the spatial coordinates of the second raster, but cannot figure out how to do this, although it seems to be fairly simple.
Secondly, is there a way to bootstrap values from a raster file. For example, I would like to bootstrap X number of grid values and calculate the mean value.
Basically, I want to know if the values in the second raster (the subset) are less than the values in the first raster and want to test this through bootstrapping the first raster. If there is a better way, please let me know.
Thanks,
Wade A. Wall
US Army ERDC-CERL
P.O. Box 9005
Champaign, IL 61826-9005
1-800-872-2375 ext. 7320 <tel:1-800-872-2375%20ext.%207320>
1-217-353-6511 ext. 7320 <tel:1-217-353-6511%20ext.%207320>
_______________________________________________
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