TAW
TAW

Reputation: 11

Convert UTM to decimal degree in R

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

Answers (1)

Elio Diaz
Elio Diaz

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

Related Questions