r - 使用带有投影坐标系的 dist2isobath 函数(marmap 包)时出现问题
问题描述
我有一个在投影坐标系(WGS84 区域 30N)中创建的网格,我正在尝试使用包 marmap 中的函数“dist2isobath”提取网格的所有单元到海岸和其他等深线的最小距离.
为此,我将 ETOPO1 数据(海洋测深)重新投影到与我的网格数据相同的投影,然后使用“dist2isobath”功能,但它给了我一个错误。显然它只适用于地理(见下面的错误)。你知道我该如何解决它,或者它是否是另一个处理投影数据的函数?
这是我使用的脚本和错误:
head(grid) # example of my data points
Lon Lat
1 -124195.7 4986652
2 -120195.7 4986652
3 -116195.7 4986652
4 -112195.7 4986652
5 -108195.7 4986652
6 -104195.7 4986652
summary(etopo1) # ETOPO1 already reprojected and converte to class "bathy" object
# Bathymetric data of class 'bathy', with 1329 rows and 709 columns
# Latitudinal range: 4306614.28 to 5618264.28 (4306614.28 N to 5618264.28 N)
# Longitudinal range: -550748.25 to 1203531.75 (550748.25 W to 1203171.75 E)
# Cell size: 79258.1 minute(s)
# Depth statistics:
# Min. 1st Qu. Median Mean 3rd Qu. Max. NA's
# -5586.23 -4004.18 -99.56 -1392.81 244.61 2928.77 141413
# First 3 columns and rows of the bathymetric matrix:
# 4306614.27700283 4308466.88999718 4310319.50299153
# -550748.253167697 NA NA NA
# -549427.259191793 NA NA NA
# -548106.265215889 NA NA NA
## Try to obtain the closest distance to the coast
DistCoast <- dist2isobath(etopo1, grid[,1:2], isobath=0)
Error in .pointsToMatrix(p) : longitude < -360
解决方案
在后台,dist2isobath()
使用包中的dist2Line()
函数geosphere
,该函数依赖于pointsToMatrix()
同一包中的函数(请参见此处的代码)。pointsToMatrix()
期望点是未投影的。
所以我认为你所要做的就是删除你的点的投影,而不是投影你从 etopo1 获得的 batymetry。etopo1 的基准已经是 WGS84,并且dist2isobath()
设计用于使用它:您只能使用未投影数据获得准确的距离计算。
推荐阅读
- neural-network - 使用 RNN 对组进行二元分类
- python - 在多列中查找相同的值
- c++ - 从迭代器中选择的函数类型成员变量
- python - 使用阈值查找黑色像素的数量
- r - 将直线阴影误差映射到 coord_polar 图
- r - 在 R 中并行化逐像素回归
- c# - 如何使 FtpWebResponse 异步
- firebase - Firestore 规则和自定义声明
- flutter - Pods/LFLiveKit/LFLiveKit/Vendor/pili-librtmp/rtmp.c:684:30:警告:从“const char *”分配给“char *”会丢弃限定符
- django - Django 信号未执行