48 votes
Accepted

Creating transparent hillshade?

Nutshell Each set of 3 images below should be read such as "grey (band) + opacity (band) = transparent result". You can test these processes within minutes via the associated github hosted ...
user avatar
  • 2,553
44 votes

How to call gdal_translate from Python code?

Since GDAL 2.1 (more info here), GDAL and OGR utilities can be used as library functions. For instance: from osgeo import gdal ds = gdal.Open('input.tif') ds = gdal.Translate('output.tif', ds, ...
user avatar
29 votes

Scale 16 bit to 8 bit within range using GDAL

If you don' want the values above 255 to be cut, you need to scale them down. For that purpose gdal_translate provides the option -scale: From the Manual: -scale [src_min src_max [dst_min dst_max]]...
user avatar
  • 6,089
20 votes
Accepted

Reducing File Size without losing quality

For aerial images like this, I suggest using TIFFs with JPEG compression. That way, there are no separate world files needed, all the metadata is stored in the TIFF as tags. Note, this will only work ...
user avatar
  • 19.8k
19 votes
Accepted

Convert huge XYZ CSV to GeoTIFF

You can do this using GDAL, it directly supports XYZ format. It doesn't matter if your coordinates are UTM, gdal_translate will output in the same coordinate system. So to convert to GeoTIFF is as ...
user avatar
  • 51.7k
19 votes
Accepted

Does gdal_translate support multi thread?

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 NUM_THREADS=number_of_threads/...
user avatar
  • 6,089
17 votes
Accepted

Clipping tiff raster image using bounding box with GDAL in python

Since GDAL 2.1 (more info here) GDAL and OGR utilities can be used as library functions, so this task is incredibly simple now: from osgeo import gdal ds = gdal.Open('original.tif') ds = gdal....
user avatar
14 votes
Accepted

Can GDAL report if a .tiff is tiled or not?

I haven't found any specific commandline utility that can report if a tiff is tiled or striped. At least not directly or in a grepable form like TILED=YES. There should be enough information in ...
user avatar
  • 2,659
13 votes
Accepted

gdal_translate or gdalwarp to define projection

if you want to set the projection of a file with gdal tools, you should use gdal_edit.py -a_srs Both gdalwarp and gdal_translate will create a new file.
user avatar
  • 48.5k
13 votes
Accepted

Convert batch file using GDAL_Translate.

From the command line you can write for %i in (*.tif) do gdal_translate -of "ENVI" %i %i.bil The command above will convert all tif to bil in the actual directory. The output name will be some_name....
user avatar
  • 6,722
11 votes

QGis Save Raster as Rendered Image

You can do that in Python Console of QGIS by using a QgsRasterPipe object (pipe) for setting a renderer clone of the image employed as active layer before to use the 'writeRaster' method of ...
user avatar
  • 25.8k
10 votes

How to translate tens of images from a directory as a batch with gdal_translate?

I suggest a batch file using OSGEO4W shell or the latest GDAL binaries from gisinternals. Using Windows: for %%N in (/work/120614/mg_1164/*.cub) DO gdal_translate %%N /work/temp/%%~nN.tif Note: Use ...
user avatar
  • 74.9k
9 votes

How to translate tens of images from a directory as a batch with gdal_translate?

If using a linux OS, you can use a for loop in your shell: for f in *.cub; do gdal_translate "$f" "${f%.*}.tif" done For more information on what this is doing, see the accepted answer to this ...
user avatar
  • 51.7k
8 votes
Accepted

How do I get GDAL_translate to output better resolution

You can improve the result with this command line: gdal_translate -of GTiff PARAmap1.pdf out1File.tif --config GDAL_PDF_DPI 300 According to http://www.gdal.org/frmt_pdf.html, the default is 150dpi. ...
user avatar
  • 74.9k
8 votes

Creating transparent hillshade?

Another way to get the same result of a non-grey canvas more suitable for combining with other layers is the 'combined' option in gdaldem. It performs a slope and hill shade and combines the two in ...
user avatar
  • 586
8 votes

Converting large jp2 files using GDAL

Jasper driver is useless for big JPEG2000 files. OpenJPEG driver is OK if source JPEG2000 is tiled, otherwise you will need JP2ECW, JP2KAK, or JP2MrSID driver. Check your drivers with gdalinfo --...
user avatar
  • 51.4k
8 votes
Accepted

How do I change the pixel size in GDAL without changing the extent?

Here's a quick script I put together to correct the cell size of a folder of GeoTiff rasters: import os, sys from osgeo import gdal from osgeo import gdalconst WorkingFolder = sys.argv[1] # first ...
user avatar
8 votes
Accepted

gdal_translate: Can I suppress the creation of auxiliary files?

I do not believe that you can avoid creating additional files with AAIGrid output. AAIGRid format does not have native internal support for projections and other metadata that GDAL needs in order to ...
user avatar
  • 51.4k
8 votes

osgeo.gdal.Translate - How to set compression on GDAL GTiff driver

You have "creationOptions" for this: translate_options = gdal.TranslateOptions(format = 'GTiff', creationOptions = ['TFW=YES', 'COMPRESS=LZW'] ...
user avatar
  • 1,624
7 votes
Accepted

jpg to geotiff transformation with gdal_translate and gcps fails

The gdal_translate document page http://www.gdal.org/gdal_translate.html may indeed give an impression that the values for Ground Control Points should be closed between brackets [-gcp pixel line ...
user avatar
  • 51.4k
7 votes

Convert MODIS HDF file in sinusoidal projection into GeoTIFF using Python GDAL

You can either leave the -s_srs empty or use +proj=sinu +R=6371007.181 +nadgrids=@null +wktext gdalwarp -of GTIFF -s_srs '+proj=sinu +R=6371007.181 +nadgrids=@null +wktext' -r cubic -t_srs '+proj=...
user avatar
7 votes

gdal_translate -a_ullr flag

After testing, the -a_ullr flag assigns the outermost coordinates of your raster. That is, the corners of grid cells located in the corners of the grid. The command: gdal_translate -of GTiff -a_srs ...
user avatar
  • 111
7 votes

osgeo.gdal.Translate - How to set compression on GDAL GTiff driver

I found the answer in this post. The post says GDAL supports three lossless compression algorithms for the GeoTiff format – Packbits, LZW and Deflate. You can use the compression methods with GDALs ...
user avatar
7 votes

Convert all files in a Linux directory from NITF to PNG using gdal_translate

The bash way You can try this directly in your shell (Linux based system assumed from the format of the path you provided, so it probably is bash): cd /home/john/WAMI/WPAFB_TRAIN/ mkdir pngs/ for f ...
user avatar
  • 6,698
6 votes
Accepted

How to add a color table to a one band tiff using GDAL?

with gdal, you can color an image based on gdal_dem (color_relief) the syntax of the color configuration file is derived from the one supported by GRASS r.colors utility. ESRI HDR color table files (....
user avatar
  • 48.5k
6 votes

How to call gdal_translate from Python code?

Here is a quick code for anyone wanting to save bands from a composite multi-band TIF to individual files using GDAL Translate in Python. import gdal in_path = 'C:/GIS/Sample.tif' #input composite ...
user avatar
  • 2,186
6 votes
Accepted

mosaicing geotiffs with gdal creates gaps due to alpha layers

Found a quick solution - replacing "-hidenodata" with "-srcnodata 0" in the .vrt build: gdalbuildvrt -srcnodata 0 mosaic.vrt geo_pict20140910_131*
user avatar
6 votes
Accepted

Convert MODIS HDF file in sinusoidal projection into GeoTIFF using Python GDAL

You might get unexpected results because your dataset crosses the 180° meridian. As a consequence, the tile is squeezed around the globe when reprojected to WGS84. To avoid that, you have to cut the ...
user avatar
  • 74.9k
6 votes

Convert TIFF file with multiple bands into a single CSV file

AFAIK gdal_translate is able to convert only one band into XYZ format, so I suggest the following workflow: use gdal_translate to convert each band into a CSV file; use ogr2ogr to append each CSV ...
user avatar

Only top scored, non community-wiki answers of a minimum length are eligible