For the issue "turned pngs", you may be able to use https://github.com/roblabs/gdal2tilesp
which has support for xyz, from the notes: Generates Leaflet layer for use with the XYZ default format. Where the tms parameter is set to false
I've also tried gdal2tiles.py and mb-util utilities. they made good
mbtile from point of transparency but all the pngs are turned upside
down see figure2 (gdalinfo shows that origin has wrong Y coordinate
with "-")
python gdal2tilesp.py -h
-o OUTPUT_CACHE, --output=OUTPUT_CACHE
Format for output cache. Values allowed are tms and
xyz, being xyz the default value
Thanks for all of the suggestions and help. The scale normalization is very useful when doing code, however in my case the original idea of putting the minimum and maximum in code looks like the only solution at this point.
I did not find a solution for doing it at the command line.
Here is a code snippet from the working solution:
(Note that originally I was writing nodata to 0 as well, and this method breaks the nodata transformation. In my code I had to re-run the translate with nodata set to 0 as the only transformation to get it to finish the whole task!)
from qgis.core import *
from qgis.utils import *
from qgis.gui import *
import processing
from PyQt4.QtCore import *
#define functions
def loadraster(cur_raster):
fileInfo = QFileInfo(cur_raster)
baseName = fileInfo.baseName()
rlayer = QgsRasterLayer(cur_raster, baseName)
if not rlayer.isValid():
print "Layer failed to load!"
return rlayer
proj = QgsProject.instance()
proj.clear()
infile = "C:/QGISwork/ving_script/mergetest.tif"
outfile = "C:/QGISwork/ving_script/mergetest_out.tif"
#load raster file
mlayer = loadraster(infile)
#this part gets the extent from the original file
ext = mlayer.extent()
extrep = ','.join([unicode(ext.xMinimum()), unicode(ext.xMaximum()), unicode(ext.yMinimum()), unicode(ext.yMaximum())])
#now get the stats whcih contain min and max values
renderer = mlayer.renderer()
provider = mlayer.dataProvider()
extent = mlayer.extent()
stats = provider.bandStatistics(1, QgsRasterBandStats.All,extent, 0)
print stats.minimumValue
print stats.maximumValue
#we don't need the layer any more so clear memory
QgsMapLayerRegistry.instance().removeMapLayer(mlayer.id())
#Run the algorithm with all of the inputs:
processing.runalg('gdalogr:translate', infile, 100, True, "0", 0, "", extrep , False, 5, 4, 75, 6, 1, False, 3, False, "-scale "+str(stats.minimumValue)+" "+str(stats.maximumValue)+" "+"0 1", outfile)
Best Answer
gdal_translate can not use Multithreading for computing. But it can use multithreaded compression for some formats e.g. for GeoTiff using
-co NUM_THREADS=ALL_CPUS
Another Performance Tweak is to extend the I/O Buffer Cache Size using GDAL_CACHEMAX config option. The following sets the Cache size to 512MB: