[R-sig-Geo] Map of pixel area?

Forrest Stevens forrest at ufl.edu
Sat Jan 10 00:11:33 CET 2015


The easiest way I can think of would be to create an "index" raster
based on your raster of interest, convert it to polygons, project it
to an equal area projection with linear units amenable to you, then
extract the polygon areas and assign them back to your index raster
for weighting.  Perhaps something like this:


r1 <- raster()
r1[] <- 1:ncell(r1)
p1 <- rasterToPolygons(r1)

## Project to cylindrical equal area:
require(rgdal)
p2 <- spTransform(p1, CRS("+proj=cea +lat_0=0 +lon_0=0 +lat_ts=30
+a=6371228.0 +units=m"))

## Extract areas and assign back to raster:
areas <- sapply(slot(p2, "polygons"), slot, "area")
r2 <- r1
plot(r2)


Though, maybe someone else has a better way?

Sincerely,
Forrest
--
Forrest R. Stevens
Ph.D. Candidate, QSE3 IGERT Fellow
Department of Geography
Land Use and Environmental Change Institute
University of Florida
www.clas.ufl.edu/users/forrest


On Fri, Jan 9, 2015 at 5:29 PM, Jonathan Greenberg <jgrn at illinois.edu> wrote:
> R-sig-geo'ers:
>
> I have an analysis where I need to take a geographic projection map, e.g.:
>
> r1 <- raster()
>
> And calculate, for each pixel, the square kilometers that each individual
> pixel covers (since they vary across a geographic projection) -- the idea
> is to end up with a map of pixel area.  Can anyone think of a clever way to
> do this?  I'll be using this to do some area weighted summaries, but I
> can't simply reproject the input map.  Thanks!
>
> --j
>
>         [[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



More information about the R-sig-Geo mailing list