landez : introducing new features of our tiles toolbox
source link: https://blog.mathieu-leplatre.info/landez-introducing-new-features-of-our-tiles-toolbox.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
landez : introducing new features of our tiles toolbox
Fri 24 February 2012landez started as a very small toolbox to build MBTiles files specifying bounding boxes and zoom levels. We have been using it for several GIS projects at Makina Corpus, and can tell it's reliable !
Landez is pure python and follows the KISS principle. It has optional requirements on PIL and mapnik for compositing, tile arranging or rendering.
Recently, we've added many extra cool features, which deserve highlight !
Simple WMS support
With landez, you can store your WMS layers into MBTiles files ! It will request the WMS /images and save them into tiles on disk ! You can then enjoy the power of MBTiles files : transport, speed, ...
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]), zoomlevels=range(18)) mb.run()
Tiles compositing
This is the killer feature ! With landez, you can now merge multiple sources of tiles (URL, WMS, MBTiles, Mapnik stylesheet) together !
For example, build a new MBTiles file by blending tiles of another on top of OpenStreetMap tiles :
mb = MBTilesBuilder(remote=True, filepath="merged.mbtiles") overlay = TilesManager(mbtiles_file="carto.mbtiles") mb.add_layer(overlay) mb.run()
Simply make a composite a WMS layer with OpenStreetMap using transparency ! You might find this useful for compositing satellite image with street maps :
mb = MBTilesBuilder(wms_server="http://yourserver.com/geoserver/wms", wms_layers=["img:orthophoto"], filepath="wms_osm.mbtiles") overlay = TilesManager(remote=True) mb.add_layer(overlay, 0.4) # 40% mb.run()
Arrange tiles into single /images
This feature can be very useful for printing tiled maps or have a quick overview of your compositing results !
Refer to any source of tiles, like you would do with MBTilesBuilder, add layers if you like and export the image !
ie = ImageExporter(tiles_url='http://server/tile/{z}/{x}/{y}.png') ... ... ie.export_image(bbox=(-180.0, -90.0, 180.0, 90.0), zoomlevel=3, imagepath="image.png")
MBTiles content reading
landez can now read MBTiles content !
We could proudly add it to the list of implementations for the MBTiles spec and UTF-Grid spec !
Use MBTiles files like any tile source :
mb = MBTilesBuilder(mbtiles_file="yourfile.mbtiles")
...extract single image or UTF-Grid tiles :
from landez.reader 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(reader.tile(z, x, y)) # UTF-Grid tile print reader.grid(z, x, y, 'callback')
Next steps...
The code has grown quickly and deserves a good refactoring, which is being done in a separate branch on GitHub ! The goal is to keep the same simple API, better modularity, increase tests coverage...
If you are wiling to participate, feel welcome !
#python, #mapbox, #gis, #landez - Posted in the Dev category
© Copyright 2020 by Mathieu Leplatre. mnmlist Theme
Content licensed under the Creative Commons attribution-noncommercial-sharealike License.
Recommend
-
29
-
9
landez : tiles post-processinglandez : tiles post-processing Tue 29 May 2012Some weeks ago, I started to refactor landez (timidly). But smart caching and post-processing of WMS map...
-
2
Render your TileMill stylesheets with LandezRender your TileMill stylesheets with Landez Thu 22 March 2012TileMill is an amazing tool to design your map, and publish it. With
-
11
landez : fabriquer facilement des fichiers MBTiles en pythonlandez : fabriquer facilement des fichiers MBTiles en python Thu 21 April 2011Une nouvelle foi...
-
3
Today our guest blogger is Lisa Kempler, who works at MathWorks in Natick, Massachusetts. Lisa supports researchers and educators, frequently geoscientists, helping them build and host the tools that they need on their community...
-
2
3 mins readCompanyIntroducing Our New Pregnancy Loss and Miscarriage LeaveWe’re joining the #WeNeedMoreLeave movement.
-
5
5 mins readProduct NewsHard refresh: Introducing our new websiteWe’ve been really fortunate that Linktree has grown rapidly in four years – we’re t...
-
5
Introducing our new talk show – Developers Digest Hey everyone, I am so excited to announce a new long format “talk show” that we are releasing from the Developer Advocates team called Developers Dig...
-
1
Introducing Our New Low-Cost Plans Posted by Andrew Fawcett...
-
7
Introducing the .NET MAUI Toolbox for Visual StudioWe are glad to announce that the
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK