将地理图层与R中的不同投影结合起来 [英] Combining geographic layers with different projections in R

查看:105
本文介绍了将地理图层与R中的不同投影结合起来的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对标题问题进行了略微的措辞,并调整了文字以回复@DWin的评论.

I have reworded the title question slightly, and adjusted the text to respond to the comment by @DWin.

要组合已投影和未投影的地理图层可能会很困难.似乎经常需要进行一些转换,因为地理层来自不同的产品和发布者.

Combining geographic layers that are projected and not projected can be challenging. Often, it seems, some transformation is necessary, as geographic layers come from different products and publishers.

我知道R有几种工具可以执行地理转换.例如:

I am aware that R has several tools to perform geographic transformations. For example:

  1. 对于sp包中的Spatial*类的对象,可以使用rgdal包中的spTransform()函数.并且,
  2. 对于raster包中的类Raster*的对象,可以使用projectRaster()函数.
  1. For objects of class Spatial* in the sp package, the spTransform() function in the rgdal package can be used; and,
  2. For objects of class Raster* in the raster package, the projectRaster() function can be used.

这是我要在R中完成的一项特定任务:将UTM网格15N(基准:NAD27)投影中的湖泊的多边形图层转换为UTM网格15N(基准:NAD83). ESRI shapefile格式).

Here is a specific task that I would like to accomplish in R: Transform to UTM grid Zone 15N (Datum: NAD83) a polygons layer describing lakes in a UTM grid Zone 15N (Datum: NAD27) projection (this is in an ESRI shapefile format).

推荐答案

这里有用的是rgdal中包含的epsg数据库.

The useful thing here is the epsg database included in rgdal.

epsgs = make_EPSG()
subset(epsgs,grepl("15N",epsgs$note))

[etc]
      code
2703 26715                         # NAD27 / UTM zone 15N  [etc]
2851 26915                         # NAD83 / UTM zone 15N  [etc]
[etc]

这些代码是您在spTransform中所需要的.如果您的湖泊位于带有该NAD27投影的shapefile中,则:

Those codes are what you need in spTransform. If your lakes are in a shapefile with that NAD27 projection, then:

require(maptools)
lakes = readShapeSpatial("lakes.shp")
proj4string(lakes)=CRS("+init=epsg:26715")

应该提供所提供的湖泊(请注意,我不认为readShapeSpatial将读取带有shapefile设置的.prj文件,因此我已在此处进行了明确设置)

should give you the lakes as supplied (note I dont think readShapeSpatial will read a .prj file with a shapefile set, so I've set it here explicitly)

现在要转换为UTM区域15N的NAD83基准版本:

Now to convert to NAD83 datum version of UTM zone 15N:

lakes83 = spTransform(lakes,CRS("+init=epsg:26915"))

栅格有点棘手,因为它们通常会涉及扭曲,因此您最终会在投影坐标系中得到规则的网格-您不能只变换角点的坐标...

Rasters are a bit trickier since they generally involve a warp so that you end up with a regular grid in your projected coordinate system - you can't just transform the coordinates of the corners...

这篇关于将地理图层与R中的不同投影结合起来的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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