Giter Site home page Giter Site logo

adrianschubek / gdal2tiles-leaflet Goto Github PK

View Code? Open in Web Editor NEW

This project forked from commenthol/gdal2tiles-leaflet

0.0 0.0 0.0 59.35 MB

Generate raster image tiles for use with leaflet.

Home Page: https://commenthol.github.io/leaflet-rastercoords/

License: MIT License

Shell 0.29% JavaScript 4.66% Python 94.76% HTML 0.30%

gdal2tiles-leaflet's Introduction

gdal2tiles-leaflet

Generate raster image tiles for use with leaflet.

Example in action.

This is a modified version of gdal2tiles.py which adds support for raster images as plain 2D maps in leafletjs.

It adds the option -l or --leaflet to generate the resulting images with the reference point [0,0] in the upper-left (North-West) corner, opposed to the standard behaviour for TMS tiles using the lower-left (South-East) corner.

Together with the small leafletjs plugin leaflet-rastercoords you'll be able to add markers at the correct position using the (x, y) coordinates of the full-size image.

Prerequisites

On Debian style OS:

sudo apt install python-gdal

for python3

sudo apt install python3-gdal

for others give your search-engine a try...

Basic usage

$ gdal2tiles.py -l -p raster -z 0-5 -w none <image> <tilesdir>

Check test/createtiles.sh for usage.

If the -z option is omitted then the tool considers the min. zoom level otherwise note...

Note: The min zoom level for tile generation must be greater or equal to log2(max(width, height)/tilesize)

Assuming an image with 2000x3000 pixels:

# take the larger dimension -> here height = 3000px
$ echo "l(3000/256)/l(2)" | bc -l
# 3.55 --> min zoomlevel for tile generation is 4
# means: `gdal2tiles.py -l -p raster -z 0-2 ...`
#                                          \__ is not allowed
# correct usage
$ gdal2tiles -l -p raster -z 0-4 ...

Multicore usage

The same works with multicore support, thanks to gdal2tiles-Ticket-4379.

$ gdal2tiles-multiprocess.py -l -p raster -z 0-5 -w none <image> <tilesdir>

Usage with Leaflet

To use the generated tiles with Leaflet there is a small plugin to correctly set the required projection for raster images. Please refer to the documention at leaflet-rastercoords.

Example

To run the example you'll need to generate the tiles for the large image first.

$ cd test
$ ./createtiles.sh
$ open index.html

Then open index.html in a browser.

The sample in test

Or see it here in action.

Contribution and License Agreement

If you contribute code to this project, you are implicitly allowing your code to be distributed under the respective license. You are also implicitly verifying that all code is your original work or correctly attributed with the source of its origin and licence.

License

Modifications and samples are MIT licensed.

gdal2tiles.py: (MIT licensed)

  • Copyright (c) 2008, Klokan Petr Pridal
  • Copyright (c) 2010-2013, Even Rouault

References

gdal2tiles-leaflet's People

Contributors

commenthol avatar carlostighe avatar guvener avatar alejandrocabeza avatar

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.