Opened 17 years ago

Closed 15 years ago

#1781 closed enhancement (fixed)

[PATCH] Add new GDAL commandline utility : gdalbuildvrt

Reported by: Even Rouault Owned by: warmerdam
Priority: normal Milestone: 1.7.0
Component: GDAL_Raster Version: svn-trunk
Severity: normal Keywords: gdalbuildvrt
Cc:

Description

This patch adds a new GDAL commandline utility : gdalbuildvrt.

Here's its usage:

            "Usage: gdalbuildvrt [-tileindex field_name] [-resolution {highest,lowest,average}]\n"
            "                     output.vrt [inputfile]*\n"
            "\n"
            "eg.\n"
            "  % gdalbuildvrt doq_index.vrt doq/*.tif\n" 
            "\n"
            "NOTES:\n"
            "  o The default tile index field is 'location' unless otherwise specified by -tileindex.\n"
            "  o In case the resolution of all input files is not the same, the -resolution flag.\n"
            "    enable the user to control the way the output resolution is computed. average is the default.\n"
            "  o Input files may be any valid GDAL dataset or a GDAL raster tile index.\n"
            "  o For a GDAL raster tile index, all entries will be added to the VRT.\n"
            "  o If one GDAL dataset is made of several subdatasets, they will be added to the VRT "
            "    rather than the dataset itself.\n"
            "  o Only datasets of same projection and band characteristics may be added to the VRT.\n");

Attachments (2)

gdal_svn_gdalbuildvrt.patch (22.1 KB ) - added by Even Rouault 17 years ago.
gdal_svn_gdalbuildvrt_with_proxy.patch (44.8 KB ) - added by Even Rouault 17 years ago.

Download all attachments as: .zip

Change History (6)

by Even Rouault, 17 years ago

Attachment: gdal_svn_gdalbuildvrt.patch added

comment:1 by Even Rouault, 17 years ago

I'm attaching a revised version of the patch. It is much faster when building VRTs of thousands of files since only one opening of dataset is required instead of 3 in the "naive" version. One of the 3 was easy to remove, but the 2nd one not so. So, the "magic" here is the use of the "proxy dataset" I already introduced in the rpftoc driver. If you look at gdalproxy.cpp, you'll see an heavily commented section between a #ifdef I_CAN_LIVE_WITH_THIS_GDAL_PROXY_NASTY_THING. The nasty things done there are not hit by gdalbuildvrt, but by the modified vrt driver which uses the proxy rasterbands instead of the really ones. This way you can considerily speed up gdalinfo on a VRT made of thousands of files (from several tens of seconds to a few milliseconds !), or its opening by openev. See the changes in vrtsources.cpp. They are protected by #ifdef USE_GDAL_PROXY_FOR_VRT I'm aware that these are scary things that might not work at all in other contexts than the VRT driver and gdalbuildvrt (they rely heavily on the fact that these two pieces make only certain calls and in a certain order) All in all if you compile GDAL with I_CAN_LIVE_WITH_THIS_GDAL_PROXY_NASTY_THING and USE_GDAL_PROXY_FOR_VRT you'll get the best performance. Otherwise it'll work but slower... Comments on how to design things better would be very much appreciated !

comment:2 by Even Rouault, 17 years ago

I'm realizing that my previous message might be confusing. When I say "only one opening of dataset is required", I mean "for each file added to the VRT, only one opening of dataset is required". If you have 1000 files to add, you'll have 1000 openings...

by Even Rouault, 17 years ago

comment:3 by Even Rouault, 17 years ago

In r12120, I've commited almost the first version of the patch. "Almost" because gdalbuildvrt is not built by default. On a *NIX system, just cd to app and make gdalbuildvrt.

comment:4 by Even Rouault, 15 years ago

Milestone: 1.7.0
Resolution: fixed
Status: newclosed

gdalbuildvrt is now compiled by default in GDAL 1.7.0dev

Note: See TracTickets for help on using tickets.