Code Monkey home page Code Monkey logo

landez's Introduction

Landez manipulates tiles, builds MBTiles, does tiles compositing and arrange tiles together into single images.

Tiles can either be obtained from a remote tile service URL, from a local Mapnik stylesheet, a WMS server or from MBTiles files.

For building MBTiles, Landez embeds mbutil from Mapbox https://github.com/mapbox/mbutil at the final stage. The land covered is specified using a list of bounding boxes and zoom levels.

https://pypip.in/v/landez/badge.png https://pypip.in/d/landez/badge.png https://travis-ci.org/makinacorpus/landez.png https://coveralls.io/repos/makinacorpus/landez/badge.png

INSTALL

Landez is pure python and has no external dependency.

sudo easy_install landez

However, it requires mapnik if the tiles are rendered locally.

sudo aptitude install python-mapnik

And PIL to blend tiles together or export arranged tiles into images.

sudo aptitude install python-imaging

USAGE

Building MBTiles files

Remote tiles

Using a remote tile service (OpenStreetMap.org by default):

import logging
from landez import MBTilesBuilder

logging.basicConfig(level=logging.DEBUG)

mb = MBTilesBuilder(cache=False)
mb.add_coverage(bbox=(-180.0, -90.0, 180.0, 90.0),
                zoomlevels=[0, 1])
mb.run()

Please respect Tile usage policies <http://wiki.openstreetmap.org/wiki/Tile_usage_policy>

Local rendering

Using mapnik to render tiles:

import logging
from landez import MBTilesBuilder

logging.basicConfig(level=logging.DEBUG)

mb = MBTilesBuilder(stylefile="yourstyle.xml", filepath="dest.mbtiles")
mb.add_coverage(bbox=(-180.0, -90.0, 180.0, 90.0),
                zoomlevels=[0, 1])
mb.run()

And with UTFGrids:

import logging
from landez import MBTilesBuilder

logging.basicConfig(level=logging.DEBUG)

mb = MBTilesBuilder(stylefile="yourstyle.xml",
                    grid_fields=["field1", "field2", "field3", ...] ,
                    filepath="dest.mbtiles")
mb.add_coverage(bbox=(-180, -90, 180, 90),
                zoomlevels=[0, 1, 2, 3])
mb.run()

From an other MBTiles file

import logging
from landez import MBTilesBuilder

logging.basicConfig(level=logging.DEBUG)

mb = MBTilesBuilder(mbtiles_file="yourfile.mbtiles", filepath="dest.mbtiles")
mb.add_coverage(bbox=(-180.0, -90.0, 180.0, 90.0),
                zoomlevels=[0, 1])
mb.run()

From a WMS server

mb = MBTilesBuilder(wms_server="http://yourserver.com/geoserver/wms",
                    wms_layers=["ign:departements"],
                    wms_options=dict(format="image/png",
                                     transparent=True),
                    filepath="dest.mbtiles")
mb.add_coverage(bbox=([-0.9853,43.6435.1126,44.0639]))
mb.run()

Blend tiles together

Merge multiple sources of tiles (URL, WMS, MBTiles, Mapnik stylesheet) together. (requires python PIL)

For example, build a new MBTiles by blending tiles of a MBTiles on top of OpenStreetMap tiles :

mb = MBTilesBuilder(filepath="merged.mbtiles")
overlay = TilesManager(mbtiles_file="carto.mbtiles")
mb.add_layer(overlay)
mb.run()

Or composite a WMS layer with OpenStreetMap using transparency (40%):

mb = MBTilesBuilder(wms_server="http://yourserver.com/geoserver/wms",
                    wms_layers=["img:orthophoto"])
overlay = TilesManager(remote=True)
mb.add_layer(overlay, 0.4)
mb.run()

Export Images

Assemble and arrange tiles together into a single image. (requires python PIL)

Specify tiles sources in the exact same way as for building MBTiles files.

import logging
from landez import ImageExporter

logging.basicConfig(level=logging.DEBUG)

ie = ImageExporter(mbtiles_file="yourfile.mbtiles")
ie.export_image(bbox=(-180.0, -90.0, 180.0, 90.0), zoomlevel=3, imagepath="image.png")

Add post-processing filters

Convert map tiles to gray scale, more suitable for information overlay :

from landez.filters import GrayScale

