输入/输出功能(cartopy.io)#

Cartopy具有许多内置图像和地图获取功能。这些功能允许以各种数据格式加载、保存和检索地图。

塑造者#

该模块提供了访问Shapetime的基本界面。将pyshp或fiona的Shape文件访问与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()

Reader 

默认可用ShapeReader界面的格式。

BasicReader(filename[, bbox])

使用Python Shapefile Library(PyShp)提供访问shapefile内容的接口。

FionaReader(filename[, bbox])

提供了一个接口,用于使用fiona库访问Shape File的内容,该库的读取器比PyShp快得多。

Record(shape, attributes, fields)

形状文件中的单个逻辑条目,将属性与其关联的几何图形相结合。

FionaRecord(geometry, attributes)

形状文件中的单个逻辑条目,将属性与其关联的几何图形相结合。

natural_earth([resolution, category, name])

返回请求的自然地球形状文件的路径,如有必要,下载并解压缩。

NEShpDownloader([url_template, ...])

专注 cartopy.io.Downloader 下载压缩后的自然地球形状文件并将其提取到定义的位置(通常是用户可配置的)。

gshhs([scale, level])

将路径返回到请求的GSHHS shapefile,如有必要,请下载并解压缩。

GSHHSShpDownloader([url_template, ...])

专注 cartopy.io.Downloader 下载压缩后的GSHHS形状文件并将它们提取到定义的位置。

图像集合#

提供用于表示图像的界面。

Img(*args, **kwargs)

代表简单的地理定位图像。

ImageCollection(name, crs[, images])

表示相同逻辑级别的图像集合。

NestedImageCollection(name, crs, collections)

表示ImageCollections的复杂嵌套。

图像图块#

实现图像区块识别和从各种来源获取,根据所需的域自动加载适当的区块和分辨率。

Matplotlib接口可以通过 cartopy.mpl.geoaxes.GeoAxes.add_image() 法例如,添加一个 MapQuest Open Aerial tileset 对于缩放级别2的现有轴,执行 ax.add_image(MapQuestOpenAerial(), 2) .以这种方式使用磁贴的示例可以在 地图磁贴获取 example.

OSM([desired_tile_form, user_agent, cache])

GoogleTiles([desired_tile_form, style, url, ...])

GoogleWTS([desired_tile_form, user_agent, cache])

使用Google WTS坐标系实现Web平铺检索。

MapQuestOSM([desired_tile_form, user_agent, ...])

MapQuestOpenAerial([desired_tile_form, ...])

MapboxStyleTiles(access_token, username, map_id)

从用户定义的Mapbox风格实现Web磁贴检索。

MapboxTiles(access_token, map_id[, cache])

从Mapbox实现Web磁贴检索。

OrdnanceSurvey(apikey[, layer, ...])

从地形测量地图数据中实现Web磁贴检索。

QuadtreeTiles([desired_tile_form, ...])

使用Microsoft WTS四键坐标系实现Web平铺检索。

StadiaMapsTiles(apikey[, style, resolution, ...])

从stadiamaps.com检索磁贴。

Stamen([style, desired_tile_form, cache])

从Maps.stamen.com检索磁贴。

开放地理空间联盟(OGC)客户#

实现RasterSource类,这些类可以从GMS和WMSG等Web服务检索图像。

matplotlib接口可以通过 cartopy.mpl.geoaxes.GeoAxes.add_raster() 方法,以及将其用于GMS和WMSG的其他特定方法 (add_wms()add_wmts() ).以这种方式使用WMSG的示例可以在 交互式WMSG(Web地图磁贴服务) .

WFSGeometrySource(service, features[, ...])

Cartopy的Web要素服务(WFS)检索。

WMSRasterSource(service, layers[, ...])

一个可以添加到地图中的GMS图像检索器。

WMTSRasterSource(wmts, layer_name[, ...])

一个WMTS图像检索器,可以添加到地图。

航天飞机雷达地形任务(SRTM)#

航天飞机雷达地形任务(SRTM)是一项国际研究工作,旨在获得56 S至60 N的近全球尺度的数字海拔模型,以在2009年ASTER GTEM发布之前生成地球最完整的高分辨率数字地形数据库。

  • 维基百科(2012年8月)

可以通过访问SRTM数据 cartopy.io.srtm 使用下面定义的类和函数的模块。

SRTM1Source([downloader, max_nx, max_ny])

SRTM 1数据源,实现Cartopy的 RasterSource interface .

SRTM3Source([downloader, max_nx, max_ny])

SRTM 3数据源,实现Cartopy的 RasterSource interface .

SRTMDownloader(target_path_template[, ...])

提供SRTM下载机制。

read_SRTM (fh)

从给定的命名文件柄读取(y,x)海拔数据数组。

read_SRTM1 (fh)

从给定的命名文件柄读取(y,x)海拔数据数组。

read_SRTM3 (fh)

从给定的命名文件柄读取(y,x)海拔数据数组。

add_shading(elevation, azimuth, altitude)

使用太阳的方位角和高度,向SRTM海拔数据添加阴影。

基本类和函数#

这些是中的基本类 cartopy.io 新资源可以利用这些新资源来实现新的阅读器或磁贴客户端。它们共同提供了一系列子包,用于加载、保存和检索各种数据格式。

Downloader(url_template, target_path_template)

代表一个可以轻松配置的资源,它知道如何获取自己(可能通过HTTP)。

DownloadWarning 

当用户下载文件时发布 Downloader .

LocatedImage(image, extent)

在表单中定义图像和关联范围:

RasterSource ()

定义制图网格获取界面。

RasterSourceContainer(contained_source)

一个容器,简单地调用所包含的相应方法 RasterSource .

PostprocessedRasterSource(contained_source, ...)

A RasterSource 它包装另一个,然后对从包含的源获取的格栅应用后处理步骤。

fh_getter(fh[, mode, needs_filename])

打开文件的便捷功能。