Code Monkey home page Code Monkey logo

gdal2tilesp's Introduction

Credits

Introduction

This enhancement to the gdal2tiles.py script includes the following additional features:

  • Parallel processing, to use all available machine cores when generating tiles. This speeds up tile creation considerably.
  • Support for both the TMS and XYZ tile cache formats. Use the -o flag to choose; XYZ is the default format.
  • Support for both PNG and JPEG tile outputs. Use the -f flag to choose; PNG is the default format.

Run gdal2tilesp.py --help to check all the command-line parameters of the script.

Caveats

  • The epsg::900913 projection code is not supported, use epsg:3857 to generate a tile set in web mercator projection.

gdal2tilesp's People

Contributors

pramsey 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gdal2tilesp's Issues

Error upon completion of first zoom level

This repo hasn't been updated in some time so it's possible there will be no fix for this but, when running gdal2tilesp.py, I get the following error at the end of processing the first zoom level:

Generating Base Tiles:
Generating Overview Tiles:
Traceback (most recent call last):
  File "C:\OSGEO4~1\apps\Python27\Scripts\gdal2tilesp.py", line 2346, in <module>
    tminz = zoom_limits.get(timeout=1)
  File "C:\OSGEO4~1\apps\Python27\lib\multiprocessing\queues.py", line 132, in get
    raise Empty
Queue.Empty

It fails regardless as to the zoom level that run the script at. I Any ideas how I can resolve this?

The regular gdal2tiles script works fine at any zoom level so I do not believe there is an issue with the input raster that I am attempting to tile.

Thanks.

jpeg generation

This script is great, but it's missing an option for setting the quality of jpeg that's being generated. Also unclear what quality is currently being used.

Also, when creating jpegs, I don't see an option to specify what color transparent edges will be rendered as (it defaults to black). My input data doesn't have any NODATA, but when tiling the edges of it, half-black tiles get rendered because it's rendering beyond my file.

OSGeo2W Shell Result

               -={ OSGeo4W Shell Commands }=-

   bmp2tiff           geotifcp           ras2tiff
   cs2cs              gif2tiff           raw2tiff
   curl               gltpd              rgb2ycbcr
   dllupdate          listgeo            rpcgen
   example1           nad2bin            testepsg
   example2           nccopy             textreplace
   fax2ps             ncdump             thumbnail
   fax2tiff           ncgen              tiff2bw
   gdaladdo           ncgen3             tiff2pdf
   gdalbuildvrt       nearblack          tiff2ps
   gdaldem            nircmd             tiff2rgba
   gdalenhance        nircmdc            tiffcmp
   gdalinfo           ogdi_import        tiffcp
   gdallocationinfo   ogdi_info          tiffcrop
   gdalmanage         ogr2ogr            tiffdither
   gdalserver         ogrinfo            tiffdump
   gdalsrsinfo        ogrlineref         tiffinfo
   gdaltindex         ogrtindex          tiffmedian
   gdaltransform      osgeo4w-setup      tiffset
   gdalwarp           pal2rgb            tiffsplit
   gdal_contour       ppm2tiff           xmlcatalog
   gdal_grid          proj               xmllint
   gdal_rasterize     psql               xmlwf
   gdal_translate     python             xxmklink
   geod               pythonw


   epsg_tr           gdalimport        make-bat-for-py
   esri2wkt          gdalmove          mkgraticule
   gcps2vec          gdal_auth         o-help
   gcps2wld          gdal_calc         o4w_env
   gdal2cesium       gdal_edit         pct2rgb
   gdal2tiles        gdal_fillnodata   rgb2pct
   gdal2tilesp       gdal_merge        setup-test
   gdal2xyz          gdal_polygonize   setup
   gdalchksum        gdal_proximity
   gdalcompare       gdal_retile
   gdalident         gdal_sieve

GDAL 1.11.2, released 2015/02/10

C:>gdal2tilesp C:\Users\laptop\Desktop\Tif\my.tif Tile
Process Process-1:
Traceback (most recent call last):
File "C:\OSGEO41\apps\Python27\lib\multiprocessing\process.py", line 258, in
_bootstrap
self.run()
File "C:\OSGEO4
1\apps\Python27\lib\multiprocessing\process.py", line 114, in
run
self._target(_self._args, *_self._kwargs)
File "C:\OSGEO41\bin\gdal2tilesp.py", line 2293, in worker_metadata
gdal2tiles.open_input()
File "C:\OSGEO4
1\bin\gdal2tilesp.py", line 904, in open_input
os.unlink(tempfilename)
WindowsError: [Error 32] The process cannot access the file because it is being
used by another process: 'c:\users\laptop\appdata\local\temp\tmp8kyv9a-gda
l2tiles.vrt'
Generating Base Tiles:
Generating Overview Tiles:
Traceback (most recent call last):
File "C:\OSGEO41\bin\gdal2tilesp.py", line 2346, in
tminz = zoom_limits.get(timeout=1)
File "C:\OSGEO4
1\apps\Python27\lib\multiprocessing\queues.py", line 132, in g
et
raise Empty
Queue.Empty

C:>

multiprocessing throws exception when tile dir already created causing tiles to not be generated

If two processes are making the same directories, there is a race condition that needs to be handled.

The race condition is when the tile directory does not exist:

  1. process-1 checks if tile directory exists and it doesn't
  2. process-2 checkis if tile directory exists and it doesn't
  3. process-1 creates tile directory
  4. process-2 tries to create tile directory and throws exception because tile directory was created by process-1

There needs to be a try/except block that ignores the exception, otherwise some tiles do not get created.

Allow gdal2tilesp to be called directly from Python

Instead of calling it from the command line I want to call it directly with Python like:

import gdal2tilesp

args = ['gdal2tiles', '-w', 'none', '-r', 'cubic', '-v', '--zoom', 'my_img.tf', 'results']
gdal2tilesp.main(args)

The patch is as follows:

From 2d7db54b02632535bf3c244dcfa4e9ab0aa8df7e Mon Sep 17 00:00:00 2001
From: Bryant Mairs <[email protected]>
Date: Thu, 8 Sep 2016 15:26:17 -0700
Subject: [PATCH] Support calling gdal2tiles through Python directly.

---
 gdal2tilesp.py | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/gdal2tilesp.py b/gdal2tilesp.py
index ffc867b..4e9cd1c 100755
--- a/gdal2tilesp.py
+++ b/gdal2tilesp.py
@@ -2308,8 +2308,8 @@ def worker_overview_tiles(argv, cpu, tz):
    gdal2tiles.open_input()
    gdal2tiles.generate_overview_tiles(cpu, tz)

-if __name__=='__main__':
-   argv = gdal.GeneralCmdLineProcessor( sys.argv )
+def main(args):
+   argv = gdal.GeneralCmdLineProcessor( args )
    if argv:
        gdal2tiles = GDAL2Tiles( argv[1:] ) # handle command line options

@@ -2361,6 +2361,8 @@ if __name__=='__main__':
                    pass
            pool.join()

+if __name__=='__main__':
+   main(sys.argv)

 #############
 # vim:noet
-- 
1.9.1

Incomplete generation when generating overview tiles

The script works really faster, but for overview tiles there is a problem that not all tiles are being generated - there are holes in preview tiles mosaic:

holes

when zooming:
holes2

in base zoom everything is OK.

Moreover, I can see in panel:
completed
when generating is without holes
VS
not-completed
uncompleted.

In what way it could be fixed?
The regular gdal2tiles script works fine at any zoom level with my input rasters.

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.