10

Honestly it's easier to do this by using gdalbuildvrt in a subprocess or os.system. Should you wish to do this through Python it can be done. Using the standard dataset creation methods within GDAL Python we can easily create the base dataset VRT. from osgeo import gdal drv = gdal.GetDriverByName("VRT") vrt = drv.Create("test.vrt", x_size, y_size, 0) ...


6

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


6

The problem is that this construction is trying to look for a "data" folder within your existent "...\Vector Map District Raster\data" folder. Since there is no such "...\data\data" folder, it returns an error. You'd need to iterate through each folder, but as far as I know there is no way to do this with gdalbuildvrt (or any other GDAL utility, for that ...


5

Depending on where you create the VRT, it will either become a relative path, or an absolute path. You can manually set this, by modifying the relativeToVRT="1"to a 0, and then write a complete path in the instead of just the image filename. See the example below of a full path VRT. <VRTRasterBand dataType="Byte" band="1"> <ColorInterp>...


5

This is a know issue, however there is a workaround described in the readme file from the installer: QGIS 3 does not find external tools needed for Processing. Some configuration options are missing. A workaround is to use QGIS custom variables. Open QGIS Preferences → System. Under the Environment section, turn on Use Custom Variables. Add (+) a ...


4

Seems to be the classic case of stale or poor documentation. After a good deal of trial and error, this seems to work: gdalbuildvrt -resolution lowest test.vrt BX*.tif BY*.tif gdal2tiles -p raster -s nztm.prj test.vrt out To be safe, i got a fresh prj from http://spatialreference.org/ref/epsg/2193/ and put that in nztm.prj TBH im not sure what was the ...


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 ...


3

From docs: -addalpha: Adds an alpha mask band to the VRT [...] The alpha band is filled on-the-fly with the value 0 in areas without any source raster, and with value 255 in areas with source raster The alpha channel is added as a Band of type byte, while the rest of your files are probably a different Type (e.g. UINT16). Like that you cannot combine ...


3

Ok, i solved the error the value in srcNodata must be a string "nan"


3

This VRT file, created from the original headers file, works for me: <OGRVRTDataSource> <OGRVRTLayer name="SO60"> <GeometryType>wkbPoint</GeometryType> <LayerSRS>EPSG:27700</LayerSRS> <SrcDataSource relativeToVRT="1">SO60.csv</SrcDataSource> <Field name="ID" src="field_1" />...


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 ...


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

Seems to be easy at least with non-rotated images which use metric units. Create VRT file and edit the 1st and 4th parameters of GeoTransform by hand. <VRTDataset rasterXSize="12000" rasterYSize="12000"> <GeoTransform> 3.8100000000000000e+005, 5.0000000000000000e-001, 0.0000000000000000e+000, 6.8270000000000000e+006, 0.0000000000000000e+000,-5....


3

I ran into the same problem and had to do an extra run with for %%N in (D:\Karten\gdal\gdal2tiles\NL50\*.tif) DO gdal_translate -of vrt -expand rgba %%N D:\Karten\gdal\gdal2tiles\NL50\%%~nN.vrt to expand the palettes used in the tifs to RGBA. Every tif has a different palette stored, and that's why stitching them together gives weired colours. In the next ...


2

The answer of @rcoup only worked for me, if modify it as follows: from osgeo import gdal vrt_options = gdal.BuildVRTOptions(resampleAlg='cubic', addAlpha=True) my_vrt = gdal.BuildVRT('my.vrt', ['one.tif', 'two.tif'], options=vrt_options) my_vrt = None Otherwise, the file is not written to disk.


2

Since GDAL 2.1 the CLI tools are available as library functions, and in fact that's what the CLI tools now call internally. For example: gdalbuildvrt -r cubic -addalpha my.vrt one.tif two.tif Is the equivalent of: from osgeo import gdal vrt_options = gdal.BuildVRTOptions(resampleAlg='cubic', addAlpha=True) gdal.BuildVRT('my.vrt', ['one.tif', 'two.tif'], ...


2

I just ran into this same/similar problem. What fixed my problem was to make the image large enough for the gdal2tiler to make proper tiles. I made my image evenly divisible by 256px, so this may have be necessary as well. I initially had a 16128px wide image and was trying to create zoom levels between 0-7. The gdal2tiler worked as expected when I tiled ...


