# Tag Info

20

While I don't know why GDAL provides this overlap in functionality, be sure to set the cache for gdalwarp to make it really fast: # assuming 3G of cache here: gdalwarp --config GDAL_CACHEMAX 3000 -wm 3000 $(list_of_tiffs) merged.tiff Be sure to not define more cache than having RAM on the machine. 16 I've found when something isn't particularly well documented in GDAL, that looking through their tests can be useful. The /vsis3 test module has some simple examples, though it doesn't have any examples of actually reading chunks. I've cobbled together the code below based on the test module, but I'm unable to test as GDAL /vsis3 requires credentials ... 12 I just happened to come across this question and a potential answer when looking for something else. gdal_merge.py uses nearest neighbor resampling. If you want control over the resampling used, you should use gdalwarp instead. source: trac.osgeo.org 9 Add an empty argument in the first approach (because gdal_merge.py parses arguments starting from 1 and not 0): import sys sys.path.append('C:\\OSGeo4W64\\bin') import gdal_merge as gm gm.main(['', '-o', 'merged.tif', 'N00W078.tif', 'N00W079.tif']) Join the path of gdal_merge.py in the second approach: import os, subprocess gm = os.path.join('C:\\','... 8 The name of the option Layer stack has been changed to Place each input file into a separate band as shown here: 7 This was a tough problem to track down because I had thought that the effect was at the edges of tiles when it fact they are throughout the data. You're right that the phenomena isn't in the data before mosaicking the data. The problem results from the resampling process that is inherent in mosaicking. You need to use either the cubic convolution or bilinear ... 7 Since /vsis3/ is implemented in GDAL you can also use rasterio to read Windows of S3 datasets. This requires either your credentials to be set up for boto or using rasterios AWS session handler. import rasterio with rasterio.open('s3://landsat-pds/L8/139/045/LC81390452014295LGN00/LC81390452014295LGN00_B1.TIF') as ds: window = ds.read(window=((0, 100), (... 7 You could build a virtual raster which allows you to merge multiband rasters. This should be less memory-intensive than the gdal_merge tool. You can access this from the same menu: Raster > Miscellaneous > Build Virtual Raster (Catalog) 6 The easiest way to do this is by importing the path where gdal_merge.py is located, in my case, /usr/bin/ -- substitute with the path to gdal_merge on your system, which, obviously, could be a Windows path too. import sys sys.path.append('/usr/bin/') import gdal_merge as gm You will now have to build up an array for sys.argv, as if you were calling ... 6 I also needed to know how to rename bands in an open source environment so spent a whole day looking for answers. There is no way to name bands in QGIS while merging. But it can be done after the file is created, by editing their .aux.xml file. It works for both .tif and .img files, as far as I've researched. The solution is to include after each <... 6 gdal_merge.py is the correct tool to 'stack' your input images. Assuming that your first band has a valid color table you could use: gdal_merge.py -separate -pct -o output_file.tif file1.tif file2.tif file3.tif Note: The command has been reformatted with -o output_file.tif before the list of inputs. From the docs: -pct: Grab a pseudocolor table from ... 6 This can be achieved with the help of GDAL's Virtual Raster Format. With this you can essentially skip the step of creating one giant DEM. The VRT will be handled by GDAL like a giant, merged DEM but is just a small XML file containing the file paths for each tile as well as some metadata. This can then be fed to gdalwarp together with a bounding box or a ... 5 I ran across this mosaicing the True Marble imagery as well, though I used gdalbuildvrt and then gdal_translate. From memory, the recalcitrant tiffs are stored as a single band with a color table. Just convert them to 3 band RGB with gdal_translate: gdal_translate -expand rgb TrueMarble.250m.21600x21600.B4.tif TrueMarble.250m.21600x21600.B4.RGB.tif 5 gdal_merge.py loads all files into memory before processing them. therefore it is not able to process large files if your memory is small. see here 5 Open MSYS (It should have been downloaded along if you used OSGeo4W utility to install qgis) cd (Change Directory) to your folder with your data. cd c:/(path to)/(my data)/ (Hint: pressing tab, autocompletes) one-line it: gdal_merge.py -o out.tif$(ls *.tif) out.tif -> is your output file, name it to whatever you want. $(ls *.tif) -> lists all the files ... 5 You can't tell gdal_merge.py to process a specific band from multiband rasters as it doesn't support a -b band argument or path/to/file.tif/band_num syntax. I would use gdalbuildvrt then gdal_translate: gdalbuildvrt -b 1 -input_file_list "file_list.txt" "target.vrt" gdal_translate "target.vrt" "target.tif" Or without an intermediate VRT file: ... 5 No, if your bands all have the same resolution, no resampling will occur when using gdal_merge.py. So it's perfectly fine to use it. As for "Pansharpening": Since the process aims to turn a low-res color image into a high-res color image with the help of a high-res panchromatic image, naturally resampling is involved. In a common implementation this would ... 5 Have you tried adding compression to the creation options, e.g. gdal_merge.py input1.tif input2.tif -o output.tif -co 'COMPRESS=LZW' 4 It is nearest neighbor as written in http://lists.osgeo.org/pipermail/gdal-dev/2006-November/010619.html There is also a hint in the mail "If you want control over the resampling used, you should use gdalwarp instead." 4 gdal_merge.py -o output.tif ls *.tif The back ticks mean execute whatever is inside the back ticks before the main command, so this will find all tif files in current directory, which will then be used as the input to gdal_merge.py. Instead of backticks, you can also use the$(command) syntax, ie, gdal_merge.py -o output.tif \$(ls *.tif) is equivalent ...

4

Did you do ldconfig to be sure that your changes to LD_LIBRARY_PATH are really applied? Where is your libgdal.so.20 file? Did you look at the GDAL .travis.yml file? A Travis file instructs how you can compile, deploy code for testing. It's firstly for testing code purpose but you can also use it to find out if you didn't miss a point when compiling. Edit ...

4

gdal_merge allocates memory for whole raster at once so it runs quickly for datasets that fit into memory. If it is not you case, use gdalwarp tool which does tiling so you can control how much memory does it use: gdalwarp --config GDAL_CACHEMAX 512 -wm 4096 merged.tif where GDAL_CACHEMAX is memory for IO cache and -wm is memory limit which controls the ...

4

Make sure that you add an extension to your file name (.tif by default) so that there is no confusion with a folder.

4

You should read again the document page or gdalbuildvrt http://www.gdal.org/gdalbuildvrt.html. Pay attention to parameter called "resolution" -resolution {highest|lowest|average|user}: In case the resolution of all input files is not the same, the -resolution flag enables the user to control the way the output resolution is computed. 'average' is the ...

4

To put the comments into an answer: It looks like the processing was doing a bad job at predicting the optimal compression? Coupled with no tiling there was really inefficient storage. The solution was to use the geotiff creation options PREDICTOR=2 & TILED=YES. The final command to call is then gdal_merge.py *.tif -o ~/out.tif \ -co COMPRESS=LZW -...

3

Try QGIS' Saga Plugin > Grid Tools > Mosaick raster layers. You can combine a number of rasters and classify overlapping areas with blending, feathering, min and max values.

3

Turns out this is a projection issue. Prior to merging, I'm reprojecting the tiles from EPSG:4326 to EPSG:3785. When this is done after the merge no problems occur.

3

The chosen value is stored in the PhotometricInterpretation TIFF tag, which defines the color space, i.e. how to interpret the values of the bands. Example for a 3-band GeoTIFF defined as RGB: band 1 = red, band 2 = green, band 3 = blue. CMYK stands for the Cyan, Magenta, Yellow, blacK color space, etc.

3

Answering my own question: Those black pixels in the images represent a "NoData" value. If I tell the gdal merge code that pixels with a color value of 0 are "NoData," it can correctly stitch the images together. (The "NoData" value isn't necessarily set to 0, it can be any value not otherwise used in the image, but in the case of NAIP ortho images, it was ...

3

If you are in a windows environment you can create a batch file: @echo off for /f %%A in ('dir "c:\your_Path\*.tif" /b/s') do ( echo %%A "c:\path\to\GDAL\bin\gdaladddo" -ro %%A 2 4 8 16 32 ) This is a batch file that says "for this folder and every subfolder, every file with the '.tif' extension run gdaladdo". You will need to change c:\path\to\GDAL\bin to ...

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