File: developer_interfaces.rst

package info (click to toggle)
python-cartopy 0.21.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 14,668 kB
  • sloc: python: 15,101; makefile: 166; javascript: 66; sh: 6
file content (68 lines) | stat: -rw-r--r-- 2,447 bytes parent folder | download
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_developer_interfaces:

Cartopy developer interfaces
============================

Cartopy exposes several interfaces to help make it easier to add new
functionality quickly and easily.

..
    Feature API
    -----------
    TODO

    Image API
    ---------
    TODO


Data/Download API
-----------------

In order to keep the size of a cartopy release low, the majority of data is
not included as standard. This means that, when developing new features, it is
often necessary to provide interfaces which can acquire data from external
sources (normally via HTTP). The :class:`~cartopy.io.Downloader` class
has been designed to make this process as easy as possible for developers to
extend, whilst still making it possible for users to configure in their own
way.


An example of specialising this class can be found in
:mod:`cartopy.io.shapereader.NEShpDownloader` which enables the downloading of
zipped shapefiles from the `<https://www.naturalearthdata.com>`_ website. All
known subclasses of :class:`~cartopy.io.Downloader` are listed below for
reference:

   * :class:`cartopy.io.shapereader.NEShpDownloader`
   * :class:`cartopy.io.srtm.SRTMDownloader`


Raster images
-------------

The abstraction between retrieval and visualisation of raster data means
that the :class:`cartopy.io.RasterSource` class exists to retrieve an image
(given sufficient context of projection, extent, resolution etc.) while in the
matplotlib interface the
:class:`cartopy.mpl.slippy_image_artist.SlippyImageArtist`
class feeds the appropriate information to the
:class:`~cartopy.io.RasterSource` and visualises it on a map.
The orchestration in Matplotlib is made more convenient
to the user of a :class:`~cartopy.mpl.geoaxes.GeoAxes` through the
:class:`~cartopy.mpl.geoaxes.GeoAxes.add_raster` method. Anything which exposes
the ``validate_projection`` and ``fetch_raster`` methods in the form described
in :class:`~cartopy.io.RasterSource` can be used as a slippy maps source in
this way.


.. currentmodule:: cartopy.mpl.slippy_image_artist

The :class:`SlippyImageArtist` class
provides panning and zooming of image sources which are able to
re-retrieve data (such as that from a web service) for efficient and
interactive visualisation. Generally the SlippyImageArtist is a developer's
interface, with users often creating a
:class:`SlippyImageArtist` instance through
the GeoAxes' :meth:`~cartopy.mpl.geoaxes.GeoAxes.add_raster` method.