【问题标题】:Reproject Raster Image from equirectagular to latlon using R使用 R 将光栅图像从 equirectagular 重新投影到 latlon
【发布时间】:2013-09-23 23:28:30
【问题描述】:

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

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)

正确的坐标应该是这样的:

    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

谢谢!!!

【问题讨论】:

标签: r raster geotiff epsg reprojection-error


【解决方案1】:

这是一种特殊情况,但通常(由数据)没有定义光栅重投影的范围和分辨率。您需要指定这些。例如,您可以这样做:

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)

【讨论】:

  • 嗨@RobertH,很抱歉回答迟了,我尝试用 projectraster 重新投影光栅图像,但我得到的图像只有 NA 值,可能我 dping 出了点问题,这就是我所做的@987654322 @r &lt;- raster(xmn=-121.735, xmx=-102.245, ymn=15.08612, ymx=32.8934, nrow=1793, ncol=1803, crs='+proj=longlat +ellps=WGS84')g2&lt;- projectRaster(a, r)rf &lt;- writeRaster(l, filename="imageresult.tif", format="GTiff", overwrite=TRUE)我发现+lat_ts=0和+lat_0=24在文件上倒置了,gdal纠正了问题,但是R不能
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2018-12-10
  • 1970-01-01
  • 2011-11-12
  • 2013-02-19
  • 2014-05-24
  • 1970-01-01
  • 2015-05-31
相关资源
最近更新 更多