3

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:

valdata[sort(valdata@data$ID),]

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

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

1 Answer 1

3

Try

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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