File: coverages.rst

package info (click to toggle)
mapproxy 1.9.0-3%2Bdeb9u1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 6,196 kB
  • sloc: python: 33,249; xml: 6,257; makefile: 194
file content (133 lines) | stat: -rw-r--r-- 3,749 bytes parent folder | download | duplicates (2)
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
.. _coverages:

Coverages
=========

With coverages you can define areas where data is available or where data you are interested in is.
MapProxy supports coverages for :doc:`sources <sources>` and in the :doc:`mapproxy-seed tool <seed>`. Refer to the corresponding section in the documentation.


There are three different ways to describe a coverage.

- a simple rectangular bounding box,
- a text file with one or more (multi)polygons in WKT format,
- (multi)polygons from any data source readable with OGR (e.g. Shapefile, GeoJSON, PostGIS)


Requirements
------------

If you want to use polygons to define a coverage, instead of simple bounding boxes, you will also need Shapely and GEOS. For loading polygons from shapefiles you'll also need GDAL/OGR.

MapProxy requires Shapely 1.2.0 or later and GEOS 3.1.0 or later.

On Debian::

  sudo aptitude install libgeos-dev libgdal-dev
  pip install Shapely


Configuration
-------------

All coverages are configured by defining the source of the coverage and the SRS.
The configuration of the coverage depends on the type. The SRS can allways be configured with the ``srs`` option.

.. versionadded:: 1.5.0
    MapProxy can autodetect the type of the coverage. You can now use ``coverage`` instead of the ``bbox``, ``polygons`` or ``ogr_datasource`` option.
    The old options are still supported.

Coverage Types
--------------

Bounding box
""""""""""""

For simple box coverages.

``bbox`` or ``datasource``:
    A simple BBOX as a list, e.g: `[4, -30, 10, -28]` or as a string `4,-30,10,-28`.

Polygon file
""""""""""""

Text files with one WKT polygon or multi-polygon per line.
You can create your own files or use `one of the files we provide for every country <http://mapproxy.org/static/polygons/>`_. Read `the index <http://mapproxy.org/static/polygons/0-fips-codes.txt>`_ to find your country.

``datasource``:
 The path to the polygon file. Should be relative to the proxy configuration or absolute.

OGR datasource
""""""""""""""

Any polygon datasource that is supported by OGR (e.g. Shapefile, GeoJSON, PostGIS).


``datasource``:
  The name of the datasource. Refer to the `OGR format page
  <http://www.gdal.org/ogr/ogr_formats.html>`_ for a list of all supported
  datasources. File paths should be relative to the proxy configuration or absolute.

``where``:
  Restrict which polygons should be loaded from the datasource. Either a simple where
  statement (e.g. ``'CNTRY_NAME="Germany"'``) or a full select statement. Refer to the
  `OGR SQL support documentation <http://www.gdal.org/ogr/ogr_sql.html>`_. If this
  option is unset, the first layer from the datasource will be used.


Examples
--------

sources
"""""""

Use the ``coverage`` option to define a coverage for a WMS or tile source.

::

  sources:
    mywms:
      type: wms
      req:
        url: http://example.com/service?
        layers: base
      coverage:
        bbox: [5, 50, 10, 55]
        srs: 'EPSG:4326'


mapproxy-seed
"""""""""""""

To define a seed-area in the ``seed.yaml``, add the coverage directly to the view.

::

  coverages:
    germany:
      datasource: 'shps/world_boundaries_m.shp'
      where: 'CNTRY_NAME = "Germany"'
      srs: 'EPSG:900913'

.. index:: PostGIS, PostgreSQL

Here is the same example with a PostGIS source::

  coverages:
    germany:
      datasource: "PG: dbname='db' host='host' user='user'
    password='password'"
      where: "select * from coverages where country='germany'"
      srs: 'EPSG:900913'


.. index:: GeoJSON

And here is an example with a GeoJSON source::

  coverages:
    germany:
      datasource: 'boundary.geojson'
      srs: 'EPSG:4326'

See `the OGR driver list <http://www.gdal.org/ogr/ogr_formats.html>`_ for all supported formats.