mapbox / mapbox-sdk-js

A JavaScript client to Mapbox services, supporting Node, browsers, and React Native
Other
709 stars 185 forks source link

How to convert TIFF file to 8bit #427

Closed mandarc64 closed 2 years ago

mandarc64 commented 3 years ago

I am facing an issue while I upload a tiff file on Mapbox studio. It shows only 8bit TIFF are supported. How can I convert my TIFF file to 8bit?

I have a tiff file in this format Band 1 Block=256x256 Type=Float64, ColorInterp=Gray Description = Population Count

I tried this

import subprocess

image_in = "example.tif"
image_out = "path.tif"

subprocess.call(["gdal_translate.exe","-co", "TILED=YES", "-co", "COMPRESS=LZW" "-ot", "Byte", "-scale", image_in, image_out ])

But I got an error

ERROR 6: Too many command options './path.tif'
Usage: gdal_translate [--help-general] [--long-usage]
       [-ot {Byte/Int16/UInt16/UInt32/Int32/Float32/Float64/
             CInt16/CInt32/CFloat32/CFloat64}] [-strict]
       [-if format]* [-of format]
       [-b band] [-mask band] [-expand {gray|rgb|rgba}]
       [-outsize xsize[%]|0 ysize[%]|0] [-tr xres yres]
       [-r {nearest,bilinear,cubic,cubicspline,lanczos,average,mode}]
       [-unscale] [-scale[_bn] [src_min src_max [dst_min dst_max]]]* [-exponent[_bn] exp_val]*
       [-srcwin xoff yoff xsize ysize] [-epo] [-eco]
       [-projwin ulx uly lrx lry] [-projwin_srs srs_def]
       [-a_srs srs_def] [-a_ullr ulx uly lrx lry] [-a_nodata value]
       [-a_scale value] [-a_offset value]
       [-nogcp] [-gcp pixel line easting northing [elevation]]*
       |-colorinterp{_bn} {red|green|blue|alpha|gray|undefined}]
       |-colorinterp {red|green|blue|alpha|gray|undefined},...]
       [-mo "META-TAG=VALUE"]* [-q] [-sds]
       [-co "NAME=VALUE"]* [-stats] [-norat] [-noxmp]
       [-oo NAME=VALUE]*
       src_dataset dst_dataset
andrewharvey commented 2 years ago

Maybe contact Mapbox Support, as this issue isn't directly related to mapbox-sdk-js.