<div dir="ltr"><div class="gmail_quote"><br><div dir="ltr">Hey all,<div><br></div><div>I am stuck with MBTiles creation from GeoTIFF files that have a black background (RGB: 0,0,0). </div><div><br></div><div>In QGIS, I am able to generate MBTiles via the following steps:</div><div><ul><li>Set Transparency pixel (0 0 0) to get a geotiff with transparent background</li><li>Use Generate XYZ tiles (MBTiles) tool to generate the MBTiles for the above generated geotiff.</li></ul><div>I want to automate the workflow using python, but not able to achieve great success. </div></div><div><br></div><div>The following commands are used: </div><div>





<pre style="color:rgb(0,0,0);font-family:"JetBrains Mono",monospace;font-size:9.8pt"><span style="color:rgb(0,128,0);font-weight:bold">gdal_translate -tr 0.035 0.035 -a_nodata none -of MBTILES file1.tif</span><span style="color:rgb(0,0,128);font-weight:bold"> file1.mbtiles</span></pre><p style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures"><span><br></span></span></p><p style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures"><span></span></span></p><pre style="font-family:"JetBrains Mono",monospace;font-size:9.8pt"><span style="color:rgb(0,128,0);font-weight:bold">gdaladdo -r nearest </span><span style="font-weight:bold"><font color="#000080">file1.mbtiles</font></span><span style="color:rgb(0,128,0);font-weight:bold"> 2 4 8 16</span></pre><pre style="font-family:"JetBrains Mono",monospace;font-size:9.8pt"><span style="color:rgb(0,128,0);font-weight:bold"><br></span></pre><pre style="font-family:"JetBrains Mono",monospace;font-size:9.8pt">This results in following issues:</pre><pre style="font-family:"JetBrains Mono",monospace;font-size:9.8pt">1. The generated mbtiles don't have all the resolutions that manually generated MBTiles have</pre><pre style="font-family:"JetBrains Mono",monospace;font-size:9.8pt">2. Background is still black, which is a big concern for my usecase</pre><pre style="font-family:"JetBrains Mono",monospace;font-size:9.8pt"><br></pre><pre style="font-family:"JetBrains Mono",monospace;font-size:9.8pt">Any help or alternative would be appreciated. Attaching a sample Geotiff for reference</pre><pre style="font-family:"JetBrains Mono",monospace;font-size:9.8pt"><br></pre><pre style="font-family:"JetBrains Mono",monospace;font-size:9.8pt"><div class="gmail_chip gmail_drive_chip" style="width:396px;height:18px;max-height:18px;background-color:rgb(245,245,245);padding:5px;font-family:arial;font-weight:bold;font-size:13px;border:1px solid rgb(221,221,221);line-height:1"><a href="https://drive.google.com/file/d/1HJaw59FVEwG_9sEN8bvfeRw1GrawGnUb/view?usp=drive_web" style="display:inline-block;max-width:366px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;text-decoration-line:none;padding:1px 0px;border:none" aria-label="sample_geotiff.tif" target="_blank"><img style="vertical-align:bottom;border:none" src="https://ssl.gstatic.com/docs/doclist/images/icon_10_generic_list.png"> <span dir="ltr" style="vertical-align:bottom;text-decoration:none">sample_geotiff.tif</span></a><img style="opacity:0.55;float:right;display:none"></div><br></pre><pre style="font-family:"JetBrains Mono",monospace;font-size:9.8pt"><br></pre><pre style="font-family:"JetBrains Mono",monospace;font-size:9.8pt">Thanks,</pre><pre style="font-family:"JetBrains Mono",monospace;font-size:9.8pt">Kanishk</pre></div></div>
</div></div>