Home > Mobile >  How can I convert metric units of spacial object in R to degree decimal?
How can I convert metric units of spacial object in R to degree decimal?

Time:05-16

I have SpatialPointsDataFrame object loaded in R with with extent in meters. I want them to convert into degree decimals. Please help how can I do that.

Below is how my data looks in console:

class       : SpatialPointsDataFrame 
features    : 23 
extent      : 351912.5, 457807, 3236835, 3367232  (xmin, xmax, ymin, ymax)
crs         :  proj=utm  zone=44  datum=WGS84  units=m  no_defs 
variables   : 1
names       : Id 
min values  :  0 
max values  :  0 

I want to convert them as my rasterStack object which has extent as below:

class      : RasterStack 
dimensions : 7554, 8341, 63007914, 2  (nrow, ncol, ncell, nlayers)
resolution : 0.0002777778, 0.0002777778  (x, y)
extent     : 78.72589, 81.04284, 28.70956, 30.80789  (xmin, xmax, ymin, ymax)
crs        :  proj=longlat  datum=WGS84  no_defs 
names      : dem_kumaun1,       slope 
min values :      -32768,           0 
max values : 32767.00000,    88.75196 

please help guys!

CodePudding user response:

Use spTransform function

new_shp <- spTransform(old_shp, CRS(" proj=longlat  datum=WGS84"))

CodePudding user response:

Following code worked fro me.

transformed_shapefile <- spTransform(SpatialPointsDataFrame , CRS(RasterStack@crs@projargs))

  • Related