[R-sig-Geo] Extraction along a SpatialLines object fails
Pascal Oettli
kridox at ymail.com
Fri May 2 10:35:38 CEST 2014
Dear list members,
Could someone explain me why the following example fails when the
latitude is equal to 0?
Thank you,
Pascal
##############################
############################################
library(raster)
old <- setwd(tempdir())
download.file('ftp://topex.ucsd.edu/pub/srtm30_plus/srtm30/grd/w020n40.nc',
'w020n40.nc', method='wget')
srtm <- raster('w020n40.nc')
proj4string(srtm) <- CRS('+proj=longlat +datum=WGS84 +no_defs
+ellps=WGS84 +towgs84=0,0,0')
extent(srtm)
lat <- 0
cds <- rbind(c(-20,lat), c(20,lat))
Sl <- SpatialLines(list(Lines(list(Line(cds)), "1")))
proj4string(Sl) <- CRS('+proj=longlat +datum=WGS84 +no_defs
+ellps=WGS84 +towgs84=0,0,0')
x11()
plot(srtm)
plot(Sl, add=TRUE)
lon <- extract(init(srtm, v='x'), Sl)[[1]]
out <- extract(srtm, Sl)[[1]]
out # no value
More information about the R-sig-Geo
mailing list