How to convert WGS84 to NAD83 using R?
Is there a way to "convert IMG format image from WGS84 to NAD83" using R programming ?
Input image:
Name: LST_2011-03-30_WGS.img
Format: IMG (ERDAS)
Projection: UTM, Zone 12
Spheroid: WGS 84
Datum: WGS 84
Output Image:
Name: LST_2011-03-30_NAD.img
Format: IMG (ERDAS)
Projection: UTM, Zone 12
Spheroid: GRS 1980
Datum: NAD 83
source to share
You can use a package gdalUtils
that assumes the user has a working GDAL on their system. If gdalUtils_gdalPath is set (usually using gdal_setInstallation), the GDAL found in that path will be used. If nothing is found, gdal_setInstallation will be executed to try to find a working GDAL that has the correct drivers as specified by the "of" parameter (output format).
Read more on inside-r.org .
Here the function gdalwarp()
works like this:
gdalwarp(srcfile="/your/path/LST_2011-03-30_WGS.img", #source file
dstfile="/your/path/LST_2011-03-30_NAD.img", #destination file
s_srs="+proj=utm +zone=12 +datum=WGS84 +no_defs +ellps=WGS84", #input spatial reference
t_srs="+proj=utm +zone=12 +datum=NAD83 +no_defs +ellps=GRS80") #output spatial reference
Nb: Since I don't have your images, I couldn't be sure that it actually works with the above parameters. However, I tested it with a different .tif raster and other spatial reference systems and it worked.
source to share
You can do it
library(raster)
r <- raster('LST_2011-03-30_WGS.img')
## crs is normally defined, see
r
## but if it is not, you can set it
## crs(r) <- "+proj=utm +zone=12 +datum=WGS84 +no_defs +ellps=WGS84"
# set up an output RasterLayer
x <- raster(r)
crs(x) <- "+proj=utm +zone=12 +datum=NAD83 +no_defs +ellps=GRS80"
# compute
x <- projectRaster(r, x)
source to share