I took a sample of a spatial polygon dataframe with 2256 elements using:

valdata <- ref_10[sample(ref_10@data$ID, length(ref_10)/3),]

now I would like to sort my new spatial dataframe by my ID-colum and always get this error message:


Error in valdata[sort(valdata@data$ID), ] : cannot get a slot ("Polygons") from an object of type "NULL"

  • ID wasn't included, just wrap the sample in sort() – mdsumner Oct 4 '16 at 11:59


valdata<-ref_10[which(ref_10@data$ID %in% sample(ref_10@data$ID, length(ref_10)/3)),]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.