Skip to content
Prev 11735 / 29559 Next

Generate a coordinate (latitude) image?

Jonathan, 

If your data are in lon/lat

r <- raster()
x <- init(r, v='x')
y <- init(r, v='y')


Or "by hand", for lon/lat do

lat <- yFromRow(r, 1:nrow(r))

if the raster is not lon/lat

xy <- SpatialPoints(xyFromCell(r, cellFromRowCol(1:nrow(r), 1)))
lat <- coordinates( spTransform(xy, CRS( +proj=longlat +datum=WGS84 )))[,2] 

In cases like this, I stop here. Rather than making a latitude raster with
lots of repeated values, I would work with the lat vector. But you could do
something like this:

x <- t((t(r) * lat))
plot(x)


Best, Robert
 

--
View this message in context: http://r-sig-geo.2731867.n2.nabble.com/Generate-a-coordinate-latitude-image-tp6375697p6378473.html
Sent from the R-sig-geo mailing list archive at Nabble.com.