Sophie

Sophie

distrib > Fedora > 13 > i386 > by-pkgid > 7fd7c575020aa78a8e2e309ea8909f43 > files > 885

gdal-1.6.2-6.fc13.i686.rpm

<html>
<head>
<title>Virtual Format</title>
</head>

<body bgcolor="#ffffff">

<h1>Virtual Format</h1>

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 associate 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.<p>

The virtual files are currently normally prepared by hand.<p>

<h2>Creation Issues</h2>

Currently the OGR 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. <p>

<h1>Virtual File Format</h1>

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

<ul>
<li> <b>SrcDataSource</b> (mandatory): The value is the name of the datasource
that this layer will be derived from.  The element may optionally have
a <b>relativeToVRT</b> attribute which defaults to "0", but if "1" indicates
that the source datasource should be interpreted as relative to the virtual
file.  This can be any OGR supported dataset, including ODBC, CSV, etc.
The element may also have a <b>shared</b> attribute to control whether the datasource should be opened in shared mode. Defaults to OFF for SrcLayer use and ON for SrcSQL use.<p>

<li> <b>SrcLayer</b> (optional): The value is the name of the layer on the
source data source from which this virtual layer should be derived.  If this
element isn't provided, then the SrcSQL element must be provided.<p>

<li> <b>SrcSQL</b> (optional): An SQL statement to execute to generate the
desired layer result.  This should be provided instead of the SrcLayer for
statement derived results.   Some limitations may apply for SQL derived 
layers.<p> 

<li> <b>FID</b> (optional): Name of the attribute column from which the 
FID of features should be derived.  If not provided, the FID of the source
features will be used directly.<p>

<li> <b>GeometryType</b> (optional): The geometry type to be assigned to the 
layer. 
If not provided it will be taken from the source layer.  The value should
be one of "wkbNone", "wkbUnknown", "wkbPoint", "wkbLineString", "wkbPolygon", 
"wkbMultiPoint", 
"wkbMultiLineString", "wkbMultiPolygon", or "wkbGeometryCollection".  
Optionally "25D" may be appended to mark it as including Z coordinates.  
Defaults to "wkbUnknown" indicating that any geometry type is allowed.<p>

<li> <b>LayerSRS</b> (optional): The value of this element is the spatial
reference to use for the layer.  If not provided, it is inherited from the
source layer.  The value may be WKT or any other input that is accepted
by the OGRSpatialReference::SetUserInput() method. <p>

<li> <b>GeometryField</b> (optional): This element is used to define
how the geometry for features should be derived.  If not provided the
geometry of the source feature is copied directly.  The type of geometry
encoding is indicated with the <b>encoding</b> attribute which may have the
value "WKT", "WKB" or "PointFromColumns".  If the encoding is "WKT" or "WKB" 
then the <b>field</b> attribute will have
the name of the field containing the WKT or WKB geometry.  If the encoding is 
"PointFromColumns" then the <b>x</b>, <b>y</b> and <b>z</b> attributes
will have the names of the columns to be used for the X, Y and Z coordinates.
The <b>z</b> attribute is optional.<p>
</ul>

<h2>Example: ODBC Point Layer</h2>

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.<p>

<pre>&lt;OGRVRTDataSource&gt;

    &lt;OGRVRTLayer name="worms"&gt;
        &lt;SrcDataSource&gt;ODBC:DISEASE,worms&lt;/SrcDataSource&gt; 
 	&lt;SrcLayer&gt;worms&lt;/SrcLayer&gt; 
	&lt;GeometryType&gt;wkbPoint&lt;/GeometryType&gt; 
        &lt;LayerSRS&gt;WGS84&lt;/LayerSRS&gt;
	&lt;GeometryField encoding="PointFromColumns" x="x" y="y"/&gt; 
    &lt;/OGRVRTLayer&gt;

&lt;/OGRVRTDataSource&gt;
</pre>

<h2>Example: Renaming attributes</h2>

It can be usefull in some circumstances to be able to rename the field names from
a source layer to other names. This is particularly true when you want to transcode
to a format whose schema is fixed, such as GPX (&lt;name&gt;, &lt;desc&gt, etc.).<p>

<pre>&lt;OGRVRTDataSource&gt;
    &lt;OGRVRTLayer name="remapped_layer"&gt;
        &lt;SrcDataSource&gt;your_source.shp&lt;/SrcDataSource&gt;
        &lt;SrcSQL&gt;SELECT src_field_1 AS name, src_field_2 AS desc FROM your_source_layer_name&lt;/SrcSQL&gt;
    &lt;/OGRVRTLayer&gt;
&lt;/OGRVRTDataSource&gt;
</pre>


<h2>Other Notes</h2>

<ul>

<li> When the GeometryField is "WKT" spatial filtering is applied
after extracting all rows from the source datasource.  Essentially that means
there is no fast spatial filtering on WKT derived geometries. <p>

<li> When the GeometryField is "PointFromColumns", and a SrcLayer (as opposed
to SrcSQL) is used, and a spatial filter is in effect on the virtual layer
then the spatial filter will be internally translated into an attribute filter
on the X and Y columns in the SrcLayer.  In cases where fast spatial filtering
is important it can be helpful to index the X and Y columns in the source
datastore, if that is possible.  For instance if the source is an RDBMS. <p>

<li> Normally the SrcDataSource is a non-spatial tabular format (such as
MySQL, SQLite, CSV, OCI, or ODBC) but it can also be a spatial database in which
case the geometry can be directly copied over. <p>

</ul>

</body>
</html>