https://github.com/hackergrrl/tile-dl
https://github.com/hackergrrl/tile-dl
Last synced: 9 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/hackergrrl/tile-dl
- Owner: hackergrrl
- Created: 2018-02-26T23:53:36.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-02-27T00:10:48.000Z (over 8 years ago)
- Last Synced: 2024-05-13T16:25:56.626Z (about 2 years ago)
- Language: JavaScript
- Size: 7.81 KB
- Stars: 7
- Watchers: 1
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# tile-dl
> Download map tiles covering an area from a URL template.
There exist various web services that act as providers for map tile data. This
could be vector tiles or maybe traditional raster image tiles. Usually they
follow a predictable URL structure like
`http://foo-service.com/tiles/{zoom}/{x}/{y}.jpg`. If you know this URL
template, you can use `tile-dl` to download all tiles within an area from this
service and store them locally.
This can be very useful for offline storage of map data for e.g. an area you'll
be traveling to.
## Install
With [npm](https://npmjs.org/) installed, run
```
$ npm install --global tile-dl
```
## Usage
```
USAGE: tile-dl -t 'URL' -o 'OUTPUT' --lat LAT --lon LON --radius R --zoom ZOOM
Recursively downloads tile data (vector, satellite, etc), given a server URL
template.
--template|-t: A URL template. Must contain the markers {x}, {y}, and {zoom}.
e.g. http://some.mapservice.com/{zoom}/{x}/{y}.jpg
--output|-o : The directory output template. For example, '{z}/{y}/{x}.png'
will create a directory hierarchy with 'z' at the top, 'y'
inside that, and fill each innermost directory with 'z.png'
files.
--lat : The center latitude to download tiles from.
--lon : The center longitude to download tiles from.
--radius|-r : The radius, in kilometers, to download around the center
latitude and longitude coordinates.
--zoom|-z : The zoom level of tiles to be downloaded. Be wary: zoom level
N+1 contains 4 times as many tiles as zoom level N.
```
## Example
Let's download the Oakland, California area at zoom level 12:
```
$ echo 'https://c.tiles.mapbox.com/v4/digitalglobe.0a8e44ba/{z}/{x}/{y}.png?access_token=pk.eyJ1IjoiZGlnaXRhbGdsb2JlIiwiYSI6ImNqOGRmNW9qZjBudmgzMnA1a294OGRtNm8ifQ.06mo-nDisy4KmqjYxEVwQw' > template
$ tile-dl -t "$(cat template)" --lon=-122.2632601 --lat=37.8027446 --radius 0.1 -z 12 -o {z}/{y}/{x}.png
```
this will download map tiles at zoom level in a 0.1km radius around
approximately `(37.8,122.2)` and write them to a folder in the current directory
called `12/`. You'll have the following file structure:
```
├── 1581
│ ├── 655.png
│ ├── 656.png
│ ├── 657.png
│ └── 658.png
├── 1582
│ ├── 655.png
│ ├── 656.png
│ ├── 657.png
│ └── 658.png
├── 1583
│ ├── 655.png
│ ├── 656.png
│ ├── 657.png
│ └── 658.png
└── 1584
├── 655.png
├── 656.png
├── 657.png
└── 658.png
```
## License
ISC