I need to extract altitude values from a raster using spatial data frame points.
Crossing two objects (raster and vectorial) I have just obtained NA.
> lat41_42_sp
class : RasterLayer
dimensions : 1201, 10801, 12972001 (nrow, ncol, ncell)
resolution : 0.0008333333, 0.0008333333 (x, y)
extent : -9.000417, 0.0004166633, 40.99958, 42.00042 (xmin, xmax, ymin, ymax)
crs : +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0
source : memory
names : layer
values : -12, 2307 (min, max)
> spdf
class : SpatialPointsDataFrame
features : 1757
extent : -46.58056, 71.00404, -158.0419, 174.9681 (xmin, xmax, ymin, ymax)
crs : +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0
variables : 3
names : WINDFARM_NAME, LATITUDE, LONGITUDE
min values : 'A_Farrapa', -46.58056, -158.04192
max values : 'Zuromin', 71.00404, 174.9681
Spatial Data Frame has a longer extent, but there are points into RasterLayer.
But it does not work :(.
> my<-extract(lat41_42_sp,spdf)
> my[1:10]
[1] NA NA NA NA NA NA NA NA NA NA
> head(my)
[1] NA NA NA NA NA NA
> tail(my)
[1] NA NA NA NA NA NA