commenthol / gdal2tiles-leaflet Goto Github PK
View Code? Open in Web Editor NEWGenerate raster image tiles for use with leaflet.
Home Page: https://commenthol.github.io/leaflet-rastercoords/
License: MIT License
Generate raster image tiles for use with leaflet.
Home Page: https://commenthol.github.io/leaflet-rastercoords/
License: MIT License
This worked for me and was simple, while trying to install gdal via pip etc did not, so sharing it here:
sudo add-apt-repository -y ppa:ubuntugis/ppa
sudo apt update
sudo apt install gdal-bin python-gdal python3-gdal
Got this from https://stackoverflow.com/a/41613466/4355695
After that, the script runs just fine:
python gdal2tiles-multiprocess.py -l -p raster bigimage.jpg tiles
Sadly this does not work with python 3.x. It would be great if the script could be updated to work on new versions of python.
File "gdal2tiles-multiprocess.py", line 50
print 'You are using "old gen" bindings. gdal2tiles needs "new gen" bindings.'
^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print('You are using "old gen" bindings. gdal2tiles needs "new gen" bindings.')?
This is the error when I try to run it
I'm attempting to move a panorama viewer from Openlayers 2 to Leaflet and tried out your modified version of gdal2tiles.
It works great on 95% of the images I give it but a handful return tiles like this link:
http://dev.gregwacker.com/#/photos/panorama/clat_adams_bicentennial_park_pano_2__6_photos_.jpg
The original image I tried to tile can be found here:
http://dev.gregwacker.com/photoalbums/ThePanoramas/fullsize/clat_adams_bicentennial_park_pano_2__6_photos_.jpg
The vanilla gdal2tiles output can be seen here:
http://www.gregwacker.com/photos/_panoramasViewer.cfm?panoID=232
Any ideas on why the leaflet version chokes on some images like the one above? The setting are identical with the exception of the Leaflet switch.
Another alternative since I'm not worried about x,y maker coordinates is to use the TMS tiles from vanilla gdal2iles with TMS set to true in leaflet, but I can't quite figure out the math for the bounds. Would you have any interest in providing an alternate rastercoords.js for TMS tiles?
Thanks for sharing the work you've done with gdal2tiles-leaflet to date.
I'm getting the above error message when running the script. OSX and python 3.7
I'm at on how to fix it.
Hmmm.... should I be using Python 2.7? Is that the problem?
I'm trying to render a map of a Hilbert curve - basically a flat 2D image. Here's one zoom level:
And here's the same image zoomed in:
Please let me know where could I upload the input file - it's pretty big (167M):
out.png: PNG image data, 65536 x 65536, 8-bit/color RGB, non-interlaced
And the command was:
/usr/bin/python gdal2tiles.py -l -p raster out.png outdir
Used latest git checkout on master.
I cloned the project and tested it as well. No problem. But when I try it with My own image the result is just empty directories, no images inside.
I exported the image from Gimp, maybe there are an option to set the get the right jpg format?
Test on Ubuntu
python3 ../gdal2tiles-multiprocess.py -l -p raster map.jpg tiles
Generating Base Tiles:
Generating Overview Tiles:
Compressed version with the same issue
map2.zip
Edit
I tested
python3 ../gdal2tiles.py -l -p raster map2.jpg tiles
Generating Base Tiles:
ERROR 6: Reading this image would require libjpeg to allocate at least 3774873600 bytes. This is disabled since above the 104857600 threshold. You may override this restriction by defining the GDAL_ALLOW_LARGE_LIBJPEG_MEM_ALLOC environment variable, or recompile GDAL by defining the GDAL_LIBJPEG_LARGEST_MEM_ALLOC macro to a value greater than 104857600
ERROR 1: map2.jpg, band 1: IReadBlock failed at X offset 0, Y offset 0: Reading this image would require libjpeg to allocate at least 3774873600 bytes. This is disabled since above the 104857600 threshold. You may override this restriction by defining the GDAL_ALLOW_LARGE_LIBJPEG_MEM_ALLOC environment variable, or recompile GDAL by defining the GDAL_LIBJPEG_LARGEST_MEM_ALLOC macro to a value greater than 104857600
I tried to add GDAL_ALLOW_LARGE_LIBJPEG_MEM_ALLOC=yes as an env variable but no success
I don't know what cause it but it shouldn't have white border it make map look like a checkerboard. How to fix that?
Great tool, unfortunately when I try to use the leaflet option
gdal2tiles.py -l -p raster -z 0-5 -w none test.jpg tiles
it breaks with the statement
gdal2tiles.py: error: no such option: -l
same if I try the --leaflet option
Any ideas?
ubuntu@ip-172-31-31-248:~$ python gdal2tiles-leaflet/gdal2tiles.py -z 0-11 -l -p raster -w none /mnt/1000/combined2.png /mnt/1000/out/
Generating Base Tiles:
0...10...20...30...40...50...60...70..ERROR 1: libpng: Read Error
ERROR 1: /mnt/1000/combined2.png, band 1: IReadBlock failed at X offset 0, Y offset 49257
Traceback (most recent call last):
File "gdal2tiles-leaflet/gdal2tiles.py", line 2925, in <module>
gdal2tiles.process()
File "gdal2tiles-leaflet/gdal2tiles.py", line 606, in process
self.generate_base_tiles()
File "gdal2tiles-leaflet/gdal2tiles.py", line 1718, in generate_base_tiles
+ 1)),
File "/usr/lib/python2.7/dist-packages/osgeo/gdal.py", line 2038, in WriteRaster
buf_pixel_space, buf_line_space, buf_band_space )
TypeError: not a string
Not sure if this is reproducible yet as generating tiles takes ages:
/mnt/1000/combined2.png: PNG image data, 65536 x 65536, 8-bit/color RGB, non-interlaced
First of all, I wanted to thank you for this handy tool. I was using the "vanilla" gdal2tiles, but was having a lot of trouble using it with leaflet. After finding this leaflet version, I was finally able to get my tiles to display properly on the y-axis!
However, I came to realize that gdal2tiles-leaflet unfortunately doesn't have support for the new "--tilesize" option from gdal2tiles 3.1 (see https://gdal.org/programs/gdal2tiles.html#cmdoption-gdal_translate-tilesize). With the original program, I was generating my tiles at 215x215 rather than 256px, since my image is 13760x6880. This means that when I use the leaflet version to generate the tiles, it ends up a little wonky.
And so, I wanted to request the addition of the --tilesize option, if possible. I tried hacking it together myself, but unfortunately I have no experience with python.
Thank you for your time.
I am trying to convert different .tiff files using this command python /tmp/gdal2tiles-multiprocess.py blueprint.tif tiles -z 16-22 --processes=4
and having this issue, In every 10 files any random 3-4 files getting stuck at "Generating base tiles" and takes too long to process sometimes 24-48 hours. any ideas ?
@commenthol
how can i download this library for CentOS 7.5?
Hello, the file path add name is '.../z/x/y.png'. But, how can I save files to '.../z/z_x_y.png'.Thank you very much.
I use a command
$ gdal2tiles-multiprocess.py --leaflet --processes=6 raster -z 0-4 -w none karta.jpg /tiles
and tiles 0-0-0 and 1-1-0 are missing
but
$ gdal2tiles-multiprocess.py --leaflet --processes=2 raster -z 0-4 -w none karta.jpg /tiles
gives me a full set of tiles
After using gdal2tiles2.py to cut tiles, the row and column number of the generated image starts from 0 and 0 by default. Can I input the longitude and latitude to make the row and column number correct? At the same time, in this case, the upper left corner of the image is taken as the starting point of slice by default. However, the upper left corner of any image is not exactly located in the upper left corner of a bounding rectangle under the leaflet slicing rule. Is there any way to crack it?
If I want to tile just zoom levels 0 and 1 (-z 0-1
) it ignores my parameter and tiles 0-5.
5 being the "Native zoom of the raster".
My goal is to host this on AWS Lambda and allocate a single zoom level to each process so that I can process tiles as fast as possible through parallel computing power (low powered single core machines)
Hi, it would be great to add support for retina / high DPI displays!
the example shows the calculation saying the minimum zoom level must be at least 4, but then continues to say that 0-4 is correct? This is very confusing. Doesn't 0-4 mean minimum zoom level 0 and maximum zoom level 4? Also it says if you don't pass -z it 'considers' the minimum zoom level. What does this mean? It assumes a minimum zoom level of 0 and a maximum zoom level of ? it automatically calculates the appropriate zoom levels?
Hi,
I'm using leaflet with simple crs and I used your (great!) python script to split an image of ~15k px X ~8k px to tiles.
The result of the zoom calculation was 5.9.. so I changed 0-4 to 0-6, but I'm receiving 404 on paths like "2/3/-1", "2/2/-1", "4/-1/4", why is that? where did I go wrong? what is this -1? is it something on my JS declaration?
Thanks.
Rotem
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.