pramsey / gdal2tilesp Goto Github PK
View Code? Open in Web Editor NEWEnhancements to tile cutter for parallelism and image format support
Enhancements to tile cutter for parallelism and image format support
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
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.
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.
-={ 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, in1\apps\Python27\lib\multiprocessing\process.py", line 114, in
_bootstrap
self.run()
File "C:\OSGEO4
run
self._target(_self._args, *_self._kwargs)
File "C:\OSGEO41\bin\gdal2tilesp.py", line 2293, in worker_metadata1\bin\gdal2tilesp.py", line 904, in open_input
gdal2tiles.open_input()
File "C:\OSGEO4
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 1\apps\Python27\lib\multiprocessing\queues.py", line 132, in g
tminz = zoom_limits.get(timeout=1)
File "C:\OSGEO4
et
raise Empty
Queue.Empty
C:>
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:
in base zoom everything is OK.
Moreover, I can see in panel:
when generating is without holes
VS
uncompleted.
In what way it could be fixed?
The regular gdal2tiles script works fine at any zoom level with my input rasters.
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:
There needs to be a try/except block that ignores the exception, otherwise some tiles do not get created.
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.