Input/output capabilities (cartopy.io)#
Cartopy has many built-in image and map acquisition capabilities. These capabilities allow the maps to be loaded, saved, and retrieved in various data formats.
Shapereader#
This module provides a basic interface for accessing shapefiles. Combine the shapefile access of pyshp or fiona with the geometry representation of shapely:
>>> import cartopy.io.shapereader as shapereader
>>> filename = shapereader.natural_earth(resolution='110m',
... category='physical',
... name='geography_regions_points')
>>> reader = shapereader.Reader(filename)
>>> len(reader)
3
>>> records = list(reader.records())
>>> print(', '.join(str(r) for r in sorted(records[0].attributes.keys())))
comment, ... name, name_alt, ... region, ...
>>> print(records[0].attributes['name'])
Niagara Falls
>>> geoms = list(reader.geometries())
>>> print(type(geoms[0]))
<class 'shapely.geometry.point.Point'>
>>> reader.close()
Alias of the default available shapereader interface. |
|
|
Provide an interface for accessing the contents of a shapefile with the Python Shapefile Library (PyShp). |
|
Provides an interface for accessing the contents of a shapefile with the fiona library, which has a much faster reader than PyShp. |
|
A single logical entry from a shapefile, combining the attributes with their associated geometry. |
|
A single logical entry from a shapefile, combining the attributes with their associated geometry. |
|
Return the path to the requested natural earth shapefile, downloading and unzipping if necessary. |
|
Specialise |
|
Return the path to the requested GSHHS shapefile, downloading and unzipping if necessary. |
|
Specialise |
Image collections#
Provides an interface for representing images.
|
Represents a simple geo-located image. |
|
Represents a collection of images at the same logical level. |
|
Represents a complex nest of ImageCollections. |
Image tiles#
Implements image tile identification and fetching from various sources, automatically loading the proper tile and resolution depending on the desired domain.
The Matplotlib interface can make use of tile objects (defined below) via the
cartopy.mpl.geoaxes.GeoAxes.add_image()
method. For example, to add a
MapQuest Open Aerial tileset
to an existing axes
at zoom level 2, do ax.add_image(MapQuestOpenAerial(), 2)
. An example of
using tiles in this way can be found at the
Map tile acquisition example.
|
|
|
|
|
Implement web tile retrieval using the Google WTS coordinate system. |
|
|
|
|
|
Implement web tile retrieval from a user-defined Mapbox style. |
|
Implement web tile retrieval from Mapbox. |
|
Implement web tile retrieval from Ordnance Survey map data. |
|
Implement web tile retrieval using the Microsoft WTS quadkey coordinate system. |
|
Retrieves tiles from stadiamaps.com. |
|
Retrieves tiles from maps.stamen.com. |
Open Geospatial Consortium (OGC) Clients#
Implements RasterSource classes which can retrieve imagery from web services such as WMS and WMTS.
The matplotlib interface can make use of RasterSources via the
cartopy.mpl.geoaxes.GeoAxes.add_raster()
method,
with additional specific methods which make use of this for WMS and WMTS
(add_wms()
and
add_wmts()
). An example of using WMTS in
this way can be found at Interactive WMTS (Web Map Tile Service).
|
Web Feature Service (WFS) retrieval for Cartopy. |
|
A WMS imagery retriever which can be added to a map. |
|
A WMTS imagery retriever which can be added to a map. |
Shuttle Radar Topography Mission (SRTM)#
The Shuttle Radar Topography Mission (SRTM) is an international research effort that obtained digital elevation models on a near-global scale from 56S to 60N, to generate the most complete high-resolution digital topographic database of Earth prior to the release of the ASTER GDEM in 2009.
Wikipedia (August 2012)
The SRTM data can be accessed through the cartopy.io.srtm
module
using classes and functions defined below.
|
A source of SRTM1 data, which implements Cartopy's RasterSource interface. |
|
A source of SRTM3 data, which implements Cartopy's RasterSource interface. |
|
Provide a SRTM download mechanism. |
|
Read the array of (y, x) elevation data from the given named file-handle. |
|
Read the array of (y, x) elevation data from the given named file-handle. |
|
Read the array of (y, x) elevation data from the given named file-handle. |
|
Add shading to SRTM elevation data, using azimuth and altitude of the sun. |
Base classes and functions#
These are the base classes in cartopy.io
that new resources can leverage
to implement a new reader or tile client. Together they provide a collection of
sub-packages for loading, saving and retrieving various data formats.
|
Represents a resource, that can be configured easily, which knows how to acquire itself (perhaps via HTTP). |
Issued when a file is being downloaded by a |
|
|
Define an image and associated extent in the form: |
Define the cartopy raster fetching interface. |
|
|
A container which simply calls the appropriate methods on the contained |
|
A |
|
Convenience function for opening files. |