使用R将栅格图像从等矩形投影到latlon [英] Reproject Raster Image from equirectagular to latlon using R

查看:281
本文介绍了使用R将栅格图像从等矩形投影到latlon的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试将光栅图像从Equirectangular重新投影到EPSG:4326(Latlon),问题是每次在R上运行代码时,新图像上的坐标都错误;我不知道代码中的错误在哪里,我也使用Qgis执行相同的过程,并且得到相同的结果,这很奇怪,我有机会在ENVI中执行相同的重新投影过程,并且结果成功了,请帮忙!!!

Hi i been trying to reproject a raster image from Equirectangular to EPSG:4326 (Latlon), the issue is that every time i run my code on R, i get the wrong coordinates on the new image; i don´t know where is the error in the code, also i do the same process with Qgis, and i got the same result, it´s strange, i got the opportunity to do the same reprojection process in ENVI, and the result was succesful, help please!!!

a <- raster("C:/Users/<username>/Documents/imageexample.tif")
> a
class       : RasterLayer 
dimensions  : 1800, 1800, 3240000  (nrow, ncol, ncell)
resolution  : 1100, 1100  (x, y)
extent      : -988900, 991100, 1677577, 3657577  (xmin, xmax, ymin, ymax)
coord. ref. : +proj=eqc +lat_ts=0 +lat_0=24 +lon_0=-112 +x_0=0 +y_0=0 +datum=WGS84 +units=m +no_defs +ellps=WGS84 +towgs84=0,0,0
data source : C:/Users/<username>/Documents/imageexample.tif
names       : imageexample

g1 <- projectRaster(a, crs="+init=epsg:4326")
> g1
class       : RasterLayer 
dimensions  : 1810, 1810, 3276100  (nrow, ncol, ncell)
resolution  : 0.00988, 0.00988  (x, y)
extent      : -120.9328, -103.05, 39.02317, 56.90597  (xmin, xmax, ymin, ymax)
coord. ref. : +init=epsg:4326 +proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs +towgs84=0,0,0 
data source : in memory
names       : imageexample.tif 
values      : -5.000117, 39.87529  (min, max)

正确的坐标应如下所示:

The correct coordinates should be like this:

    class       : RasterLayer 
dimensions  : 1793, 1803, 3232779  (nrow, ncol, ncell)
resolution  : 0.0108098, 0.009931556  (x, y)
extent      : -121.735, -102.245, 15.08612, 32.8934  (xmin, xmax, ymin, ymax)
coord. ref. : +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0 
data source : C:/Users/<username>/Documents/CORRECTimageexample.tif 
names       : CORRECTimageexample

谢谢!

推荐答案

这是一个特例,但通常没有(通过数据)定义栅格重投影的范围和分辨率.您需要指定这些.例如,您可以执行以下操作:

This is a bit of a special case but generally there is not defined (by the data) extent and resolution for raster reprojection. You need to specify these. For example, you can do:

library(raster)
r <- raster(xmn=-121.735, xmx=-102.245, ymn=15.08612, ymx=32.8934, nrow=1793, ncol=1803, crs='+proj=longlat +ellps=WGS84')
g2 <- projectRaster(a, r)

这篇关于使用R将栅格图像从等矩形投影到latlon的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