On 18/05/2011 1:25, Jonathan Greenberg wrote:
Folks:
Is there any way to take a raster and generate two outputs where
each pixel is the center coordinate of that pixel (e.g. you will have
one x- image and one y-image)? I'm trying to produce a "latitude map"
for solar calculations.
If you mean "each pixel value is the center coordinate of that pixel"
you could proceed like this:
# (first, I built a raster for my toy example)
library(maptools)
data(meuse.grid) # only the non-missing valued cells
coordinates(meuse.grid) = c("x", "y") # promote to SpatialPointsDataFrame
gridded(meuse.grid) <- TRUE # promote to SpatialPixelsDataFrame
# now, assign the coordinates as values to each pixel
meuse.grid[["xcoord"]] = coordinates(meuse.grid)[,"x"]
meuse.grid[["ycoord"]] = coordinates(meuse.grid)[,"y"]
image(meuse.grid["xcoord"]) # note the single [
image(meuse.grid["ycoord"])
Cheers,
Marcelino
--j
--
_________________________________ Marcelino de la Cruz Rot Departamento
de Biologia Vegetal E.U.T.I. Agricola Universidad Politecnica de Madrid
28040 Madrid Tel: 34913365654 _________________________________
_______________________________________________
R-sig-Geo mailing list
[email protected]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo