I have a point coordinate dataset in the UTM 48 zone.
xy 615028.3 2261614 615016.3 2261635 614994.4 2261652
The CSV file is here .
I would like to load a CSV and create a form file using R. My code:
library(maptools) library(rgdal) library(sp) UTMcoor=read.csv(file="https://dl.dropboxusercontent.com/u/549234/s1.csv") coordinates(UTMcoor)=~X+Y proj4string(UTMcoor)=CRS("++proj=utm +zone=48") # set it to UTM LLcoor<-spTransform(UTMcoor,CRS("+proj=longlat")) #set it to Lat Long plot(LLcoor) points(LLcoor$X,LLcoor$Y,pch=19,col="blue",cex=0.8) #to test if coordinate can be plot as point map writeOGR(UTMcoor, dsn="c:/todel" ,layer="tsb",driver="ESRI Shapefile") writeSpatialShape("LLcoor","test")
The last command (writeSpatialShape) R produces the following error:
Error in writeSpatialShape("LL2", "test") : x is acharacterobject, not a compatible Spatial*DataFrame
When I read LLcoor from the console, it seems that this is already a spatial DataFrame. Writing a form file using writeOGR (RGdal package) also gives a similar error. Any hints are welcome.
source share