cartopy

Xarray Roll and Cartopy add_cyclic_point functions conflicting

二次信任 提交于 2021-02-05 11:12:58
问题 Recently I tried to make a simple plot of the Pacific and Atlantic Oceans together, from 180W-20E. To cross the 0 degree line I used the roll method as follows: import matplotlib.pyplot as plt import cartopy.crs as ccrs import cartopy.feature as cf import cartopy as cartopy import numpy as np import xarray as xr from cartopy.mpl.ticker import LongitudeFormatter, LatitudeFormatter from cartopy.util import add_cyclic_point dset = xr.open_dataset('sst.mnmean.nc') var = dset['sst'][:,:,:] lat =

How to set curvilinear lat lon gridline labels parallel to gridlines with cartopy?

空扰寡人 提交于 2021-01-29 09:40:55
问题 Description Is there a method available (or under consideration) to orient the lat lon gridline labels parallel to the gridlines as they intersect the plot boundary? Something like the labels seen in this plot. There seems to be an automated logic in place for orienting gridline labels as follows: Cartopy version 0.18.0b1 Code import matplotlib.pyplot as plt import cartopy.crs as ccrs rotated_crs = ccrs.RotatedPole(pole_longitude=120.0, pole_latitude=70.0) ax = plt.axes(projection=rotated_crs

Python: Axis disappearing in figure when animating with celluloid

廉价感情. 提交于 2021-01-29 08:57:39
问题 I am using celluloid (https://github.com/jwkvam/celluloid) to plot a function over several years and i love it so far, it works great! I have one small problem though, the edges of my plot disappear after the first loop. I have attached images of how this looks. First loop: Second loop: As you can see the axis has disappeared. I am using cartopy and matplotlib in jupyter notebook and this is my code for the animation: # Use 'Agg' so script only displays animation in HTML import matplotlib

Plot Fine Grained Geodesic with Cartopy

匆匆过客 提交于 2021-01-29 08:49:46
问题 The following code (copied from here) produces a nicely looking geodesic between NYC and New Delhi. Upon close inspection, the geodesic does not look smooth. How can I make it smooth looking? import cartopy.crs as ccrs import matplotlib.pyplot as plt ny_lon, ny_lat = -75, 43 delhi_lon, delhi_lat = 77.23, 28.61 ax = plt.axes(projection=ccrs.PlateCarree()) ax.stock_img() plt.plot([ny_lon, delhi_lon], [ny_lat, delhi_lat], linewidth=2, marker='o', transform=ccrs.Geodetic()) plt.tight_layout() plt

How to plot a vector field with error ellipse using cartopy

安稳与你 提交于 2021-01-29 05:27:24
问题 Cartopy seems like a great tool for Geoscience, but it appears to lack a method for plotting vector data on a map together with their error ellipses. Is there a straightforward way to add error ellipses centered on the tips of vector data? 回答1: Cartopy inherits all its vector plotting functionality from matplotlib. Cartopy provides a way to project the vectors, but they are drawn by matplotlib. I haven't heard of a feature you describe in matplotlib, so I'm afraid the answer is probably no.

How can I rotate gridline labels on a cartopy map?

六眼飞鱼酱① 提交于 2021-01-28 19:54:49
问题 I'm plotting a map using Stamen tiles inside a matplotlib figure like so: tiler=Stamen('terrain-background') mercator=tiler.crs ax3=fig.add_subplot(gs01[1,0], projection=ccrs.PlateCarree()) ax3.add_image(tiler,14) I then attempt to rotate the gridline tick labels like so: gl3=ax3.gridlines(crs=ccrs.PlateCarree(), draw_labels=True, linewidth=1., color='gray', alpha=0.75, linestyle='--') gl3.left_labels=False gl3.top_labels=False gl3.xlabel_style={'size':10., 'color':'gray', 'weight':'bold'}

cartopy: how to add an image on top of map

烂漫一生 提交于 2021-01-28 05:22:53
问题 How to overlay a custom image on top of a cartopy map? If I do ax = plt.axes(projection=map_quest_aerial.crs) ax.set_extent([lon_0, lon_1, lat_0, lat_1]) plt.imshow('myimage.png', extent=(x0,x1,y0,y1)) plt.show() my image shows up correctly in the axes. But, if I try to add the background map image, my image no longer appears: ax = plt.axes(projection=map_quest_aerial.crs) ax.set_extent([lon_0, lon_1, lat_0, lat_1]) ax.add_image(map_quest_aerial, 10) plt.imshow('myimage.png', extent=(x0,x1,y0

Merge countries using Cartopy

时光总嘲笑我的痴心妄想 提交于 2021-01-27 21:12:47
问题 I am using the following code to make a map for Sweden, Norway and Finland together as one area. however, I am struggling with it. I'm following this example, Python Mapping in Matplotlib Cartopy Color One Country. from shapely.geometry import Polygon from cartopy.io import shapereader import cartopy.io.img_tiles as cimgt import cartopy.crs as ccrs import geopandas import matplotlib.pyplot as plt def rect_from_bound(xmin, xmax, ymin, ymax): """Returns list of (x,y)'s for a rectangle""" xs =

Why do my google tiles look poor in a Cartopy map?

梦想的初衷 提交于 2020-12-29 03:56:15
问题 I am a bit puzzled by the rendering of google tiles with Cartopy. The map looks extremely poor compared to the standard google map look. Example (code from https://ocefpaf.github.io/python4oceanographers/blog/2015/06/22/osm/): import matplotlib.pyplot as plt import cartopy.crs as ccrs from cartopy.io import shapereader from cartopy.mpl.gridliner import LONGITUDE_FORMATTER, LATITUDE_FORMATTER def make_map(projection=ccrs.PlateCarree()): fig, ax = plt.subplots(figsize=(9, 13), subplot_kw=dict