I have been trying to create an empty SpatialPoints in R but have not found the way yet.
I have tried with this formula:
SpatialPoints(as.matrix(data.table(x = numeric(), y = numeric())))
But it didn't work. The closest thing I have found on the internet is Creating empty Polygons or SpatialPolygons in R? but that is for polygons and apparently it does not work the same way.
I have sp version 1.2.7
for
loop to incrementally add points to, you might be better off using anapply
-type operation and then combining the results in the end - this is usually faster than growing a vector from an empty object.