ie = ImageExporter()
ie.add_filter(GrayScale())

Replace a specific color by transparent pixels (i.e. color to alpha, a-la-Gimp) :

from landez.filters import ColorToAlpha

overlay = TileManager()
overlay.add_filter(ColorToAlpha('#ffffff'))  # white will be transparent

ie = ImageExporter()
ie.add_layer(overlay)
...

Extract MBTiles content

from landez.sources import MBTilesReader

mbreader = MBTilesReader("yourfile.mbtiles")

# Metadata
print mbreader.metadata()

# Zoom levels
print mbreader.zoomlevels()

# Image tile
with open('tile.png', 'wb') as out:
    out.write(mbreader.tile(z, x, y))

# UTF-Grid tile
print mbreader.grid(z, x, y, 'callback')

Manipulate tiles

from landez import MBTilesBuilder

# From a TMS tile server
# tm = TilesManager(tiles_url="http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png")

# From a MBTiles file
tm = TilesManager(mbtiles_file="yourfile.mbtiles")

tiles = tm.tileslist(bbox=(-180.0, -90.0, 180.0, 90.0),
                     zoomlevels=[0, 1])
for tile in tiles:
    tilecontent = tm.tile(tile)  # download, extract or take from cache
    ...

Cache tiles are stored using TMS scheme by default (with y value flipped). It can be changed to WMTS (a.k.a xyz) :

tm = TilesManager(your_sources_options, cache=True, cache_scheme="wmts")

Run tests

