Skip to content
Prev 16123 / 29559 Next

Latitude Longitude to SPDF

Or you can use the coordinates() function:

library(sp)
loc <- data.frame(x=c(23.1,19.0),y=c(43.2,45.5),value=c(200,100))
coordinates(loc) = c("x","y")

Applied on a data.frame it returns a SpatialPointsDataFrame object.
If you are going to use it with other spatial data, make sure to define
the data projection using proj4string().