Reputation: 11
I am using the following code in R to convert my UTM coordinates to decimal degrees
utmcoor<-SpatialPoints(cbind(starling2$Easting,starling2$Northing), proj4string=CRS("+proj=utm +zone=51"))
longlatcoor<-spTransform(utmcoor,CRS("+proj=longlat"))
how to I add the results ('latlongcoor' output) as two new columns in my original dataframe 'starling2'?
Upvotes: 1
Views: 4339
Reputation: 600
In a SpatialPointsDataFrame the coordinates behave like the "rownames" for your data:
starling2$X <- coordinates(longlatcoor)[,1]
starling2$y <- coordinates(longlatcoor)[,2]
Upvotes: 1