在 matplotlib 中仅在大陆上绘图 [英] Plot only on continent in matplotlib

查看:34
本文介绍了在 matplotlib 中仅在大陆上绘图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 matplotlib 中的底图绘制地图.数据遍布全球,但我只想保留大陆上的所有数据,而将其丢在海洋上.有没有办法过滤数据,或者有没有办法再次绘制海洋来覆盖数据?

I am drawing a map using basemap from matplotlib. The data are spreaded all over the world, but I just want to retain all the data on the continent and drop those on the ocean. Is there a way that I can filter the data, or is there a way to draw the ocean again to cover the data?

推荐答案

matplotlib.basemap 中有一个方法:is_land(xpt, ypt)

There's method in matplotlib.basemap: is_land(xpt, ypt)

如果给定的 x,y 点(在投影坐标中)在陆地上,则返回 True,否则返回 False.土地的定义基于与类实例关联的 GSHHS 海岸线多边形.陆地区域内湖泊上方的点不计为陆地点.

It returns True if the given x,y point (in projection coordinates) is over land, False otherwise. The definition of land is based upon the GSHHS coastline polygons associated with the class instance. Points over lakes inside land regions are not counted as land points.

有关详细信息,请参阅此处.

For more information, see here.

这篇关于在 matplotlib 中仅在大陆上绘图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