Cartopy
Cartopy is a Python package designed for geospatial data processing in order to produce maps and other geospatial data analyses.
Official Documents
Tutorial
A First Look at Cartopy (for Iris) 気象データ解析のためのmatplotlibの使い⽅: cartopyのTIPS
Cartopyで地理データを可視化する - Met Post
Cartopy Tutorial | Xdev
Tips
簡潔に軸ラベルを表記できるように
Suplots
code:python
fig, axs = plt.subplots(nrows=nrows,ncols=ncols,
subplot_kw={'projection': ccrs.PlateCarree()},
figsize=(11,8.5))
Examples
`#6 - Making a Basic Map with Cartopy
`#7- Contouring a Field on a Map
contour
add cyclonic point
`#33 - Cartopy 0.16
feature
state border
with_scale
scatter
`#64 - Night Shading
https://gyazo.com/b70d49b74e340b9e7b8c0b0baed921ab
'#89 - SPC Maps with Shapefiles : Unidata Developer's Blog `#134 - Buoys and Tropical Storm Cristobal
scatter
Metpy.calc.wind_component `#143 - HURDAT2 Plotting
Wind roses are a powerful tool for visualizing wind patterns, but what if you could overlay them on real-world maps for better geographic context? In this week's MetPy Monday, we take wind data analysis to the next level by plotting wind roses on OpenStreetMap layers using CartoPy. By integrating Python's windrose package with CartoPy image tiles, we create a geospatial visualization that combines meteorology and mapping. In this tutorial, you'll learn how to extract wind speed and direction data, generate wind rose plots, and overlay them onto OpenStreetMap using customized map layers. Whether you're working in meteorology, environmental analysis, or GIS, this approach provides deeper insight into regional wind patterns. Watch the full video to see how Python can help you bridge the gap between weather data and spatial analysis! Examples
python4oceanographers
Using SRTM data to correct GPS altimetry
Plotting shapefiles with cartopy and folium
Qiitaのcartopyタグ記事
Ocean Science Hack
surface drifter (in Japanese)
Surface velocity data of MOVE/MRI.com at NEAR-GOOS RRTDB (in Japanese)
Tips
python - Increasing resolution of Cartopy stock background? - Geographic Information Systems Stack Exchange
python - Download data from Natural Earth and OpenStreetMap for Cartopy - Stack Overflow
Cartopy Performance Optimization: transform_first
What is transform_first?
A keyword argument in Cartopy plotting functions (e.g., contourf, pcolormesh) that changes the timing of coordinate transformation.
Default (False): Transforms every single data point/polygon from source to target projection. High precision, but high CPU load for large grids.
True: Renders data as an image in the source projection first, then warps the resulting image to the target projection. Significant speedup for high-resolution 2D grids.
Case-by-Case Analysis
table: Cases
Case Transformation Speedup Verdict
1 Different (e.g., Robinson) High Recommended for massive grids
2 Same (PlateCarree -> PC) None Not necessary
3 Shifted (PC -> PC 180) High Useful to bypass wrapping math
Sample Code
code:python
import cartopy.crs as ccrs
import matplotlib.pyplot as plt
ax = plt.axes(projection=ccrs.Robinson())
plt.contourf(lons, lats, data, transform=ccrs.PlateCarree(), transform_first=True)
Disadvantages and Cautions: The "Seam" Issue
When changing central_longitude, using transform_first=True may cause a thin, blank vertical line to appear at the new map boundaries (the "seam" where the data should be continuous).
This is caused by sampling errors that occur when the rendered image is "torn" and rearranged to fit the new projection. While applying cartopy.util.add_cyclic_point to your data is the standard way to ensure periodicity, its effect may be diminished or bypassed when transform_first=True is enabled, as the transformation happens at the image level rather than the coordinate level.
# N