49
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 ...
49
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, ...
32
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]]...
25
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/...
22
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 ...
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 ...
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....
15
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 ...
14
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.
14
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....
12
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 ...
12
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']
...
9
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 ...
9
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 ...
9
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 ...
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 --...
8
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 ...
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 ...
8
votes
Accepted
Can Gdal.Translate() return an object instead of writing a file?
gdal.Translate does return an object, it returns a gdal.Dataset object.
from osgeo import gdal
in_ds = gdal.OpenEx('path/to/input.tif')
print(in_ds)
<osgeo.gdal.Dataset; proxy of <Swig ...
8
votes
Accepted
Averaging overlapping rasters with GDAL
The following approach worked pretty well.
First I build virtual raster.
gdalbuildvrt raster.vrt -srcnodata 0 -input_file_list paths.txt
paths.txt is file with following content:
a.tif
b.tif
Then ...
8
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 ...
7
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 ...
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=...
7
votes
Accepted
Matching two rasters with different projections and resolution
First of all, I'd move the two raster layers in the same working directory in order to skip the long paths in command line.
We can transform the elevation layer to the same CRS of the satellite image,...
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 ...
7
votes
How to get gdal_translate to create world file for GeoTIFF
"WORLDFILE=YES" is a jpeg creation option, not a tiff option.
The creation option you want is TFW=YES
gdal_translate -co "TFW=YES" infile outfile
See the geotiff documentation.
7
votes
Accepted
File size inflation using GDAL
Your existing data is compressed. You're getting an increase in file-size because the default is uncompressed and you aren't specifying a compression option (-co compress=LZW).
However, it's a ...
7
votes
Accepted
How to show pixel boundaries of a given raster in QGIS?
Go to
View - Decorations - Grid
"Update intervals / Offsets from" click "Active Raster Layer"
Then click the Line symbol and adjust the symbol. I made the lines 0.06 wide
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*
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 ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
gdal-translate × 531gdal × 371
gdalwarp × 140
geotiff-tiff × 103
python × 72
qgis × 55
raster × 44
coordinate-system × 32
gdalbuildvrt × 22
gdal2tiles × 21
netcdf × 18
geopackage × 12
gdal-merge × 12
r × 11
georeferencing × 11
vrt × 11
sentinel-2 × 10
mbtiles × 10
raster-conversion × 9
pyqgis × 8
dem × 8
kmz × 8
nodata × 8
jpeg-2000 × 8
wms × 7