Cartopy
Cartopy is a Python package designed for geospatial data processing in order to produce maps and other geospatial data analyses.
https://scitools.org.uk/cartopy/docs/latest/
Official Documents
Gallery https://scitools.org.uk/cartopy/docs/latest/gallery/index.html
Tutorial
A First Look at Cartopy (for Iris)
https://github.com/SciTools/courses
気象データ解析のためのmatplotlibの使い⽅: cartopyのTIPS
http://ebcrpa.jamstec.go.jp/~yyousuke/matplotlib/cartopy.html
or https://yyousuke.github.io/matplotlib/index.html
Cartopyで地理データを可視化する - Met Post
1 http://metpost.hatenablog.com/entry/2015/11/05/180006
2 http://metpost.hatenablog.com/entry/2016/06/04/155751
3 http://metpost.hatenablog.com/entry/2016/06/04/161222
Cartopy Tutorial | Xdev
https://ncar.github.io/xdev/posts/cartopy-tutorial/
Tips
python - Change map boundary color in Cartopy - Stack Overflow
matplotlib - Setting up a map which crosses the dateline in cartopy - Stack Overflow
cartopy - Force aspect ratio for a map - Stack Overflow
cartopyタグ記事 - Qiita
python+cartopy0.18.0で地図を描画してみる - Qiita
簡潔に軸ラベルを表記できるように
Suplots
Making multi-panel plots using Cartopy — Pangeo-at-AOES 0.1.1 documentation
code:python
fig, axs = plt.subplots(nrows=nrows,ncols=ncols,
subplot_kw={'projection': ccrs.PlateCarree()},
figsize=(11,8.5))
Examples
MetPy Mondays
`#6 - Making a Basic Map with Cartopy
https://www.unidata.ucar.edu/blogs/developer/en/entry/metpy-mondays-6-making-a
`#7- Contouring a Field on a Map
https://www.unidata.ucar.edu/blogs/developer/en/entry/metpy-mondays-7-contouring-a
contour
add cyclonic point
https://scitools.org.uk/cartopy/docs/latest/cartopy/util/util.html?highlight=add_cyclic_point#cartopy.util.add_cyclic_point
`#33 - Cartopy 0.16
https://www.unidata.ucar.edu/blogs/developer/en/entry/metpy-mondays-33-cartopy-0
feature
state border
with_scale
scatter
`#64 - Night Shading
https://www.unidata.ucar.edu/blogs/developer/en/entry/metpy-mondays-64-night-shading
https://scitools.org.uk/cartopy/docs/latest/gallery/nightshade.html
https://gyazo.com/b70d49b74e340b9e7b8c0b0baed921ab
'#89 - SPC Maps with Shapefiles : Unidata Developer's Blog
#GeoPandas
shapefiles from the Storm Prediction Center and make a map like those on the SPC website!
https://www.unidata.ucar.edu/blogs/developer/entry/metpy-mondays-89-spc-maps/
`#134 - Buoys and Tropical Storm Cristobal
https://www.unidata.ucar.edu/blogs/developer/entry/metpy-mondays-134-buoys-and
NDBC #buoy data
#wind #barb
scatter
Metpy.calc.wind_component
https://unidata.github.io/MetPy/latest/api/generated/metpy.calc.wind_components.html#metpy.calc.wind_components
`#143 - HURDAT2 Plotting
https://www.unidata.ucar.edu/blogs/developer/entry/metpy-mondays-143-hurdat2-plotting
HURDAT2
Hurricane
bokeh
MetPy Mondays #295 - 2 Minutes to Plotting Major Cities on Your Python Maps : Unidata Developer's Blog
US Cities Database | Simplemaps.com
MetPy Mondays #323 - Mapping Wind Roses on OpenStreetMap with CartoPy : Unidata Developer's Blog -
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
GOES IR images using Cartopy
https://nbviewer.jupyter.org/gist/ajdawson/8637019
python4oceanographers
Using SRTM data to correct GPS altimetry
https://ocefpaf.github.io/python4oceanographers/blog/2014/09/08/srtm/
Plotting shapefiles with cartopy and folium
http://ocefpaf.github.io/python4oceanographers/blog/2015/02/02/cartopy_folium_shapefile/
Qiitaのcartopyタグ記事
https://qiita.com/tags/cartopy
Ocean Science Hack
surface drifter (in Japanese)
http://oceansciencehack.blogspot.com/2014/09/surface-drifter.html
Surface velocity data of MOVE/MRI.com at NEAR-GOOS RRTDB (in Japanese)
http://oceansciencehack.blogspot.com/2014/11/surface-velocity-data-of-movemricom-at.html
Tips
python - Increasing resolution of Cartopy stock background? - Geographic Information Systems Stack Exchange
https://gis.stackexchange.com/questions/313490/increasing-resolution-of-cartopy-stock-background
python - Download data from Natural Earth and OpenStreetMap for Cartopy - Stack Overflow
https://stackoverflow.com/questions/35707514/download-data-from-natural-earth-and-openstreetmap-for-cartopy?rq=1
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