Virtual Format

OGR Virtual Format is a driver that transforms features read from other drivers based on criteria specified in an XML control file. It is primarily used to derive spatial layers from flat tables with spatial information in attribute columns. It can also be used to associated coordinate system information with a datasource, merge layers from different datasources into a single data source, or even just to provide an anchor file for access to non-file oriented datasources.

The virtual files are currently normally prepared by hand.

Creation Issues

Currently the ODBC VRT driver is read-only, so new features, tables and datasources cannot normally be created by OGR applications. This limitation may be removed in the future.

Virtual File Format

The root element of the XML control file is OGRVRTDataSource. It has an OGRVRTLayer child for each layer in the virtual datasource. That element may have the following subelements:

Example: ODBC Point Layer

In the following example (disease.ovf) the worms table from the ODBC database DISEASE is used to form a spatial layer. The virtual file uses the "x" and "y" columns to get the spatial location. It also marks the layer as a point layer, and as being in the WGS84 coordinate system.

<OGRVRTDataSource>

    <OGRVRTLayer name="worms">
        <SrcDataSource>ODBC:DISEASE,worms</SrcDataSource> 
 	<SrcLayer>worms</SrcLayer> 
	<GeometryType>wkbPoint</GeometryType> 
        <LayerSRS>WGS84</LayerSRS>
	<GeometryField encoding="PointFromColumns" x="x" y="y"/> 
    </OGRVRTLayer>

</OGRVRTDataSource>

Other Notes