为什么检查,如果一个GeoPoint是土地cartopy失败?

问题描述 投票:0回答:1

以下this answer,我试图检查是否该坐标对(经度,纬度)=(-3.4066095486248327,51.38747051763357)表示在陆地上的位置。这里是我的代码:

import fiona
import cartopy.io.shapereader as shpreader
import shapely.geometry as sgeom
from shapely.prepared import prep
geoms = fiona.open(shpreader.natural_earth(resolution='10m', category='physical', name='land'))
land_geom = sgeom.MultiPolygon([sgeom.shape(geom['geometry']) for geom in geoms])
land = prep(land_geom)

x = -3.4066095486248327
y = 51.38747051763357

print(land.contains(sgeom.Point(x, y)))

其结果是False即使一点是在陆地上,我使用Google Maps检查。我也查了,如果xysgeom.Point(x, y)切换的地方,但没有工作的结果仍False

谁能帮助?

cartopy
1个回答
1
投票

这点非常靠近海岸。你已经使用了1:10万比例尺海岸线“真相”在哪里的海岸线,但在这个规模这一点的确不是在陆地上,它只是在离海岸:

import matplotlib.pyplot as plt
import cartopy.crs as ccrs


x = -3.4066095486248327
y = 51.38747051763357

ax = plt.axes(projection=ccrs.PlateCarree())
ax.coastlines(resolution="10m")
ax.scatter([x], [y], transform=ccrs.PlateCarree())
# Land is top half, sea is bottom half of the domain
ax.set_extent([x-.1, x+.1, y-.1, y+.1], crs=ccrs.PlateCarree())
plt.show()

point plotted with coastline

如果你想获得这样的尺度这一权利,那么你将需要使用海岸线的更准确的表示。

© www.soinside.com 2019 - 2024. All rights reserved.