1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
|
.. _cartopy_feature_interface:
The cartopy Feature interface
=============================
The :ref:`data copyright, license and attribution <referencing_copyright>` can be blended on the map using `text annotations (mpl docs) <https://matplotlib.org/users/annotations_intro.html>`_ as shown in `feature_creation <../gallery/feature_creation.html>`_.
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 :ref:`the reference documentation <api.feature>`.
To simplify some very common cases, some pre-defined Features exist as :mod:`cartopy.feature`
constants. The pre-defined Features are all small-scale (1:110m)
`Natural Earth <https://www.naturalearthdata.com>`_ datasets, and can be added with methods
such as :func:`GeoAxes.add_feature <cartopy.mpl.geoaxes.GeoAxes.add_feature>`:
======================= ================================================================
Name Description
======================= ================================================================
.. py:data:: BORDERS Country boundaries.
.. py:data:: COASTLINE Coastline, including major islands.
.. py:data:: LAKES Natural and artificial lakes.
.. py:data:: LAND Land polygons, including major islands.
.. py:data:: OCEAN Ocean polygons.
.. py:data:: RIVERS Single-line drainages, including lake centerlines.
.. py:data:: 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 :class:`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 :attr:`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
----------------------------------------------------------------
.. figure:: ../gallery/lines_and_polygons/images/sphx_glr_feature_creation_001.png
:target: ../gallery/lines_and_polygons/feature_creation.html
:align: center
:scale: 50
|