Run tests with nosetests (if you are working in a virtualenv, don't forget to install nose in it!):

cd landez
nosetests

The Mapnik stylesheet for the test about grid content comes from <https://github.com/springmeyer/gridsforkids>

AUTHORS

http://depot.makina-corpus.org/public/logo.gif

LICENSE

  • Lesser GNU Public License

landez's People

Contributors

dispiste avatar ebrehault avatar kiorky avatar lepetittim avatar leplatrem avatar osuchw avatar seandepagnier avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

landez's Issues

Lack of help if coverage too large

Code :

import logging
from landez import MBTilesBuilder
from landez import TilesManager


logging.basicConfig(level=logging.DEBUG)

mb = MBTilesBuilder(mbtiles_file="/home/guillaume/Tiles/Merge/tiles.mbtiles",
                    cache=True, filepath="/home/guillaume/Tiles/Merge/merged.mbtiles")
overlay = TilesManager(mbtiles_file="/home/guillaume/Tiles/Merge/tiles_kml_v3.mbtiles")
mb.add_layer(overlay)
mb.add_coverage(bbox=(5.0826,42.4397,5.6940,43.2806),
                zoomlevels=range(10,18))
mb.run()

Error :

WARNING:landez.tiles:Could not extract tile (15, 16858, 12044) from /home/guillaume/Tiles/Merge/tiles_kml_v3.mbtiles
DEBUG:landez.cache:Save 857 bytes to /tmp/landez/tilesmbtilestileskmlv3mbtiles10/15/16858/20723.png
DEBUG:landez.sources:Extract tile (16, 33704, 24120)
DEBUG:landez.sources:Execute query 'SELECT tile_data FROM tiles WHERE zoom_level=? AND tile_column=? AND tile_row=?;' ((16, 33704, 41415),)
Traceback (most recent call last):
File "merge_tiles.py", line 14, in
mb.run()
File "/usr/local/lib/python2.7/dist-packages/landez-2.0.4.dev0-py2.7.egg/landez/tiles.py", line 293, in run
self._gather((z, x, y))
File "/usr/local/lib/python2.7/dist-packages/landez-2.0.4.dev0-py2.7.egg/landez/tiles.py", line 327, in gather
tilecontent = self.tile((z, x, y))
File "/usr/local/lib/python2.7/dist-packages/landez-2.0.4.dev0-py2.7.egg/landez/tiles.py", line 160, in tile
output = self.reader.tile(z, x, y)
File "/usr/local/lib/python2.7/dist-packages/landez-2.0.4.dev0-py2.7.egg/landez/sources.py", line 96, in tile
raise ExtractionError(
("Could not extract tile %s from %s") % ((z, x, y), self.filename))
landez.sources.ExtractionError: Could not extract tile (16, 33704, 24120) from /home/guillaume/Tiles/Merge/tiles.mbtiles

Making Blank mbtiles

My process is to make 1 mbtiles file for each WMS i need (20) and then merge those files together.
To do so i need to get at least one mbtiles (use as base) with my full project coverage (see #19 ).

But calling one WMS on a coverage that is not relevent make the process very slow (so many calls made just for a blank png). So i wonder if building a "blank" mbtiles would help me.

=> is it possible to create mbitiles over a predefined bbox, for n zoomlevels and only blank tiles ? In my process i would have 1 "blank" mbtiles that will be used to merge 20 "real" mbtiles.

AttributeError if no coverage provided

DEBUG:landez.tiles:Clean-up /tmp/landez/composite_z12_15_2
Traceback (most recent call last):
  File "./composite.py", line 13, in <module>
    mb.run()
  File "/usr/local/lib/python2.7/dist-packages/landez-2.0.3.dev0-py2.7.egg/landez/tiles.py", line 271, in run
    metadata = bottomlayer.reader.metadata()
AttributeError: 'tuple' object has no attribute 'reader'

Cannot import name MBTilesBuilder

I'm trying the first example of the readme on Debian wheezy:

 $ sudo easy_install landez
Searching for landez
Reading http://pypi.python.org/simple/landez/
Best match: landez 2.3.0
Downloading https://pypi.python.org/packages/source/l/landez/landez-2.3.0.zip#md5=b0ae5f3fbdcc81b7a7bc42283da6db2a
Processing landez-2.3.0.zip
Running landez-2.3.0/setup.py -q bdist_egg --dist-dir /tmp/easy_install-SNDc2Y/landez-2.3.0/egg-dist-tmp-ixZLkU
Adding landez 2.3.0 to easy-install.pth file

Installed /usr/local/lib/python2.7/dist-packages/landez-2.3.0-py2.7.egg
Processing dependencies for landez
Searching for mbutil
Reading http://pypi.python.org/simple/mbutil/
Best match: mbutil 0.2.0
Downloading https://pypi.python.org/packages/source/m/mbutil/mbutil-0.2.0.tar.gz#md5=959fee1068a40eafda7159e66c547808
Processing mbutil-0.2.0.tar.gz
Running mbutil-0.2.0/setup.py -q bdist_egg --dist-dir /tmp/easy_install-a3A01Q/mbutil-0.2.0/egg-dist-tmp-BfKAX4
zip_safe flag not set; analyzing archive contents...
Adding mbutil 0.2.0 to easy-install.pth file
Installing mb-util script to /usr/local/bin

Installed /usr/local/lib/python2.7/dist-packages/mbutil-0.2.0-py2.7.egg
Finished processing dependencies for landez

 $ python landez.py
Traceback (most recent call last):
  File "landez.py", line 2, in <module>
    from landez import MBTilesBuilder
  File "/tmp/landez.py", line 2, in <module>
    from landez import MBTilesBuilder
ImportError: cannot import name MBTilesBuilder

I checked and the module is correctly set up in /usr/local/lib/python2.7/dist-packages/ so I don't get it.

Mapnik signature mismatch error

Hi,

I am trying to use landez to render maps in MBTiles using Mapnik XMl file as the input. I am getting the below error. Just wanted to check if this is a known issue before I try to debug it.

Traceback (most recent call last):
File "render_mbtiles.py", line 131, in
mb.run()
File "/usr/local/lib/python2.7/dist-packages/landez-2.0.3.dev0-py2.7.egg/landez/tiles.py", line 290, in run
self._gather((z, x, y))
File "/usr/local/lib/python2.7/dist-packages/landez-2.0.3.dev0-py2.7.egg/landez/tiles.py", line 324, in _gather
tilecontent = self.tile((z, x, y))
File "/usr/local/lib/python2.7/dist-packages/landez-2.0.3.dev0-py2.7.egg/landez/tiles.py", line 157, in tile
output = self.reader.tile(z, x, y)
File "/usr/local/lib/python2.7/dist-packages/landez-2.0.3.dev0-py2.7.egg/landez/sources.py", line 234, in tile
return self.render(proj.tile_bbox((z, x, y)))
File "/usr/local/lib/python2.7/dist-packages/landez-2.0.3.dev0-py2.7.egg/landez/sources.py", line 245, in render
self._mapnik = mapnik.Map(width, height)
Boost.Python.ArgumentError: Python argument types in
Map.init(Map, int, NoneType)
did not match C++ signature:
init(_object*, int width, int height)
init(_object*, int width, int height, std::string srs)

Thanks
Nishanth

Report progress callback

I'm integrating your library to a Kivy graphical application.
I would like the user to know roughly the progress of the process.
I guess this could be achieved with a callback we could pass to the MBTilesBuilder.run() method.

Add generation of GeoJSON tiles

It could be interesting to be able to generate GeoJSON tiles from a datasource (shapefile, GeoJSON, database, ...) with Landez.

So I think we have to get the intersection of a bounding box and each feature of the GeoJSON. It may be possible using Shapely:

>>> from shapely.geometry import box
>>> from shapely.geometry import Polygon
>>> from shapely.geometry import LineString
>>> a = LineString([(0, 0), (1,2), (2,2)])
>>> b = box(0.0, 0.0, 1.0, 1.0)
>>> tile_content = a.intersection(b)

tile_content.coords contains:
(0.0, 0.0)
(0.5, 1.0)

Even if it does not seem that simple when working with polygons... (Intersection of a polygon (the bbox) and another one (a geometry of the GeoJSON) could give a polygon, a line, a point, multiple lines or multiple points)…

And to read/write the datasource: there is Fiona.

Problem with compositing two mbtiles

This code tries to composite tiles from two mbtiles and make into a composite:

import logging
from landez import MBTilesBuilder, TilesManager

logging.basicConfig(level=logging.DEBUG)

mb = MBTilesBuilder(filepath="composite_z12_15.mbtiles", mbtiles_file="OSMBrightZ12_15_label_only.mbtiles")  # base layer
overlay = TilesManager(mbtiles_file="watercolor_z12_15.mbtiles")
# if no coverage the bottom layer, but I need this to avoiding running into another landez bug
mb.add_coverage(bbox=(-122.1099,37.4531,-121.8768,37.6107), zoomlevels=range(12,16)) # 12 to 15
mb.add_layer(overlay)
mb.run()

This runs into the error of:

DEBUG:landez.sources:Execute query 'SELECT tile_data FROM tiles WHERE zoom_level=? AND tile_column=? AND tile_row=?;' ((15, 5284, 20081),)
Traceback (most recent call last):
File "./composite.py", line 13, in
mb.run()
File "/usr/local/lib/python2.7/dist-packages/landez-2.0.3.dev0-py2.7.egg/landez/tiles.py", line 288, in run
self._gather((z, x, y))
File "/usr/local/lib/python2.7/dist-packages/landez-2.0.3.dev0-py2.7.egg/landez/tiles.py", line 322, in gather
tilecontent = self.tile((z, x, y))
File "/usr/local/lib/python2.7/dist-packages/landez-2.0.3.dev0-py2.7.egg/landez/tiles.py", line 155, in tile
output = self.reader.tile(z, x, y)
File "/usr/local/lib/python2.7/dist-packages/landez-2.0.3.dev0-py2.7.egg/landez/sources.py", line 106, in tile
raise ExtractionError(
("Could not extract tile %s from %s") % ((z, x, y), self.filename))
landez.sources.ExtractionError: Could not extract tile (15, 5284, 12686) from OSMBrightZ12_15_label_only.mbtiles

Where as my previous code (which I mistakenly written with two overlays) ran fine:

logging.basicConfig(level=logging.DEBUG)
mb = MBTilesBuilder(filepath="composite_z12_15.mbtiles")
overlay = TilesManager(mbtiles_file="OSMBrightZ12_15_label_only.mbtiles")
overlay2 = TilesManager(mbtiles_file="watercolor_z12_15.mbtiles")

# if no coverage the bottom layer, but I need this to avoiding running into another landez bug
mb.add_coverage(bbox=(-122.1099,37.4531,-121.8768,37.6107), zoomlevels=range(12,16)) # 12 to 15

mb.add_layer(overlay2)
mb.add_layer(overlay)
mb.run()

I think the first code is grabbing the wrong tile number.

Use metatiles

Is there a way to use "meta tiles" while capturing a WMS to make the mbtile file ?
It could help to avoid labels cropping issues : getting larger image and the cutting to fit le tile normal size and bbox.

Merging many mbtiles issue

It seems that merging many mbtiles is limited by the name computed by lander for its temp directory.

using 75101.mbtiles up to 75120.mbtiles (20 files in total) fails if more than 10 files used.
using 1.mbtiles up to 20.mbtiles fails for 12 or 13.

Loading mapnik stylesheets

I am using mapnik to render tiles locally, but Landez fails to load the mapnik stylesheet. This is because strict mode is used, in sources.py:

# Load style XML
mapnik.load_map(self._mapnik, self.stylefile, True)

The last boolean parameter should be omitted, or at least configurable.

Background information: I am using openstreetmap-carto and the developers decided to add both Unifont Medium and unifont Medium to cover the capitalization differences on several systems. Also, I am missing some (mainly south-east asian character) fonts which are not really required for the maps I am rendering.
I am fine with a number of warnings related to the fonts but in strict mode I can't load the stylesheet at all. If this was introduced to avoid excessive logging by mapnik it may be better to disable logging with:
mapnik.logger.set_severity(getattr(mapnik.severity_type, 'None'))

Render number of argument wrong

Trying the second example (local rendering) gives me this:

Traceback (most recent call last):
File "./example2.py", line 9, in
mb.run()
File "/usr/local/lib/python2.7/dist-packages/landez-2.0.3.dev0-py2.7.egg/landez/tiles.py", line 290, in run
self._gather((z, x, y))
File "/usr/local/lib/python2.7/dist-packages/landez-2.0.3.dev0-py2.7.egg/landez/tiles.py", line 324, in _gather
tilecontent = self.tile((z, x, y))
File "/usr/local/lib/python2.7/dist-packages/landez-2.0.3.dev0-py2.7.egg/landez/tiles.py", line 157, in tile
output = self.reader.tile(z, x, y)
File "/usr/local/lib/python2.7/dist-packages/landez-2.0.3.dev0-py2.7.egg/landez/sources.py", line 244, in tile
return self.render(proj.tile_bbox((z, x, y)))
TypeError: render() takes at least 3 arguments (2 given)

(The line number is not the same as the trunk because I modified it to take mapnik2 as well)

WMS example URL questions, posible error?

Hi, Im reproducing the wms example and have ran into some strange behaviour:
trying to run the script I notice in the URL that Landez generates includes an option - scheme=wmts - that I have not specified. Im clearly using wms. Why is that?

Slow to render mbtiles compared to Tilemill

I found landez very slow, as in days, compared to Tilemill to render a 6-15z custom OSM baselayer of southern British Columbia, Canada. Tillmill took 3 days, and I shut down landez after 5 while it was still on z15.

Are there any options or methods to increase the rendering speed?

Is there a way to "parallel" process the rendering, aka render Z6 as process, render Z7 as four processes, Z8 as 16 processes, ... , then combine all the tiles at end? Does this even make sense? Could the code be rewritten in Twisted to perform faster? Or maybe the bottlenecks are elsewhere?

Peter

cannot export images that cross 180 longitude

It would be nice to be able to export images that cross the date line, but currently there is no way to do this, as longitudes are bounded to -180 to 180, and the logic also doesn't deal with a larger minlon and smaller maxlon.

Do not crash if downloading a tile temporary fails

When downloading a bunch of tiles to create an mbtiles file, the process is interrupted (program crash) if downloading one tile fails for an unknown reason (probably a temporary server error or something). It would be nice if this error would just be treated transparently by either retrying a few times or ignoring that tile (and reporting that tiles were skipped in the end).

Here's the stacktrace of such an event:

DEBUG:landez.tiles:tile method called with [15, 17144, 11422]
DEBUG:landez.sources:Request WMS tile (15, 17144, 11422)
DEBUG:landez.sources:Download 'https://...'
WARNING:landez.tiles:''
Traceback (most recent call last):
  File "dtk.py", line 30, in <module>
    mb.run()
  File "/usr/local/lib/python2.7/dist-packages/landez-2.4.0-py2.7.egg/landez/tiles.py", line 322, in run
    self._gather((z, x, y))
  File "/usr/local/lib/python2.7/dist-packages/landez-2.4.0-py2.7.egg/landez/tiles.py", line 374, in _gather
    tilecontent = self.tile((z, x, y))
  File "/usr/local/lib/python2.7/dist-packages/landez-2.4.0-py2.7.egg/landez/tiles.py", line 172, in tile
    output = self.reader.tile(z, x, y)
  File "/usr/local/lib/python2.7/dist-packages/landez-2.4.0-py2.7.egg/landez/sources.py", line 231, in tile
    f = urllib2.urlopen(request)
  File "/usr/lib/python2.7/urllib2.py", line 154, in urlopen
    return opener.open(url, data, timeout)
  File "/usr/lib/python2.7/urllib2.py", line 429, in open
    response = self._open(req, data)
  File "/usr/lib/python2.7/urllib2.py", line 447, in _open
    '_open', req)
  File "/usr/lib/python2.7/urllib2.py", line 407, in _call_chain
    result = func(*args)
  File "/usr/lib/python2.7/urllib2.py", line 1241, in https_open
    context=self._context)
  File "/usr/lib/python2.7/urllib2.py", line 1201, in do_open
    r = h.getresponse(buffering=True)
  File "/usr/lib/python2.7/httplib.py", line 1121, in getresponse
    response.begin()
  File "/usr/lib/python2.7/httplib.py", line 438, in begin
    version, status, reason = self._read_status()
  File "/usr/lib/python2.7/httplib.py", line 402, in _read_status
    raise BadStatusLine(line)
