[gdal-dev] Ogr2ogr with -dialect and VRT
jukka.rahkonen at mmmtike.fi
Sun May 26 07:25:50 PDT 2013
Even Rouault wrote:
> Le vendredi 24 mai 2013 23:52:43, Jukka Rahkonen a écrit :
>> The -dialect parameter in ogr2ogr does not have an effect when using VRT as
>> datasource but could it be made to inject the selected dialect into SrcSQL
>> element of the VRT? Thus
>> ogr2ogr -dialect SQLITE
>> would lead to
>> <SrcSQL dialect="sqlite">SELECT ...</SrcSQL>
> (Almost) everything is possible in matter of software development, but IMHO
> the above would be a horrible hack in the code, whereas you can simply edit a
> text file to indicate your will.
After rethinking I agree that using -dialect as I suggested is not a good idea and that editing a text file is simple. I do not agree that making VRT to indicate my will is always easy but it helps a lot if there are some examples about the correct use and syntax.
I suggest to add a new example into Virtual Format manual page http://www.gdal.org/ogr/drv_vrt.html and it might be something like this:
Example: SQLite/Spatialite SQL dialect (GDAL >=1.10.0)
The following example will return four different layers which are generated in a fly from the same polygon shapefile. The first one is the shapefile layer as it stands. The second layer gives simplified polygons by applying Spatialite function "Simplify" with parameter tolerance=10. In the third layer the original geometries are replaced by their convace hulls. In the fourth layer Spatialite function PointOnSurface is used for replacing the original geometries by points which are inside the corresponding source polygons. Note that for using the last three layers of this VRT file GDAL must be compiled with SQLite and Spatialite.
<SrcSQL dialect="sqlite">SELECT Simplify(geometry,10) from polygons</SrcSQL>
<SrcSQL dialect="sqlite">SELECT ConvexHull(geometry) from polygons</SrcSQL>
<SrcSQL dialect="sqlite">SELECT PointOnSurface(geometry) from polygons</SrcSQL>
The last Other note on the driver page dealing with the normal use of VRT driver feels somehow outdated
"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. "
More information about the gdal-dev