- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我一直在关注显示的示例 here ,但对于英国。出于这个原因,我使用 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"
"+proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0"
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, "rgeos_distance") :
Spatial object 1 is not projected; GEOS expects planar coordinates
2: In RGEOSDistanceFunc(spgeom1, spgeom2, byid, "rgeos_distance") :
Spatial object 2 is not projected; GEOS expects planar coordinates
3: In RGEOSDistanceFunc(spgeom1, spgeom2, byid, "rgeos_distance") :
spgeom1 and spgeom2 have different proj4 strings
coast.proj <- spTransform(coast,CRS(Epsg.27700))
non finite transformation detected:
[1] 111.01051 19.68378 Inf Inf
Error in .spTransform_Line(input[[i]], to_args = to_args, from_args = from_args, :
failure in Lines 22 Line 1 points 1
In addition: Warning message:
In .spTransform_Line(input[[i]], to_args = to_args, from_args = from_args, :
671 projected point(s) not finite
最佳答案
AFAICT 你没有做错任何事。错误消息告诉您,全局海岸线 shapefile 中的某些坐标映射到 Inf
.我不确定为什么会发生这种情况,但通常期望特定区域的平面投影在全局范围内起作用并不是一个好主意(尽管它确实在另一个问题中起作用......)。一种解决方法是将海岸线 shapefile 裁剪到特定投影的边界框,然后转换裁剪后的 shapefile。 EPSG.27700 的边界框可以在 here 中找到.
# use bounding box for epsg.27700
# found here: http://spatialreference.org/ref/epsg/osgb-1936-british-national-grid/
bbx <- readWKT("POLYGON((-7.5600 49.9600, 1.7800 49.9600, 1.7800 60.8400, -7.5600 60.8400, -7.5600 49.9600))",
p4s=CRS(wgs.84))
coast <- gIntersection(coast,bbx) # just coastlines within bbx
# now transformation works
coast.proj <- spTransform(coast,CRS(epsg.27700))
MAD.proj <- spTransform(MAD,CRS(epsg.27700))
dist.27700 <- gDistance(MAD.proj,coast.proj) # distance in sq.meters
dist.27700
# [1] 32153.23
# identify the closest point
th <- seq(0,2*pi,len=1000)
circle <- cbind(1.00001*dist.wgs84*cos(th)+MAD$x,1.00001*dist.wgs84*sin(th)+MAD$y)
sp.circle <- SpatialLines(list(Lines(list(Line(circle)),ID="1")),proj4string=CRS(wgs.84))
sp.pts <- gIntersection(sp.circle,coast)
sp.pts
# SpatialPoints:
# x y
# 1 -0.2019854 50.83079
# 1 -0.1997009 50.83064
# Coordinate Reference System (CRS) arguments: +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0
# plot the results: plot is in CRS(wgs.84)
plot(coast, asp=1)
plot(bbx,add=T)
plot(MAD,add=T, col="red", pch=20)
plot(sp.circle,add=T, col="blue", lty=2)
lines(c(MAD$x,sp.pts$x),c(MAD$y,sp.pts$y),col="red")
关于r - 计算一个点和英国海岸之间的最小距离,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27384403/
我有以下方法可以向邮政编码添加空格: function isValidPostcode(p) { var postcodeRegEx = /[A-Z]{1,2}[0-9]{1,2} ?[0-9][A-
我希望能够从随机字符串中获取邮政编码。 我可能收到的字符串 2 Castlebar Park, London, Greater London W5 1BX, UK The Ludgrove Club,
这个问题已经有答案了: Date api for managing off days in an year? (2 个回答) 已关闭 4 年前。 我需要防止在公共(public)假期期间进入 park
我在下面有这个测试代码。 行///1///和///2///是备选方案。 如果我使用行///2///输出看起来有问题,似乎它没有说明美国波士顿和英国伦敦全年相差 5 小时的事实。如果我使用行///1//
我一直在搜索Highmaps Map Collection并且找不到英国的 map 数据。有谁知道在哪里可以找到这个?他们有这么多不同国家的国家 map ,却没有英国的 map ,这似乎很奇怪。 最佳
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 我们不允许提问寻求书籍、工具、软件库等的推荐。您可以编辑问题,以便用事实和引用来回答。 关闭 6 年前。
我已经注册了一个 token 来访问国家铁路(英国)Live Departure Boards API,但我似乎无法使用它。谁能指出我做错了什么? 我使用 WSDL.EXE 构建了一个 C# SOAP
在 mac 终端应用程序中有一个设置(首选项 -> 键盘),可让您设置“使用选项作为元键”。这很有用,因为许多 unix 机器使用 bash作为默认 shell 并且具有 emacs 键绑定(bind
我正在尝试比较两个日期。其中一个是用户在创建新点时输入的,其中有一个日期字段,模型如下所示。 [Required] [DataType(DataType.Date)] [DisplayFormat(D
我原以为这是很多人需要的东西,但我似乎找不到任何用 Go 做过的人的包或 repos/playground 示例。 目标是转换一个字符串/ float ,使1.20(输入)变成1/5(输出),1.29
我正在开发一个需要连接到互联网的应用程序。到目前为止,我一直在使用 Wifi 和 WAP 2 连接 UID 进行 Http 连接,并且一切正常。但是现在客户端告诉他希望使用直接 TCP 连接,因为使用
我在博客中发布了 FT map 。为此,我使用了以下代码: http://fusion-tables-api-samples.googlecode.com/svn/trunk/FusionTables
我正在使用 phonegap build 来制作应用程序。我已经集成了一个 Paypal SDK 插件,但它只接受来自美国或英国用户的信用卡: https://developer.paypal.com
有了新的Google Play优化建议,它给我的建议之一是: Your app is popular with users who speak English (United Kingdom) but
我想在 iPhone 应用程序中使用 TradeDoubler(欧洲)和 LinkShare(美国、加拿大)并链接到应用程序商店。我已经知道我总是会被带到正确的商店。但是每个国家/项目的附属链接都是不
我希望将 paypal 集成为我的客户的支付网关。 我给客户提供一个在线软件,向用户销售产品,所以我作为第三方开发paypal,所以钱是直接转入我客户的paypal账户,而不是我的。 我已经在 pay
我有这张图片。这是一张英国 map (不包括南爱尔兰): 我已成功获取纬度和经度并将其绘制到这张 map 上,方法是获取英国最左边的经度和最右边的经度,并使用它们计算出将点放在 map 上的位置。 这
我已经尝试了多个代码,例如这样 Sub DateFixer() Application.ScreenUpdating = False Application.Calculation =
用国语, countrycode | language US | English BR | Portuguese UK | English 在国名中, countrycode | name
嘿,我想知道如何使用 PHP 和 Google Maps Api 计算出 2 个邮政编码之间的距离。 任何人都有任何想法或示例链接。 最佳答案 假设您正在寻找 geographic distance
我是一名优秀的程序员,十分优秀!