mardi 21 novembre 2017

Worldclim database is not working for random samples

I have a raster with a forest cover of one area

    class       : RasterLayer 
dimensions  : 5436, 2633, 14312988  (nrow, ncol, ncell)
resolution  : 100, 100  (x, y)
extent      : -109346.5, 153953.5, -290837.1, 252762.9  (xmin, xmax, ymin, ymax)
coord. ref. : +proj=tmerc +lat_0=39.66825833333333 +lon_0=-8.133108333333334 +k=1 +x_0=0 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs 
data source : c://Total_Forest_cove
names       : Total_Forest_cove

with values from 0 to 3 I want to create a dataset with random samples from the pixels with values higher than 0.

For that I do

values(Forestcover)[values(Forestcover) < 1] = NA
randompoints <- sampleRandom(Forestcover, size = 10, sp=TRUE, na.rm=TRUE)
plot(Forestcover, axes=FALSE, legend=FALSE)
randompoints <- cbind(randompoints@coords)

when I try to pull out the enviromental variables form worldclim

randpoints_wc <- extract(worldclim, randompoints)
randpoints_wc <- cbind(randompoints, randpoints_wc) 

My dataset is always empty

Not sure if there is other method to extract random that can be apply here.

Regards




Aucun commentaire:

Enregistrer un commentaire