I have a CSV-list of coordinates that I know are coordinates in Gauß-Krüger (Transverse Mercator) and I want to transform them to UTM in R with GDAL.
I read the csv in, separated the columns, added the original source proj4string while creating a SpatialPoints object. Then I tried to transform the data with ogr2ogr but always get the error message:
"Error in as.character.default(new("SpatialPoints", coords = c(3480702.68, : no method for coercing this S4 class to a vector"
library(gdalUtils)
library(rgdal)
library(rgeos)
library(sp)
ExamplePoints <- read.csv2("C:/Users/Desktop/Test.csv", header = TRUE,
dec = ",")
points_SRC <- ExamplePoints[3:4]
ExamplePoints_SRC <- SpatialPoints(points_SRC,
proj4string=CRS("+proj=tmerc +lat_0=0 +lon_0=9 +k=1 +x_0=3500000 +y_0=0
+ellps=bessel +towgs84=598.1,73.7,418.2,0.202,0.045,-2.455,6.7 +units=m
+no_defs"))
Transform_test <- ogr2ogr(src_datasource_name = ExamplePoints_SRC,
dst_datasource_name = "C:/Users/Desktop/Test.shp", f = "ESRI
Shapefile", t_srs = "+proj=tmerc +lat_0=0 +lon_0=9 +k=0.9996
+x_0=32500000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m
+no_defs", s_srs = "+proj=tmerc +lat_0=0 +lon_0=9 +k=1 +x_0=3500000
+y_0=0 +ellps=bessel +towgs84=598.1,73.7,418.2,0.202,0.045,-2.455,6.7
+units=m +no_defs", a_srs= "EPSG:4647")
I do not understand the error message. What kind of input does ogr2ogr expect instead? I could not get an answer to this until now unforunately.
Did anyone experience a similar error or does understand what GDAL wants instead?
This is how the CSV file looks like in the editor (the decimal separator is ',' and the column separator is ';' :
point number;source CRS;x;y;target CRS;x;y
1;31467;3480702,68;5380141,08;4647;32480635,05;5378428,48
2;31467;3516958,39;5423993,28;4647;32516876,30;5422263,10
3;31467;3533028,71;5384162,09;4647;32532940,13;5382447,91
4;31467;3504712,87;5405841,58;4647;32504635,69;5404118,72
This is the table of coordinates before the making a SpatialPoint object out of it: