[FWTools] gdal_merge with a specific pixel value clipped/removed

Chaitanya kumar CH chaitanya.ch at gmail.com
Tue Jun 9 23:17:33 EST 2015


Ari,

The vrt is an xml file that represents a single raster dataset made up of
one or many rasters. So, it is already merged. You can read it using any
good text editor.
You only have to run gdal_translate to convert it to a tif.

gdal_translate -of GTiff tif_index.vrt tif_index.tif

On Wed, Jun 10, 2015 at 2:40 AM Ari Simmons <ari.ucb.fire at gmail.com> wrote:

> Interesting...ok, so (knowing nothing about .vrt's and having a bunch of
> .tiff's) I ran this:
>
> >>gdalbuildvrt -srcnodata "230 245 255" tif_index.vrt *.tif
> 0...10...20...30...40...50...60...70...80...90...100 - done.
>
> then
>
> >> gdal_merge -o merged_result.tif *.vrt
>
> and got
>
> ERROR 4: `*.vrt' does not exist in the file system,
>
> and is not recognised as a supported dataset name.
>
> I'm on OSGEO4W too..
>
>
> On Tue, Jun 9, 2015 at 1:24 PM, <Matt.Wilkie at gov.yk.ca> wrote:
>
>> The error is because you need to quote the argument values to keep them
>> from being interpreted as filenames:
>>
>>         gdal_merge -n “230 245 255” ...
>>
>> However gdal_merge can't use different nodata values for each band. You
>> need to pre-process the files before merging. This worked for me here:
>>
>> Create  VRT (virtual raster) file for the input file(s):
>>
>>         gdalbuildvrt -srcnodata "230 245 255”"  infile1.vrt  infile1.tif
>>
>> Then feed the .vrt's to gdal_merge:
>>
>>         gdal_merge -of merged_result.tif infile1.vrt infile2.vrt ...
>>
>>
>> You may need to switch from fwtools to Osgeo4w (if on Windows) to get
>> gdalbuildvrt.
>>
>> Cheers,
>>
>> --
>> matt wilkie
>> --------------------------------------------
>> Geomatics Analyst
>> Information Management and Technology
>> Yukon Department of Environment
>> 10 Burns Road * Whitehorse, Yukon * Y1A 4Y9
>> 867-667-8133 Tel * 867-393-7003 Fax
>> http://environmentyukon.gov.yk.ca/geomatics/
>> --------------------------------------------
>>
>>
>>
>> -----------------------------
>>
>> From: fwtools-bounces at lists.maptools.org [mailto:
>> fwtools-bounces at lists.maptools.org] On Behalf Of Ari Simmons
>> Sent: Tuesday, June 09, 2015 12:43 PM
>> To: fwtools at lists.maptools.org
>> Subject: [FWTools] gdal_merge with a specific pixel value clipped/removed
>>
>> I have a large set of .tif files and I need to merge/mosaic them all into
>> one .tif with the no-data value removed (i.e. value 230, 245, 255).
>> However, when I put this in...pixel '230, 245, 255' becomes '0, 245, 255').
>> I am trying to get NO PIXEL returned for 230, 245, 255. Is that possible?
>> I:\TFS_6\trial_merge>gdal_merge.py -o test.tif -n 230 245 255 file1.tif
>> file2.tif
>>
>> ERROR 4: `245' does not exist in the file system,
>> and is not recognised as a supported dataset name.
>>
>> ERROR 4: `255' does not exist in the file system,
>> and is not recognised as a supported dataset name.
>>
>> 0...10...20...30...40...50...60...70...80...90...100 - done.
>>
>
> _______________________________________________
> FWTools mailing list
> FWTools at lists.maptools.org
> http://lists.maptools.org/mailman/listinfo/fwtools
> http://fwtools.maptools.org/
>
-- 

Chaitanya Kumar CH
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.maptools.org/pipermail/fwtools/attachments/20150610/3cd3d782/attachment.htm 


More information about the FWTools mailing list