httplib.BadStatusLine: ''

Color to alpha is applied to all layers indifferently

Code :

import logging
from landez import MBTilesBuilder
from landez import TilesManager
from landez.filters import ColorToAlpha


logging.basicConfig(level=logging.DEBUG)

mb = MBTilesBuilder(mbtiles_file="/home/guillaume/Tiles/Merge/tiles.mbtiles",
                    cache=True, filepath="/home/guillaume/Tiles/Merge/blended.mbtiles")
overlay = TilesManager(mbtiles_file="/home/guillaume/Tiles/Merge/tiles_kml_v3.mbtiles")
overlay.add_filter(ColorToAlpha('#ffffff'))
mb.add_layer(overlay)
mb.add_coverage(bbox=(4.9919,42.8865,5.6985,43.2997),
                zoomlevels=range(10,18))
mb.run()

This is supposed to blend osm maps (tiles.mbtiles) and a layer containing colored areas (tiles_kml_v3.mbtiles) with #ffffff to alpha in the second layer. The fact is, white is sent to alpha in both layers but only in the areas defined in the second layer. This is the result :
648
(Yes, with the white background on github, it doesn't change anything, it is more evident on a non-plain background, on GIMP for instance)

WMS isn't working

assert request.headers should be > assert request.headers.get('Content-Type')

Wrong tilerow when download with boundingbox

I'm downloading this tile to a MBTiles:
http://tile.thunderforest.com/cycle/4/8/5.png
So the image has this Parameter:
zoomlevel: 4
tilecolumn: 8
tilerow: 5

I have following code:

from landez import MBTilesBuilder
mb = MBTilesBuilder(tiles_url="http://tile.thunderforest.com/cycle/{z}/{x}/{y}.png",filepath="C:\\Temp\\test.mbtiles")
mb.add_coverage(bbox=(8.0, 47.0, 8.1, 47.1), zoomlevels=[4])
mb.run()

When I extract the tile out of the MBTiles, I get the correct Image but the wrong filename; 10.png instead of 5.png

By examining the mbtiles file I see following
zoomlevel: 4
tilecolumn: 8
tilerow: 10

Why did the tilerow messed up? I have even tried using cache_scheme="wmts" but this did not change anything.

Any Idea how to get this fixed?

Skip Missing Tile!

I am trying to convert an Mbtile file to a single raster. Landez gives me this error:
ExtractionError: Could not extract tile (12, 2644, 1692) from Shiraz.sqlite
which simply means the mentioned tile is missing in the mbtile.
I want to skip this tile and I want to add no data pixels instead that tile ( I'm exporting to Png).
Here is my simple code:

import logging
from landez import ImageExporter

logging.basicConfig(level=logging.DEBUG)

ie = ImageExporter(mbtiles_file="Shi.sqlite") 

ie.export_image(bbox=(52.3615993,29.461357,52.682949,29.85397), zoomlevel=12, imagepath="shi12.png")

Is is possible to do so with landez?
Thanks

Use namedtuple for tiles

   from collections import namedtuple

   Tile = namedtuple('Tile', 'z x y')
   t = Tile(x=2, y=3, z=1)
   z, x, y = t
   t = Tile(z, x, y)
   assert t.x == t[1]


Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.