I have to save /Export raster layer to image . How this can be done using Python Script .
I can do this with GDAL script but this creates an image with low resolution
gdal_translate -of GTiff abc.tif out.jpeg
or,
gdal_translate -of JPEG -B 1 -B 2 -B 3 abc.tif out.jpeg
Is there any way to preserve the resolution while creating image using GDAL ?
1 Answer 1
What you are showing shouldn't be changing the resolution of the image in terms of the georeferencing, but is actually compressing the image.
You can set the level of compression using a creation option called QUALITY
(GDAL jpeg docs).
gdal_translate -of JPEG -co "QUALITY=95" abc.tif out.jpeg
-
i tried it but shows Input File size is 219,163 0Error 6 :JPEG Driver doesn't support 2 bands. Must be 1 (grey) ,3 (RGB) ,or 4 Bands.User18– User182016年12月07日 04:45:29 +00:00Commented Dec 7, 2016 at 4:45
-
1Due to jpeg's specs, it will need 1, 3, or 4 bands. Either duplicate one of the input bands into another channel or save as two separate raster files. (gdal_translate docs) GeoTiffs don't have this requirement, so consider using that format if it is acceptable within the workflow.Logan Byers– Logan Byers2016年12月07日 05:01:20 +00:00Commented Dec 7, 2016 at 5:01
gdal_translate -of GTiff abc.tif out.jpeg
will output a GeoTiff calledout.jpeg
. It won't actually be JPEG format.