2

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 ?

PolyGeo
65.5k29 gold badges115 silver badges349 bronze badges
asked Dec 6, 2016 at 12:03
1
  • gdal_translate -of GTiff abc.tif out.jpeg will output a GeoTiff called out.jpeg. It won't actually be JPEG format. Commented Dec 6, 2016 at 22:23

1 Answer 1

3

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
answered Dec 6, 2016 at 14:15
2
  • 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. Commented Dec 7, 2016 at 4:45
  • 1
    Due 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. Commented Dec 7, 2016 at 5:01

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.