[R-sig-Geo] Error using extract() for raster - NAs are not allowed as part of subscripted assignments
sfranks
samantha.franks at bto.org
Wed May 14 13:52:57 CEST 2014
Hi,
I'm trying to extract data from the Europe CORINE land cover raster.
> r
class : RasterLayer
dimensions : 46000, 59000, 2.714e+09 (nrow, ncol, ncell)
resolution : 100, 100 (x, y)
extent : 1500000, 7400000, 9e+05, 5500000 (xmin, xmax, ymin, ymax)
coord. ref. : +proj=laea +lat_0=52 +lon_0=10 +x_0=4321000 +y_0=3210000
+ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs
data source : C:\Users\samf\Documents\Git\cuckoos\data\corine raster
100x100\g100_06.tif
names : g100_06
values : 0, 255 (min, max)
I have 3 spatial polygons for which I want to extract raster values.
> randomstop
class : SpatialPolygons
features : 3
extent : 2997503, 3946661, 1857532, 3090567 (xmin, xmax, ymin, ymax)
coord. ref. : +init=epsg:3035 +proj=laea +lat_0=52 +lon_0=10 +x_0=4321000
+y_0=3210000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs
When I try to extract, I get the following error message:
> extract(r, randomstop)
Error in .readCellsGDAL(x, uniquecells, layers) :
NAs are not allowed in subscripted assignments
I have extracted each polygon separately, and I know which one is causing
the error. When I create a new raster using crop() to the same extent as
the problem polygon, it extracts fine. Also, when I crop r to the extent of
randomstop (all 3 polygons), it also extracts fine. But there doesn't seem
to be an obvious problem with the extent of r in relation to the extent of
randomstop.
> extent(r)
class : Extent
xmin : 1500000
xmax : 7400000
ymin : 9e+05
ymax : 5500000
> extent(randomstop)
class : Extent
xmin : 2997503
xmax : 3946661
ymin : 1857532
ymax : 3090567
I can build crop() into the code to solve the problem and extract my values,
but I'm still mystified as to what the root cause of the error is.
Thanks in advance,
Samantha
--
View this message in context: http://r-sig-geo.2731867.n2.nabble.com/Error-using-extract-for-raster-NAs-are-not-allowed-as-part-of-subscripted-assignments-tp7586434.html
Sent from the R-sig-geo mailing list archive at Nabble.com.
More information about the R-sig-Geo
mailing list