Skip to main content

Fetch map from WMS server and store them as tiled web map with Slippy Map or or Google Map convention

Project description

wms-tile-get

Fetch map from WMS server and store them as tiled web map with Slippy Map or Google Map convention. Typically the resulting tiles should be with EPSG:3857 projection.

The output structure:

.
|- 10/
|  |- 544/
|  |  |- 354.png
|  |  |- 355.png
|  |- 545
|     |- 354.png
|     |- 355.png
|- 11/
|  |- ...
|
|- 12/
|  |- ...
|

The tool is similar to many others like wms-tiles-downloader but it can also accept geojson polygon as area of interest.

Install

On Unix-like platforms just use pip install

$ pip install wms-tile-get

The script wms-tile-get will be installed, otherwise scripts/wms-tile-get from a cloned code repository can also be run directly.

On Windows please see the instruction

Usage

Fetch tiles for an area (e.g. a city)

$ cd example/

$ wms-tile-get -s by_wms.json \
               -g munich.boundary.geojson \
               -z 10 \
               -o by_dop80c
  • -s defines WMS server parameters.
  • -g defines the area(s) of interest (polygon area in geojson).
  • -z defines the zoom level(s) of interest.
  • -o defines output folder.

An area or boundary shapes (e.g. munich.boundary.geojson) of named areas can be downloaded from boundary.now.

Fetch tiles for a bbox area

$ wms-tile-get -s by_wms.json \
               -b 11.43,48.11,11.63,48.26 \
               -z 10 \
               -o by_dop80c
  • -b defines bounding box with longitudes and latitudes coordinates (i.e. EPSG:4326)

More example

fetch tiles for zoom level 1 to 5, and 10 and 13. All tiles will be fetched again when the tiles already exist in the output folder.

$ wms-tile-get -s by_wms.json \
               -g munich.boundary.geojson \
               -z 1-5 10 13  \
               -o by_dop80c  \
               --force

Requirement:

Extra example

We can also only generate tile information with [x, y, z, minx, miny, maxx, maxy] tuples representing WMTS tile id and bbox.

$ cat munich.boundary.geojson       \
     | supermercado burn 18         \
     | mercantile shapes --mercator \
     | jq -c -r '[ [.id[1:-1]|split(",")|.[]|tonumber], .bbox ] | flatten | join(" ")' \
     > munich.tiles.bbox.z18.txt

The result munich.tiles.bbox.z18.txt looks like:

139445,90854,18,1280014.4756635614,6148135.933089867,1280167.3497201318,6148288.807146437
139446,90854,18,1280167.3497201318,6148135.933089867,1280320.223776702,6148288.807146437
139447,90854,18,1280320.223776702,6148135.933089867,1280473.0978332725,6148288.807146437
139448,90854,18,1280473.0978332725,6148135.933089867,1280625.971889843,6148288.807146437
139449,90854,18,1280625.971889843,6148135.933089867,1280778.8459464132,6148288.807146437
...

and then we can fetch tiles with such tile information.

$ wms-tile-get -s by_wms.json \
               -t munich.tiles.bbox.z10.txt \
               -o by_dop80c
  • -t defines tile information input file.

WMS server definition

A WMS server definition consists mainly url and parameter which is appended to url as HTTP GET method parameters.

Example: example/by_wms.json

{
  "url": "https://geoservices.bayern.de/wms/v2/ogc_dop80_oa.cgi",
  "parameter": {
    "service": "WMS",
    "request": "GetMap",
    "layers": "by_dop80c",
    "styles": "",
    "format": "image/png",
    "transparent": true,
    "version": "1.1.1",
    "width": 256,
    "height": 256,
    "srs": "EPSG:3857",
    "bbox": "1330615.7883883484,6124746.202434601,1340399.728008851,6134530.142055106"
  },
  "concurrency": 8
}

Additional options:

  • concurrency: the maximal number of parallel requests to the WMS server

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

wms-tile-get-0.3.tar.gz (7.2 kB view details)

Uploaded Source

File details

Details for the file wms-tile-get-0.3.tar.gz.

File metadata

  • Download URL: wms-tile-get-0.3.tar.gz
  • Upload date:
  • Size: 7.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.5

File hashes

Hashes for wms-tile-get-0.3.tar.gz
Algorithm Hash digest
SHA256 8a0e56c5def9e9703c1f320980a0b35bb68fbc1d7eb359702b951fe35f15d2d8
MD5 de411e42a34fad244db0360b55dd61c7
BLAKE2b-256 d27fc1aa66c0a6243966a818584f37a0066a271346a66fb8207e72bc9bfd239a

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page