Opened 17 years ago
Closed 13 years ago
#1985 closed enhancement (fixed)
improved gdal_vrtmerge.py
Reported by: | vincentschut | Owned by: | warmerdam |
---|---|---|---|
Priority: | normal | Milestone: | |
Component: | Utilities | Version: | svn-trunk |
Severity: | normal | Keywords: | |
Cc: |
Description
Attached is a slightly improved version of the gdal_vrtmerge.py that is currently in pymod/samples.
Changes: o uses ngpython bindings ('from osgeo import gdal') o fixed colortable bug o added customizable precision for coordinates and pixel sizes, by
default set to 10 digits. Can be adjusted by changing the variable 'precision' at the beginning of the python script. This is used 1) to round the calculation result of corner coordinates and pixel size, and 2) in the comparison between pixel size/scale of multiple datasets (including a conversion to string before comparison) to prevent bailing out on nanometer/degree scale differences due to rounding/floating point issues.
Any of you who speaks python, feel free to double check my changes and eventually propose/implement better ones :-) I hereby donate this version to the gdal community.
Vincent Schut.
Attachments (2)
Change History (8)
by , 17 years ago
Attachment: | gdal_vrtmerge.py added |
---|
follow-up: 2 comment:1 by , 17 years ago
comment:2 by , 17 years ago
Replying to sieczka:
The -separate flag does not work. So one can't create multi-band VRTs. Trying to erge 7 Landsat bands:
$ gdal_vrtmerge.py -separate nn*.tif -o tm.vrt Traceback (most recent call last): File "/home/shoofi/bin/gdal_vrtmerge.py", line 277, in ? t_fh.write('\t\t<ColorInterp>%s</ColorInterp>\n' %
Ah, that must have been my colortable 'fix'. For me it was the other way around: without my fix, it wouldn't work without the -separate flag... I'll have a look into it later today, if time permits.
comment:3 by , 16 years ago
I have just tried it again against GDAL 1.5.1 + SVN r14376 and the '-separate' flag works now OK. Might be it failed before due to my error, earlier GDAL version, different Python or else (I'm now on Debian testing Python 2.5.2, before it was Ubuntu Dapper Python 2.4.2).
I can load the resulting VRT into QGIS and arrange any 3 of the 7 TM bands into an RGB composition as needed. E x c e l l e n t.
Without '-separate' however, gdal_vrtmerge.py fails saying:
$ gdal_vrtmerge.py -o tm2.vrt *.tif Traceback (most recent call last): File "/home/shoofi/bin/gdal_vrtmerge.py", line 294, in <module> file_infos[0].nodata[band]) TypeError: float argument required
Not an issue for me currently as the '-separate' mode I the exact thing I need, but I thought I'd report for the record.
Anyway - great tool! Thanks!
comment:4 by , 15 years ago
Hello. I added a little patch that allows you to pass a very big list of input files in a text file. Futhermore, this patch adds a <SourceProperties> tag for each <Source>, so they don't have to be opened at VRT file openning to get needed informations. It's not bulletproof but it works well in my case.
by , 15 years ago
Attachment: | gdal_vrtmerge.py.diff added |
---|
Input file list and SourceProperties patch.
comment:5 by , 15 years ago
gdal_vrtmerge.py.diff applied in r17881 with a minor modification to use characterestics of band s_band instead of always band 1.
comment:6 by , 13 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
The -separate flag does not work. So one can't create multi-band VRTs. Trying to erge 7 Landsat bands: