本文整理汇总了Python中cartopy.feature.LAND属性的典型用法代码示例。如果您正苦于以下问题:Python feature.LAND属性的具体用法?Python feature.LAND怎么用?Python feature.LAND使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类cartopy.feature
的用法示例。
在下文中一共展示了feature.LAND属性的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _setup_map
# 需要导入模块: from cartopy import feature [as 别名]
# 或者: from cartopy.feature import LAND [as 别名]
def _setup_map(
ax, xticks, yticks, crs, region, land=None, ocean=None, borders=None, states=None
):
"""
Setup a Cartopy map with land and ocean features and proper tick labels.
"""
if land is not None:
ax.add_feature(cfeature.LAND, facecolor=land)
if ocean is not None:
ax.add_feature(cfeature.OCEAN, facecolor=ocean)
if borders is not None:
ax.add_feature(cfeature.BORDERS, linewidth=borders)
if states is not None:
ax.add_feature(cfeature.STATES, linewidth=states)
ax.set_extent(region, crs=crs)
# Set the proper ticks for a Cartopy map
ax.set_xticks(xticks, crs=crs)
ax.set_yticks(yticks, crs=crs)
ax.xaxis.set_major_formatter(LongitudeFormatter())
ax.yaxis.set_major_formatter(LatitudeFormatter())
示例2: _setup_map
# 需要导入模块: from cartopy import feature [as 别名]
# 或者: from cartopy.feature import LAND [as 别名]
def _setup_map(
ax, xticks, yticks, crs, region, land=None, ocean=None, borders=None, states=None
):
"""
Setup a Cartopy map with land and ocean features and proper tick labels.
"""
import cartopy.feature as cfeature
from cartopy.mpl.ticker import LongitudeFormatter, LatitudeFormatter
if land is not None:
ax.add_feature(cfeature.LAND, facecolor=land)
if ocean is not None:
ax.add_feature(cfeature.OCEAN, facecolor=ocean)
if borders is not None:
ax.add_feature(cfeature.BORDERS, linewidth=borders)
if states is not None:
ax.add_feature(cfeature.STATES, linewidth=states)
ax.set_extent(region, crs=crs)
# Set the proper ticks for a Cartopy map
ax.set_xticks(xticks, crs=crs)
ax.set_yticks(yticks, crs=crs)
ax.xaxis.set_major_formatter(LongitudeFormatter())
ax.yaxis.set_major_formatter(LatitudeFormatter())
示例3: receiver_locations
# 需要导入模块: from cartopy import feature [as 别名]
# 或者: from cartopy.feature import LAND [as 别名]
def receiver_locations(locs: pandas.DataFrame):
if not isinstance(locs, pandas.DataFrame):
return
if cartopy is not None:
ax = figure().gca(projection=cartopy.crs.PlateCarree())
ax.add_feature(cpf.LAND)
ax.add_feature(cpf.OCEAN)
ax.add_feature(cpf.COASTLINE)
ax.add_feature(cpf.BORDERS, linestyle=':')
else:
ax = figure().gca()
for name, loc in locs.iterrows():
if 15 <= loc.interval < 30:
c = 'g'
elif 5 <= loc.interval < 15:
c = 'o'
elif loc.interval < 5:
c = 'r'
else: # large or undefined interval
c = 'b'
if np.isfinite(loc.interval):
ax.scatter(loc.lon, loc.lat, s=1000*1/loc.interval, c=c, label=name)
else:
ax.scatter(loc.lon, loc.lat, c=c, label=name)
示例4: plot_global
# 需要导入模块: from cartopy import feature [as 别名]
# 或者: from cartopy.feature import LAND [as 别名]
def plot_global(xx,yy, data,
data_projection_code,
cmin, cmax, ax,
plot_type = 'pcolormesh',
show_colorbar=False,
cmap=None,
show_grid_lines = True,
show_grid_labels = True,
grid_linewidth = 1,
custom_background = False,
background_name = [],
background_resolution = [],
levels=20):
# assign cmap default
if cmap is None:
if cmin*cmax<0:
cmap = 'RdBu_r'
else:
cmap = 'viridis'
if show_grid_lines :
gl = ax.gridlines(crs=ccrs.PlateCarree(),
linewidth=1, color='black',
draw_labels = show_grid_labels,
alpha=0.5, linestyle='--', zorder=102)
else:
gl = []
if data_projection_code == 4326: # lat lon does nneed to be projected
data_crs = ccrs.PlateCarree()
else:
data_crs =ccrs.epsg(data_projection_code)
if custom_background:
ax.background_img(name=background_name, resolution=background_resolution)
if plot_type == 'pcolormesh':
p = ax.pcolormesh(xx, yy, data, transform=data_crs,
vmin=cmin, vmax=cmax, cmap=cmap)
elif plot_type =='contourf':
p = ax.contourf(xx, yy, data, levels, transform=data_crs,
vmin=cmin, vmax=cmax, cmap=cmap)
else:
raise ValueError('plot_type must be either "pcolormesh" or "contourf"')
if not custom_background:
ax.add_feature(cfeature.LAND, zorder=100)
ax.coastlines('110m', linewidth=grid_linewidth, zorder=101)
cbar = []
if show_colorbar:
sm = plt.cm.ScalarMappable(cmap=cmap, norm=plt.Normalize(cmin,cmax))
sm._A = []
cbar = plt.colorbar(sm,ax=ax)
return p, gl, cbar
# -----------------------------------------------------------------------------
示例5: plot_base
# 需要导入模块: from cartopy import feature [as 别名]
# 或者: from cartopy.feature import LAND [as 别名]
def plot_base(self, bous = 1, bmap = None,
features = ['land','ocean','lake','river'],
gridline = True, lic = True):
"""
Plot map base
Parameters
----------
bous : TYPE, optional
DESCRIPTION. The default is 1.
bmap : TYPE, optional
DESCRIPTION. The default is None.
features : TYPE, optional
DESCRIPTION. The default is ['land','ocean','lake','river'].
gridline : TYPE, optional
DESCRIPTION. The default is True.
lic : TYPE, optional
DESCRIPTION. The default is True.
Returns
-------
None.
"""
if self.engine == 'gmt':
self.gmt_plot_base(self.region)
else:
self.fig.set_extent([72, 137, 10, 55])
self.fig.stock_img()
self.fig.coastlines()
self.fig.add_feature(cfeature.LAND)
self.fig.add_feature(cfeature.OCEAN)
self.fig.add_feature(cfeature.LAKES)
self.fig.add_feature(cfeature.RIVERS)
self.fig.gridlines(crs=ccrs.PlateCarree(), draw_labels=True)
datapath = Path(Path(catalog.__file__).parent,'data')
fname = Path(datapath, 'bou1_4l.shp')
f2name = Path(datapath, 'bou2_4l.shp')
faults = Path(datapath, 'gem_active_faults.shp')
self.fig.add_geometries(Reader(str(faults)).geometries(),
ccrs.PlateCarree(),facecolor = 'none',
edgecolor='red')
self.fig.add_geometries(Reader(str(f2name)).geometries(),
ccrs.PlateCarree(), facecolor = 'none',
edgecolor='gray', linestyle=':')
self.fig.add_geometries(Reader(str(fname)).geometries(),
ccrs.PlateCarree(), facecolor = 'none',
edgecolor='black')