Konvertiert die Koordinatentabelle mit R in eine Formdatei
Ich habe einen Datensatz mit Punktkoordinaten in der UTM-Zone 48.
x y
615028.3 2261614
615016.3 2261635
614994.4 2261652
Die CSV-DateiHier.
Ich möchte die CSV-Datei laden und mit R ein Shapefile erstellen. Mein Code lautet:
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")
Geben Sie im letzten Befehl (writeSpatialShape) R den folgenden Fehler ein:
Error in writeSpatialShape("LL2", "test") :
x is acharacterobject, not a compatible Spatial*DataFrame
Während ich den LLcoor von der Konsole aus lese, scheint es sich bereits um einen Spatial DataFrame zu handeln. Das Schreiben einer Formdatei mit writeOGR (RGdal-Paket) führt ebenfalls zu einem ähnlichen Fehler. Jeder Hinweis wird sehr geschätzt.