The Lat-Lon Tiler is a small tool to create map tiles in sphericalmercator projection for the use with online map libraries likeLeaflet, OpenLayers, Mapbox etc...
Project description
lltiler
The Lat-Lon Tiler is a small tool to create map tiles in spherical Mercator projection for the use with online map libraries like Leaflet, OpenLayers, Mapbox etc...
usage
In order to create tiles with lltiler, the user must provide a function which can compute colors for given pairs of latitude and longitude.
A typical example would be a function which interpolates an image onto the given latitudes and longitudes.
This method is used to generate the most detailed level of tiles in a first step.
In an optional second step, multiple tile sets generated using LLTiler
can be combined using the overlay_tiles
utility.
In the last step, coarsened tiles are generated in successive steps from the most detailed level up to global scale using the pyramid_step
utility.
The second and third step can be executed automatically using the generate_tile_makefile
utility and GNU make.
1 generate detailed tiles
A user supplied function and a lat/lon bounding box must then be handed to the render method of the LLTiler
object, which will then compute the necessary tiles and calls the given function repeatedly until all tiles have been generated.
An example is shown below:
from lltiler import LLTiler
import matplotlib.pylab as plt
import matplotlib.colorbar
lat_min = 16.
lon_min = 45.
lat_max = 19.
lon_max = 48.
cmap = plt.get_cmap("gray")
def f(lat, lon):
rel_lat = (lat - lat_min) / (lat_max - lat_min)
rel_lon = (lon - lon_min) / (lon_max - lon_min)
valid = (rel_lat >= 0) & (rel_lat < 1) & (rel_lon >= 0) & (rel_lon < 1)
colors = cmap(rel_lat, bytes=True)
colors[..., -1] = 255 * valid
return colors
t = LLTiler("temp_maps/gray", size_hint=1000.)
t.render(((lat_min, lon_min), (lat_max, lon_max)), f, show_progress=True)
Note that show_progress=True
additionally requires the tqdm
package.
2 (optional) combine multiple overlapping tiles
If multiple tilesets have been generated using the first step and these tilesets should be combined to one tileset, the overlay_tiles
utility can be used to paint multiple images on top of each other.
This is of course only useful if the image which is painted on top contains transparent regions where parts of the lower image can be seen through.
overlay_tiles <output_image> <input_image_1> <input_image_2> ... <input_image_n>
3 generate image pyramid
To generate coarser resolution images from detailed images, the pyramid_step
utility can be used.
It takes up to four adjacent images (missing images are assumed to be entirely transparent) stacks these images together and generates a new image with half of the original resolution.
pyramid_step <output_image> <top_left> <bottom_left> <top_right> <bottom_right>
Missing images must be denoted by a -
.
automate steps 2 and 3
The generate_tile_makefile
utility can be used to automate steps 2 and 3:
generate_tile_makefile <base_level> <input_folder> <output_folder> | make -f- -j
base_level
must be the tile-level for which the tiles have been generated in step 1.
input_folder
must be a folder which includes one folder per input tileset.
output_folder
is the folder into which the resulting tiles should be written.
Note that in the above command generates a makefile which is directly passed to make and then executed in parallel.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file lltiler-0.0.2.tar.gz
.
File metadata
- Download URL: lltiler-0.0.2.tar.gz
- Upload date:
- Size: 24.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2e0148cf29a41ee5c2cd72339a07b68c0712d5087dd29138c30f1a3b4a4ad518 |
|
MD5 | 51d52938162009a1dbcac6fab2ae84e4 |
|
BLAKE2b-256 | 94abce03ecab06314cef2600b680261fd7caa3aa14aa8a3488b105ea1add9b72 |
File details
Details for the file lltiler-0.0.2-py3-none-any.whl
.
File metadata
- Download URL: lltiler-0.0.2-py3-none-any.whl
- Upload date:
- Size: 8.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a75c57dac084cd5d852e57d28518d0d3ce88abaf9be891a7e6bb2388a6ec650e |
|
MD5 | f45544e38c8a96d7492bd0ce30ec23e9 |
|
BLAKE2b-256 | 5dea7b427646befb2c768540b92017d731c61742f0b6b970eb25ba1d37c524a0 |