9

landez : tiles post-processing

 3 years ago
source link: https://blog.mathieu-leplatre.info/landez-tiles-post-processing.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 : tiles post-processing

landez : tiles post-processing

Tue 29 May 2012

Some weeks ago, I started to refactor landez (timidly). But smart caching and post-processing of WMS maps were expected in my last project, so it gave me a great boost : Landez 2.0 has landed ! :)

The base code is much clearer, and a few new features came out ! Among them, the ability to apply image filters to your maps !

Grayscale conversion

Not the funniest one of course, but quite handy to highlight map content !

landez-grayscale.jpg
from landez import MBTilesBuilder
from landez.filters import GrayScale

overlay = MBTilesBuilder()
overlay.add_filter(GrayScale())

Color to Alpha

If the tiles you overlay are mainly white, they might make your background layer brighter. Therefore, adding a filter replacing white by transparent will nicely blend your top layer without lightening the global result :

landez-overlay.jpg
landez-blend.jpg
from landez import TilesManager, ImageExporter
from landez.filters import ColorToAlpha

overlay = TilesManager(tiles_url='http://an.osm.mirror.org/{z}/{x}/{y}.png')
overlay.add_filter(ColorToAlpha('#ffffff'))

orthophoto = ImageExporter(wms_server='http://server/wms',
                           wms_layers=['orthophoto'])
orthophoto.add_layer(overlay)

Continuous Integration

A Travis job was setup and allows me to improve the testing strictness :)

The Travis configuration has some kind of magic, just drop one file and enable the hook in your Github repo :

language: python
python:
  - 2.6
  - 2.7
install:
  - pip install Pillow
  - python setup.py develop
script:  python -m landez.tests

Next steps...

I hope to get the opportunity to develop new post-processing filters, as pretty as those coming-up in MapBox Tilemill !

PerryGeo wrote python-mbtiles which might be a good candidate for low-level access of MBTiles content. I like the idea of a common python stack for reading and writing, it is not very clear to me which one will emerge as the best one though...

#python, #gis, #landez - Posted in the Dev category


© Copyright 2020 by Mathieu Leplatre. mnmlist Theme

Content licensed under the Creative Commons attribution-noncommercial-sharealike License.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK