[R-sig-Geo] Area of Spatial Pixels

Rafael Wüest rafael.wueest at wsl.ch
Thu Jan 26 17:30:17 CET 2012


Hi Mark

If you create a raster via

r<-raster(bath)

you can use the area function of the raster package.

check out ?area

Rafael

On 26.01.2012, at 17:14, Mark Payne wrote:

> Dear R spatial gurus,
> 
> I am new to the spatial classes in R, but have been very impressed by what I've seen so far. Hopefully this question isn't too simple but I haven't been able to find the answer in either the mailing lists or documentation...
> 
> I have created a SpatialPixelsDataFrame as follows:
> 
>> summary(bath)
> Object of class SpatialPixelsDataFrame
> Coordinates:
>     min max
> lon -180 180
> lat  -90  90
> Is projected: FALSE
> proj4string : [+proj=longlat +datum=WGS84]
> Number of points: 64800
> Grid attributes:
>    cellcentre.offset cellsize cells.dim
> lon            -179.5        1       360
> lat             -89.5        1       180
> Data attributes:
>   Min. 1st Qu.  Median    Mean 3rd Qu.    Max.
> -7473.0 -4286.0 -2514.0 -1896.0   233.2  5731.0
>> 
> 
> This object represents the ocean bathymetry on  a global 1 degree grid. I would like to calculate the area of each pixel in this object (for use in further calculations), but can't figure out how to do it. Is there an easy and direct way to achieve this?
> 
> Best wishes,
> 
> Mark
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo



--
Rafael Wüest
Swiss Federal Research Institute WSL
Zürcherstrasse 111
8903 Birmensdorf
Switzerland

+41 44 7392126
rafael.wueest at wsl.ch
http://www.wsl.ch/info/mitarbeitende/wueest



More information about the R-sig-Geo mailing list