r - 在 rgdal R 中使用 spTransform 重新投影空间点时出错

标签 r spatial projection coordinate-systems rgdal

你好,
我在 CRS 澳大利亚大地基准 66/84(简称 AGD66)中有大量经/纬度坐标。我想将这些坐标从 AGD66 更改为 WGS84,因为它们之间存在大约 200m 的差异,并且我在 WGS84 中有其他坐标和图层。我试图通过以下方式做到这一点:

lon        lat
147.1428   -43.49083

library(rgdal)
pts<-read.table(file.choose(),header=TRUE,sep=',')  
# I first project the pts in their original CRS
pts66<-project(cbind(pts$lon,pts$lat), "+init=epsg:4202")
# Then to transform it to WGS84
pts84 = spTransform(pts66,CRS("+init=epsg:3033"))

Error in function (classes, fdef, mtable)  : 
unable to find an inherited method for function "spTransform", for signature "matrix", "CRS"

有谁知道我为什么会收到此错误或对如何将这些坐标从 AGD66 更改为 WGS84 有任何建议?提前感谢您的帮助。

干杯,
亚当

最佳答案

我删除了部分错误答案

函数 project() 不能进行数据转换,所以你可能在那里遇到了问题,我认为你的问题是错误的。

问题是你只能在 WGS84 上从/到 longlat project(),所以你第一次使用 project 是不正确的。如果我猜对了,您的坐标在 AGD66 中,因此您必须首先分配该投影,然后才能进行变换。您不能使用 project() 进行数据转换,但 spTransform() 可以。

我想你需要这个:

pts = read.table(text = "lon        lat
147.1428   -43.49083", header = TRUE)

## assign original coordinate system
pts66 = SpatialPoints(cbind(pts$lon,pts$lat), CRS("+init=epsg:4202"))

## Then to transform it to WGS84
pts84 = spTransform(pts66, CRS("+init=epsg:3033"))


pts66
SpatialPoints:
     coords.x1 coords.x2
[1,]  147.1428 -43.49083
Coordinate Reference System (CRS) arguments: +init=epsg:4202 +proj=longlat +ellps=aust_SA
+no_defs 

pts84
SpatialPoints:
     coords.x1 coords.x2
[1,]  11126605   2971806
Coordinate Reference System (CRS) arguments: +init=epsg:3033 +proj=lcc +lat_1=-68.5     +lat_2=-74.5
+lat_0=-50 +lon_0=70 +x_0=6000000 +y_0=6000000 +ellps=WGS84 +datum=WGS84 +units=m +no_defs
+towgs84=0,0,0 

这意味着 pts66 的原始值没有改变,但它们具有正确的元数据,可用于下一步将它们转换为您的目标(顺便说一句,兰伯特共形圆锥曲线)。您可能需要进行更多调查才能弄清楚需要什么。

CRS("+init=epsg:4202")
CRS arguments:
+init=epsg:4202 +proj=longlat +ellps=aust_SA +no_defs 

CRS("+init=epsg:3033")

CRS arguments:
+init=epsg:3033 +proj=lcc +lat_1=-68.5 +lat_2=-74.5 +lat_0=-50
+lon_0=70 +x_0=6000000 +y_0=6000000 +ellps=WGS84 +datum=WGS84 +units=m
+no_defs +towgs84=0,0,0 

您的原始 project() 错误地尝试从 WGS84 上的 longlat 转换为 AGD66 上的 longlat,但该函数无法做到这一点,因此它只是在混合中增加了困惑。基准不是投影,它是投影定义的关键部分,从这个意义上说,“AGD66 上的 longlat”是一个投影,就像“WGS84 上的 Lambert Conformal Conic”一样。

关于r - 在 rgdal R 中使用 spTransform 重新投影空间点时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9974785/

相关文章:

java - 如何为 OrientDB (2.2.x) 的空间模块创建索引?

r - 使用 R 中的 NA 计算栅格数据的变异函数

c# - 有什么方法可以使用 LINQ 查询来投影 "original plus a few changes"?

android - 在增强现实应用程序中变换屏幕上的纬度、经度位置

r - 在 gamm4 R 封装中进行 GAM-GEE?

spring - 使用 Spring 数据和 QueryDSL 在 MongoDb 查询上进行投影

mysql - 从 R 插入 MySQL

R 监督潜在狄利克雷分配包

r - 了解剪切输出

r - 使用 data.table 的垂直条件创建一个新列