小编B. *_*eas的帖子

使用 cartopy 和 Natural Earth 10m 数据检查地理坐标点是陆地还是海洋

上一个问题“使用 cartopy 检查地理坐标点是陆地还是海洋”的答案请参阅https://stackoverflow.com/questions/asktitle=Checking%20if%20a%20geocooperative%20point%20is%20land%20or%20ocean% 20using%20cartopy%20and%20Natural%20Earth%2010m%20data建议使用以下代码来确定地理坐标是否为“is_land”:

    import cartopy.io.shapereader as shpreader
    import shapely.geometry as sgeom
    from shapely.ops import unary_union
    from shapely.prepared import prep

    land_shp_fname = shpreader.natural_earth(resolution='50m',
                                   category='physical', name='land')

    land_geom = 
    unary_union(list(shpreader.Reader(land_shp_fname).geometries()))
    land = prep(land_geom)

    def is_land(x, y):
       return land.contains(sgeom.Point(x, y))
Run Code Online (Sandbox Code Playgroud)

当自然地球“物理”“土地”形状文件的分辨率更改为“10m”时,此代码返回地理坐标 (0,0) 的意外结果“True”。

    >>> print(is_land(0, 0))
    True
Run Code Online (Sandbox Code Playgroud)

这是 Natural Earth shapefile 数据或 shapely 实用程序代码的问题吗?

    print shapely.__version__
    1.6.4.post1
Run Code Online (Sandbox Code Playgroud)

python shapely cartopy

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

标签 统计

cartopy ×1

python ×1

shapely ×1