1

I want to prepare a dataset to make a variogram. But it doesn't work. How can I make a spatialpoints dataset of the x and y column, that are non-numeric?

library(sp)
head(data)   

   x       y    R
   3695.99 1713.02 1.85
   2    3696.99 1712.98 1.32
   3    3697.99 1712.95 0.92
   4    3699.02 1713.05 0.70
   5    3700.02 1713.01 0.44
   6    3701.02 1712.97 0.26



   > coordinates(data) <- ~ x + y
  Error in .local(obj, ...) : 
   cannot derive coordinates from non-numeric matrix
  • Possible duplicate of [Create SpatialPointsDataframe](https://stackoverflow.com/questions/32583606/create-spatialpointsdataframe) – Rich Pauloo Apr 15 '19 at 15:29
  • 'coordinates(df1) <- ~ lng + lat' is not working – user9931361 Apr 15 '19 at 15:38
  • What packages are you using? Where do you expect the function `coordinates` to come from, since the error you show is that that function can't be found? – camille Apr 15 '19 at 15:40
  • @user9931361, welcome to SO! I encourage you to see [this link](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) for guidelines on writing a question that has the highest likelihood of being answered. Your error message indicates that you have non-numeric coordinates in x or y. Try `class(data$x)` and `class(data$y)` to verify that your data are numeric. – Rich Pauloo Apr 15 '19 at 15:42
  • > class(data$x) gives [1] "factor"" – user9931361 Apr 15 '19 at 15:54
  • Do you have suggestions? – user9931361 Apr 17 '19 at 14:07

0 Answers0