GDAL I/O
Davinci, with an I/O module and an appropriately installed and configured GDAL installation, has the capability to read any file type that GDAL can access, within the limitations of the data types that GDAL and davinci have in common.
Prerequisites
The GDAL module is currently in alpha and not included in the source distribution of davinci. To download the the code required for build, look here. This module has only been tested on 64-bit Linux systems (specifically CentOS 5.3) using GDAL 1.7.1. This archive file should be expanded in the root directory of your davinci source tree. If you don't have the ability to compile it yourself, a 64-bit x86 Linux version is included in the tar file.
GDAL (including its development headers) must be installed on your system and to compile the module, you must know where it is installed. Edit the build.sh file in the distribution and change the values in GDALDIR to point to the proper locations. If you wish to build for 32 bit Linux systems, change the ARCH value to 32 as well. Other OSes are currently not supported, but will be in the future when the code to build it is distributed in core davinci. If you are using another operating system and/or compiler and you figure out how to compile it for it, please let us know! It will help get the build to be more portable.
Once you have edited this file to reflect the appropriate changes, Run it:
./build.sh
If all is right, you should have a file in the directory called "gdal.dvio"
This file should be copied to where your davinci modules are kept. Alternatively, you can set the environment variable DV_MOD_PATH to the location of this file when you run davinci:
DV_MOD_PATH=directory davinci
Reading a file
To use the GDAL I/O module, you must first load it in davinci:
dv> insmod("gdal") Initializing GDAL IO module. found 62 drivers. dv> lsmod("gdal") Module name : gdal Module path : ./gdal.dvio Supports read : yes Supports write: no Supports pds : no File Types : VRT GTiff NITF SAR_CEOS CEOS ELAS AIG AAIGrid SDTS OGDI DTED PNG JPEG MEM JDEM GIF ESAT FITS BSB XPM BMP AirSAR RS2 PCIDSK ILWIS SGI Leveller GMT netCDF HDF4 HDF4Image PNM DOQ1 DOQ2 ENVI EHdr PAux MFF MFF2 FujiBAS GSC FAST BT LAN CPG IDA NDF DIPEx ISIS2 PDS JPEG2000 L1B FIT RMF WCS RST RIK USGSDEM GXF DODS HDF5 HDF5Image
This only needs to be done once per davinci session, and the lsmod command is optional, but will show you what GDAL capabilities have been reported to davinci. When the module successfully loads, the davinci built-in function load() now knows how to read file types GDAL supports without you having to take any extra action:
dv> a = load("jpeg2000_sample.jp2") GDAL Driver: JPEG2000 raster dimensions: 400x200x3 400x200x3 array of byte, bsq format [240,000 bytes] dv>
Limitations, extended geographic information and output
At this point, the module only supports reading the simple raster data from files using the GDAL interface. Rasters with complex number data types are not supported, and feedback as to the value and the methods used in supporting it are welcome, since davinci has no concept of a complex number. One idea considered is to read the real and imaginary components of the complex number as successive real values, doubling the sample size when loaded into davinci: e.g. a 1000x1000x10 complex type raster would appear to davinci as a 2000x1000x10 array with a real type, and interpretation of the values would be left as an exercise to the davinci programmer.
It is possible for the GDAL system to report that it supports a file type when the reality is it does not. This is a peculiarity in the way your GDAL implementation is configured and is beyond the scope of what davinci can address.
In the future, reading the metadata will be supported by loading it into a davinci structure along with the raster information, similar to the method used in the ISIS3 IO module.
Writing data with the GDAL module is also not currently supported, but is in the works. Some changes to davinci core will possibly have to be made to support some of the extended and advanced file saving functions of GDAL.