本文整理汇总了Python中cartopy.feature.NaturalEarthFeature方法的典型用法代码示例。如果您正苦于以下问题:Python feature.NaturalEarthFeature方法的具体用法?Python feature.NaturalEarthFeature怎么用?Python feature.NaturalEarthFeature使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cartopy.feature
的用法示例。
在下文中一共展示了feature.NaturalEarthFeature方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: map_unique_events
# 需要导入模块: from cartopy import feature [as 别名]
# 或者: from cartopy.feature import NaturalEarthFeature [as 别名]
def map_unique_events(cat, catname, mids):
"""Map unassociated events from a catalog."""
if len(mids) == len(cat):
return
cat = cat[~cat['id'].isin(mids)].reset_index(drop=True)
lllat, lllon, urlat, urlon, _, _, _, clon = qcu.get_map_bounds(cat)
plt.figure(figsize=(12, 7))
mplmap = plt.axes(projection=ccrs.PlateCarree(central_longitude=clon))
mplmap.coastlines('50m')
mplmap.scatter(cat['longitude'].tolist(), cat['latitude'].tolist(),
color='r', s=2, zorder=4, transform=ccrs.PlateCarree())
mplmap.gridlines(crs=ccrs.PlateCarree(), draw_labels=True,
linewidth=1, color='gray', alpha=0.5, linestyle='--')
mplmap.add_feature(cfeature.NaturalEarthFeature('cultural',
'admin_1_states_provinces_lines', '50m', facecolor='none',
edgecolor='k', zorder=9))
mplmap.add_feature(cfeature.BORDERS)
plt.title('%s unassociated events' % catname, fontsize=20, y=1.08)
#print(catname)
plt.savefig('%s_uniquedetecs.png' % catname, dpi=300)
plt.close()
示例2: countries
# 需要导入模块: from cartopy import feature [as 别名]
# 或者: from cartopy.feature import NaturalEarthFeature [as 别名]
def countries(**kwargs):
params = {
"category": "cultural",
"name": "admin_0_countries",
"scale": "10m",
"edgecolor": "#524c50",
"facecolor": "none",
"alpha": 0.5,
**kwargs,
}
return NaturalEarthFeature(**params)
示例3: rivers
# 需要导入模块: from cartopy import feature [as 别名]
# 或者: from cartopy.feature import NaturalEarthFeature [as 别名]
def rivers(**kwargs):
params = {
"category": "physical",
"name": "rivers_lake_centerlines",
"scale": "10m",
"edgecolor": "#226666",
"facecolor": "none",
"alpha": 0.2,
**kwargs,
}
return NaturalEarthFeature(**params)
示例4: lakes
# 需要导入模块: from cartopy import feature [as 别名]
# 或者: from cartopy.feature import NaturalEarthFeature [as 别名]
def lakes(**kwargs):
params = {
"category": "physical",
"name": "lakes",
"scale": "10m",
"edgecolor": "#226666",
"facecolor": "#226666",
"alpha": 0.2,
**kwargs,
}
return NaturalEarthFeature(**params)
示例5: ocean
# 需要导入模块: from cartopy import feature [as 别名]
# 或者: from cartopy.feature import NaturalEarthFeature [as 别名]
def ocean(**kwargs):
params = {
"category": "physical",
"name": "ocean",
"scale": "10m",
"edgecolor": "#226666",
"facecolor": "#226666",
"alpha": 0.2,
**kwargs,
}
return NaturalEarthFeature(**params)
示例6: map_events
# 需要导入模块: from cartopy import feature [as 别名]
# 或者: from cartopy.feature import NaturalEarthFeature [as 别名]
def map_events(cat1, cat1name, cat2, cat2name, cat1mids, cat2mids, dirname):
"""Map matching events between catalogs."""
if len(cat1mids) == 0:
return
lllat, lllon, urlat, urlon, _, _, _, clon = qcu.get_map_bounds(cat1, cat2)
cat1lons, cat1lats, cat2lons, cat2lats = [], [], [], []
for i, mid in enumerate(cat1mids):
cat1lons.append(cat1[cat1['id'] == mid]['longitude'].get_values()[0])
cat1lats.append(cat1[cat1['id'] == mid]['latitude'].get_values()[0])
cat2lons.append(cat2[cat2['id'] == cat2mids[i]]['longitude'
].get_values()[0])
cat2lats.append(cat2[cat2['id'] == cat2mids[i]]['latitude'
].get_values()[0])
plt.figure(figsize=(12, 7))
mplmap = plt.axes(projection=ccrs.PlateCarree(central_longitude=clon))
mplmap.set_extent([lllon, urlon, lllat, urlat], ccrs.PlateCarree())
mplmap.coastlines('50m')
mplmap.gridlines(crs=ccrs.PlateCarree(), draw_labels=True,
linewidth=1, color='gray', alpha=0.5, linestyle='--')
for i, lat in enumerate(cat1lats):
mplmap.plot([cat1lons[i], cat2lons[i]], [lat, cat2lats[i]],
color='k', transform=ccrs.PlateCarree())
mplmap.scatter(cat1lons, cat1lats, color='b', s=2, zorder=4,
transform=ccrs.PlateCarree(), label=cat1name)
mplmap.scatter(cat2lons, cat2lats, color='r', s=2, zorder=4,
transform=ccrs.PlateCarree(), label=cat2name)
mplmap.add_feature(cfeature.NaturalEarthFeature('cultural',
'admin_1_states_provinces_lines', '50m', facecolor='none',
edgecolor='k', zorder=9))
mplmap.add_feature(cfeature.BORDERS)
plt.legend()
plt.savefig('%s_mapmatcheddetecs.png' % dirname, dpi=300)
plt.close()
示例7: plot_lonlat_map
# 需要导入模块: from cartopy import feature [as 别名]
# 或者: from cartopy.feature import NaturalEarthFeature [as 别名]
def plot_lonlat_map(ax, lon, lat, data, transform, extend=None, cmap="CN_ref", bounds=np.arange(-5,76,5),
cbar=True, orientation="vertical",cbar_ticks=None, cbar_ticklabels=None, **kwargs):
"""
:param ax:cartopy.mpl.geoaxes.GeoAxesSubplot, it should get from cartopy, eg:plt.axes(projection=ccrs.PlateCarree())
:param lon: lon mesh grid for data units: degree
:param lat: lat mesh grid for data units: degree
:param data: radar data ,dims like lat, lon
:param transform: The transform argument to plotting functions tells Cartopy what coordinate system your data are defined in.
:param extend: (min_lon, max_lon, min_lat, max_lat), Latitude and longitude range, units:degrees
:param cmap: str or Colormap, optional, A Colormap instance or registered colormap name. to see cm.py!
:param min_max: The colorbar range(vmin, vmax). If None, suitable min/max values are automatically chosen by min max of data!
:param cmap_bins:bins of cmaps, int
:param cbar: bool, if True, plot with colorbar,
:param orientation: vertical or horizontal, it is vaild when cbar is True
:param kwargs: kwargs: other arguments for pcolormesh!
:return: pcolor result
"""
assert isinstance(ax, cartopy.mpl.geoaxes.GeoAxesSubplot), "axes is not cartopy axes!"
if extend is None:
min_lon = np.min(lon)
max_lon = np.max(lon)
min_lat = np.min(lat)
max_lat = np.max(lat)
else:
min_lon, max_lon, min_lat, max_lat = extend
ax.set_aspect("equal")
cmaps = plt.get_cmap(cmap)
norm = BoundaryNorm(bounds, ncolors=cmaps.N, clip=True)
pm = ax.pcolormesh(lon, lat, data, transform=transform, cmap=cmap, norm=norm, zorder=4, **kwargs)
ax.add_feature(cfeature.OCEAN.with_scale('50m'), zorder=0)
ax.add_feature(cfeature.NaturalEarthFeature('physical', 'land', '50m', \
edgecolor='none', facecolor="white"), zorder=1)
ax.add_feature(cfeature.LAKES.with_scale('50m'), zorder=2)
ax.add_feature(cfeature.RIVERS.with_scale('50m'), zorder=3)
ax.add_feature(cfeature.ShapelyFeature(CN_shp_info.geometries(), transform, \
edgecolor='k', facecolor='none'), linewidth=0.5, \
linestyle='-', zorder=5, alpha=0.8)
parallels = np.arange(int(min_lat), np.ceil(max_lat) + 1, 1)
meridians = np.arange(int(min_lon), np.ceil(max_lon) + 1, 1)
ax.set_xticks(meridians, crs=transform)
ax.set_yticks(parallels, crs=transform)
lon_formatter = LongitudeFormatter()
lat_formatter = LatitudeFormatter()
ax.xaxis.set_major_formatter(lon_formatter)
ax.yaxis.set_major_formatter(lat_formatter)
if cbar:
cb = plt.colorbar(mappable=pm, ax=ax, orientation=orientation)
if cbar_ticks is None:
ticks = bounds
else:
ticks = cbar_ticks
cb.set_ticks(ticks)
if cbar_ticklabels is not None:
if orientation == "vertical":
cb.ax.set_yticklabels(cbar_ticklabels)
else:
cb.ax.set_xticklabels(cbar_ticklabels)
return pm