【问题标题】:How to change projection and convert shapefile to rasterstack in R?如何在 R 中更改投影并将 shapefile 转换为 rasterstack?
【发布时间】:2015-10-13 13:57:42
【问题描述】:

我有一个来自同事的地图 shapefile,我还获得了一些观测数据,它们的坐标记录在 WGS84 中。我在 R 中阅读了 shapefile:

# read shapefile
> shpmap <- readOGR(dsn = "soil_type", layer = "soil_type_data")
OGR data source with driver: ESRI Shapefile 
Source: "soil_type", layer: "soil_type_data"
with 18542 features
It has 8 fields

# show shapefile attributes
> shpmap
class       : SpatialPolygonsDataFrame 
features    : 18542 
extent      : 44795.53, 1572888, 3187943, 4661428  (xmin, xmax, ymin, ymax)
coord. ref. : +proj=aea +lat_1=25 +lat_2=47 +lat_0=0 +lon_0=105 +x_0=0 +y_0=0 +ellps=krass +units=m +no_defs

阅读 shapefile 后,我发现它使用的是 krassovsky ellps。现在我想做两件事。首先,更改 shapefile 的投影以匹配我的观察结果 WGS84。其次,shapefile 包含几个土壤属性,我想将它们转换为 rasterstack 对象。

我是在 R 中处理 GIS 文件的新手,我真的很困惑。我将不胜感激任何建议!提前致谢!

【问题讨论】:

  • 你需要spTransform()rasterize()
  • 谢谢!我已经按照您的建议解决了!

标签: r projection raster


【解决方案1】:

使用spTransform 更改crs。

library(rgdal)
g <- spTransform(shpmap, CRS("+proj=longlat +datum=WGS84"))

您可以使用rasterize(光栅包)创建一个RasterBrick(堆栈)

【讨论】:

  • 谢谢!已经解决了。对于栅格化部分,我将每个属性转换为单个栅格对象,然后将stack 它们转换为 rasterstack 对象。
  • 这行得通,但一步光栅化所有属性可能更有效(不要提供field 参数);然后在结果上使用deratify 创建一个RasterBrick
猜你喜欢
  • 2017-02-20
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-01-15
  • 2019-03-05
  • 2014-07-06
  • 2018-12-19
  • 2014-10-07
相关资源
最近更新 更多