2

Your output image will have more pixels than the sum of your input images, but this does not explain the large difference. I suggest that you look at the characteristics of your images based on gdalinfo in order to see what compression is used and check that the extents are correct. (assuming your input images have the same size, it makes 20000 * 12000 ...


2

Your source data is in GDA94, supposed to be Vicgrid94 covering Philip Island. gdalwarp transforms correctly to a target CRS of epsg:3857, but gdal_translate will not do that. -a_srs has a different purpose: just assign a CRS, no reprojection. So you have to use: gdalwarp -of GTiff -s_srs epsg:3111 -a_srs epsg:3857 test.vrt 25k.tif BTW I used this batch ...


2

To perform the conversion to GeoTIFF: gdal_translate in.vrt out.tif See the gdal_translate help and the GeoTIFF driver documentation for various other arguments and config options to control the conversion, such as whether to compress the output. For stacking, look at gdalbuildvrt. Something like: gdalbuildvrt -separate stacked.vrt [in vrts or rasters] ...


2

Right, so here goes. I haven't managed to achieve it with a single VRT (explanation to follow) but I have with two. The first VRT to is in this format: <OGRVRTDataSource> <OGRVRTUnionLayer name="OS_Open_Names_Data"> <!-- Repeat this section for each file --> <OGRVRTLayer name="SO82"> <SrcDataSource ...


2

well to others may face the same problem, there must be a / at the beginning of vrt path GDALDataset *poDataset; GDALAllRegister(); poDataset = (GDALDataset *) GDALOpen( "/home/m/3857/srtm_merged.vrt", GA_ReadOnly ); if( poDataset != NULL ) { }


2

QGIS can handle this under the Layer Properties/Transparency.


2

-a_srs just assigns the given SRS into metadata but nothing else. I believe this is what you did already and I don't know any better way for doing it: gdalbuildvrt -a_srs epsg:4326 ortho_4326.vrt ortho-*.tif gdalwarp -of VRT -s_srs epsg:4326 -t_srs epsg:3857 ortho_4326.vrt ortho_3857.vrt. There is one exception, if your final goal is to use VRT as a ...


2

*tif will not get expanded into subdirectories of .../data. You must use an input file list as described in http://www.gdal.org/gdalbuildvrt.html -input_file_list: To specify a text file with an input filename on each line You can create such file from command line when you home directory is at you "data" dir /b /s *.tif >my_input_file_list.txt


2

I'm pretty sure that adding poSrcDS = poDriver->CreateCopy( "wrk.vrt", poSrcDS, FALSE, APPEND_SUBDATASET=YES, NULL, NULL ); before closing the datasets should add the second dataset to the VRT as well. Hope this helps


2

The Python script is older but the executable is not an exact rewrite in C++. As you can see from the history the latest real change to the gdal_vrtmerge was done about 7 years ago in revision 20672. 1) Not exactly, but probably gdalbuildvrt was close to gdal_vrtmerge.py in GDAL 1.6 many years ago. 2) Probably, but not guaranteed because they are not ...


2

After doing some digging, the answer is within the documentation, but not on the main BuildVRT page: http://gdal.org/python/osgeo.gdal-module.html#BuildVRTOptions The answer to my above question is therefore to use the outputBounds argument, like so: options = gd.BuildVRTOptions(outputBounds=(xmin, ymin, xmax, ymax), separate=True) outds = gd.BuildVRT(...


2

Your arguments are incorrect, you have all positional args. There are only 2 positional args destName, srcDSOrSrcDSTab and the rest are keyword args, either ALL keyword=arg OR options=gdal.BuildVRTOptions() (possbly also a mix of keyword args and options="keyword=string" or ["a=list", "of=strings"] but not sure). From the docs: BuildVRT(destName, ...


1

No need of giving double quotes on both sides of data_vrt . TIF_files = '"' + str(data_vrt) + '"' // No need of this statement in my program. It is possible to directly give data_vrt (without any double quotes) as input into the algorithm. general.runalg("gdalogr:buildvirtualraster",data_vrt,0,True,False,output_vrt) // This will solve the issue. The ...


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