geocat.viz.util.set_map_boundary

geocat.viz.util.set_map_boundary#

geocat.viz.util.set_map_boundary(ax, lon_range, lat_range, north_pad=0, south_pad=0, east_pad=0, west_pad=0, res=1)#

Utility function to set the boundary of ax to a path that surrounds a given region specified by latitude and longitude coordinates. This boundary is drawn in the projection coordinates and therefore follows any curves created by the projection. As of now, this only works consistently for the Lambert Conformal Projection and North/South Polar Stereographic Projections.

Parameters:
  • ax (matplotlib.axes.Axes) – The axes to which the boundary will be applied.

  • lon_range (tuple, list) – The two-tuple containing the start and end of the desired range of longitudes. The first entry must be smaller than the second entry, except when the region crosses the antimeridian. Both entries must be between [-180 , 180]. If lon_range is from -180 to 180, then a full circle centered on the pole with a radius from the pole to the lowest latitude given by lat_range will be set as the boundary.

  • lat_range (tuple, list) – The two-tuple containing the start and end of the desired range of latitudes. The first entry must be smaller than the second entry. Both entries must be between [-90 , 90].

  • north_pad (int) – A constant to be added to the second entry in lat_range. Use this if the northern edge of the plot is cut off. Defaults to 0.

  • south_pad (int) – A constant to be subtracted from the first entry in lat_range. Use this if the southern edge of the plot is cut off. Defaults to 0.

  • east_pad (int) – A constant to be added to the second entry in lon_range. Use this if the eastern edge of the plot is cut off. Defaults to 0.

  • west_pad (int) – A constant to be subtracted from the first entry in lon_range. Use this if the western edge of the plot is cut off. Defaults to 0.

  • res (int) – The size of the incrementation for vertices in degrees. Default is a vertex every one degree of longitude. A higher number results in a lower resolution boundary.

Notes

Due to the behavior of Cartopy’s set_extent() function, the curved edges of the boundary may be flattened and cut off. To solve this, use the kwargs north_pad, south_pad, east_pad, and west_pad. These will modify the coordinates passed to set_extent(). For the Lambert Conformal and Polar Stereographic projections, typically only north_pad and south_pad are needed. If attempting to use this function for other projections (i.e. Orthographic) east_pad and west_pad may be needed.

Examples

All usage examples are within the GeoCAT-Examples Gallery. To see more usage cases, search the function on the website.