小编Mik*_*keM的帖子

计算一个点和英国海岸之间的最小距离

我一直在遵循此处显示的示例,但适用于英国。出于这个原因,我使用 EPSG:27700 的英国 CRS,它具有以下投影字符串:

"+proj=tmerc +lat_0=49 +lon_0=-2 +k=0.9996012717 +x_0=400000 +y_0=-100000 +ellps=airy +datum=OSGB36 +units=m +no_defs"
Run Code Online (Sandbox Code Playgroud)

但是,我不确定要遵循的 wgs.84 代码。目前我正在使用:

"+proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0"
Run Code Online (Sandbox Code Playgroud)

还尝试使用 datum=OSGB36 和 +ellps=airy 。

完整代码如下:

library(rgeos)
library(maptools)
library(rgdal)

epsg.27700 <- '+proj=tmerc +lat_0=49 +lon_0=-2 +k=0.9996012717 +x_0=400000 +y_0=-100000    +ellps=airy +datum=OSGB36 +units=m +no_defs'
wgs.84    <- '+proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0'

coast <- readShapeLines("ne_10m_coastline",CRS(wgs.84)) #have tried other shapefiles with the same issue
MAD   <- readWKT("POINT(-0.1830372 51.1197467)",p4s=CRS(wgs.84)) #Crawley, West Sussex
gDistance(MAD,coast)

[1] 0.28958
Warning messages:
1: In RGEOSDistanceFunc(spgeom1, spgeom2, byid, …
Run Code Online (Sandbox Code Playgroud)

gis r spatial

4
推荐指数
1
解决办法
1494
查看次数

标签 统计

gis ×1

r ×1

spatial ×1