Quantcast

Reading attribute from high resolution raster using low resolution raster as boundary

classic Classic list List threaded Threaded
2 messages Options
Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Reading attribute from high resolution raster using low resolution raster as boundary

asrovai
Dear friends,

I have 2 raster files, one with very high resolution (each degree-cell is
30x30m) and the other with coarser resolution (0.25 degree-cells).

The high resolution raster has info on forest cover area.  The low
resolution raster has info on species abundance.  My end goal is to
determine abundance per area.  That entails determining the forest cover
area (high res raster) within each one of low res raster degree-cells.

Is it possible to overlay both rasters and retrieve the area atribute from
high res raster for each one the degree-cells in the low res raster?  I
guess another way to do it it would be to determine the number of
degree-cells from the high resolution raster that lie within each one of
the degree-ceils from the coarser resolution raster?

Any help is much appreciated.  I have been stuck with this for a couple of
weeks..!!

Thanks!

Andre




*Andre Rovai, Ph.D.*
Research Associate V
Department of Oceanography and Coastal Sciences
Energy, Coast, and Environment Bldg., Room 3201
Louisiana State University
Baton Rouge, LA 70803
Phone: 225 578 6422 <(225)%20578-6422>
Cell: 225 439 5559 <(225)%20439-5559>
Email: [hidden email]
           [hidden email]

        [[alternative HTML version deleted]]

_______________________________________________
R-sig-ecology mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-ecology
Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Reading attribute from high resolution raster using low resolution raster as boundary

Jeremy Chacon
Hi Andre,

Are the dimensions of the low- and high-res images the same? If so, an easy
approach would be to up-scale the low-res image to be the same size as the
high-resolution image.

You can use EBImage from bioconductor to scale the low-res image with
nearest-neighbor interpolation, and then just grab the data from each
image. See code below.

Note that nearest-neighbor scaling is quite simple, so if the dimensions
were different, or the x- resolution was different than the y-resolution,
you could probably hack together an implementation.

# fake data
low_res = matrix(runif(100), 10, 10)
high_res = matrix(rnorm(10000), 100, 100)

source("http://bioconductor.org/biocLite.R")
biocLite("EBImage")
library(EBImage)

# nearest-neighbor scaling
upscaled_low_res = resize(low_res, w = nrow(high_res), h = ncol(high_res),
filter = "none")

# look same
par(mfrow = c(1,2))
image(low_res)
image(upscaled_low_res)

# naively put it together with loops
# (faster methods avail., but loops are easy to read)
all_dat = data.frame()
for (i in 1:nrow(high_res)){
  for (j in 1:nrow(high_res)){
    all_dat = rbind(all_dat,
                    data.frame(x = i,y = j, forest_cover = high_res[i,j],
abundance = upscaled_low_res[i,j]))
  }
}


On Tue, Apr 4, 2017 at 2:54 PM, Andre Rovai <[hidden email]> wrote:

> Dear friends,
>
> I have 2 raster files, one with very high resolution (each degree-cell is
> 30x30m) and the other with coarser resolution (0.25 degree-cells).
>
> The high resolution raster has info on forest cover area.  The low
> resolution raster has info on species abundance.  My end goal is to
> determine abundance per area.  That entails determining the forest cover
> area (high res raster) within each one of low res raster degree-cells.
>
> Is it possible to overlay both rasters and retrieve the area atribute from
> high res raster for each one the degree-cells in the low res raster?  I
> guess another way to do it it would be to determine the number of
> degree-cells from the high resolution raster that lie within each one of
> the degree-ceils from the coarser resolution raster?
>
> Any help is much appreciated.  I have been stuck with this for a couple of
> weeks..!!
>
> Thanks!
>
> Andre
>
>
>
>
> *Andre Rovai, Ph.D.*
> Research Associate V
> Department of Oceanography and Coastal Sciences
> Energy, Coast, and Environment Bldg., Room 3201
> Louisiana State University
> Baton Rouge, LA 70803
> Phone: 225 578 6422 <(225)%20578-6422>
> Cell: 225 439 5559 <(225)%20439-5559>
> Email: [hidden email]
>            [hidden email]
>
>         [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-ecology mailing list
> [hidden email]
> https://stat.ethz.ch/mailman/listinfo/r-sig-ecology
>



--

*___________________________________________________________________________Jeremy
M. Chacon, Ph.D.*

*Post-Doctoral Associate, Harcombe Lab*
*University of Minnesota*
*Ecology, Evolution and Behavior*

        [[alternative HTML version deleted]]

_______________________________________________
R-sig-ecology mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-ecology
Loading...