The cartopy Feature interface#

The data copyright, license and attribution can be blended on the map using text annotations (mpl docs) as shown in feature_creation.

Specific Feature subclasses have been defined for common functionality, such as accessing Natural Earth or GSHHS shapefiles. A list of these can be found in the reference documentation.

To simplify some very common cases, some pre-defined Features exist as cartopy.feature constants. The pre-defined Features are all small-scale (1:110m) Natural Earth datasets, and can be added with methods such as GeoAxes.add_feature:

Name

Description

BORDERS#

Country boundaries.

COASTLINE#

Coastline, including major islands.

LAKES#

Natural and artificial lakes.

LAND#

Land polygons, including major islands.

OCEAN#

Ocean polygons.

RIVERS#

Single-line drainages, including lake centerlines.

STATES#

Internal, first-order administrative boundaries (limited to the United States at this scale). Natural Earth have first-order admin boundaries for most countries at the 1:10,000,000 scale; these may be accessed with cartopy.feature.STATES.with_scale('10m')

Note

Any Natural Earth dataset can be used by creating an instance of cartopy.feature.NaturalEarthFeature. For example:

import cartopy.feature as cfeature
land_50m = cfeature.NaturalEarthFeature('physical', 'land', '50m',
                                        edgecolor='face',
                                        facecolor=cfeature.COLORS['land'])

A dictionary of some useful colors for drawing features also exists in cartopy.feature.COLORS.

For a full list of names in this dictionary:

>>> import cartopy.feature
>>> sorted(cartopy.feature.COLORS.keys())
['land', 'land_alt1', 'water']

Example of using the Feature class with the Matplotlib interface#

../_images/sphx_glr_feature_creation_001.png