I have three rasters for the same geographical location loaded in R.
> ndvi
class : RasterLayer
dimensions : 1138, 1171, 1332598 (nrow, ncol, ncell)
resolution : 30, 30 (x, y)
extent : 766867.4, 801997.4, 1420228, 1454368 (xmin, xmax, ymin, ymax)
coord. ref. : +proj=utm +zone=43 +datum=WGS84 +units=m +no_defs +ellps=WGS84
+towgs84=0,0,0
data source : in memory
names : layer
values : -0.4103095, 0.7972555 (min, max)
> temp_celsius_lst
class : RasterLayer
dimensions : 1138, 1171, 1332598 (nrow, ncol, ncell)
resolution : 30, 30 (x, y)
extent : 766867.4, 801997.4, 1420228, 1454368 (xmin, xmax, ymin, ymax)
coord. ref. : +proj=utm +zone=43 +datum=WGS84 +units=m +no_defs +ellps=WGS84
+towgs84=0,0,0
data source : in memory
names : layer
values : 21.56528, 40.01204 (min, max)
> landuse_raster
class : RasterLayer
dimensions : 1138, 1171, 1332598 (nrow, ncol, ncell)
resolution : 30, 30 (x, y)
extent : 766867.4, 801997.4, 1420228, 1454368 (xmin, xmax, ymin, ymax)
coord. ref. : +proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0
data source : in memory
names : layer
values : 0.93, 0.98 (min, max)
I also have a polygon layer as follows.
> urbangreen_buffer
class : SpatialPolygonsDataFrame
features : 884
extent : 774055.5, 791282.7, 1421905, 1446710 (xmin, xmax, ymin, ymax)
coord. ref. : +proj=utm +zone=43 +datum=WGS84 +units=m +no_defs +ellps=WGS84
+towgs84=0,0,0
variables : 6
names : Id
min values : 1
max values : 9
What i am trying to do is extract data from the raster that intersect with the polygon regions. I use the following code:
extract(ndvi, urbangreen_buffer)
extract(temp_celsius_lst, urbangreen_buffer)
extract(landuse_raster, urbangreen_buffer)
It works for the ndvi and temp_celsius_lst rasters. The code returns a list with 884 elements with each element having values of all pixels in the raster that lie within the corresponding polygon.
However, the code for the landuse_raster just returns a list with 884 elements filled with NULL values. I am unable to figure out a reason for the same. Any help would be greatly appreciated.
I'd even be fine if there any any alternate methods of extraction that return all pixel values for the polygons.
Regards,