[Qgis-developer] Vector equivalent of a VRT

Even Rouault even.rouault at spatialys.com
Sun Oct 26 06:57:29 PDT 2014


Le dimanche 26 octobre 2014 14:37:04, Zoltan Szecsei a écrit :
> On 2014/10/24 18:49, Andre Joost wrote:
> > +100 from me if you promise to build a QGIS plugin for the purpose ;-)
> 
> Well, I'm not building a plugin - but rather a bash script, both to keep
> it simple, and to further my knowledge.
> 
> So,
> My script is working insofar as I am getting a VRT that QGIS (v2.5.0 rev
> b43d131 and gdal/ogr 1.11.0) loads, _but it comes in with zero elements._
> For guidance I am using http://www.gdal.org/drv_vrt.html
> 
> I have tried wrapping each SHP file in it's own <OGRVRTLayer
> name:shpname>, and below is the version having a global OGRVRTLayer name.
> 
> > <OGRVRTDataSource>
> > 
> >   <OGRVRTLayer name="River">
> >   
> >     <SrcDataSource>ESRI
> > 
> > Shapefile:2730/2730_RIVER_LINE_2006_06.shp</SrcDataSource>
> > 
> >     <relativeToVRT>1</relativeToVRT>
> > 
> > <SrcLayer>2730_RIVER_LINE_2006_06</SrcLayer>
> > 
> >     <ExtentXMin>30.000000</ExtentXMin>
> >     <ExtentYMin>-28.000037</ExtentYMin>
> >     <ExtentXMax>31.000000</ExtentXMax>
> >     <ExtentYMax>-27.000000</ExtentYMax>
> >     <SrcDataSource>ESRI
> > 
> > Shapefile:2731/2731_RIVER_LINE_2006_04.shp</SrcDataSource>
> > 
> >     <relativeToVRT>1</relativeToVRT>
> > 
> > <SrcLayer>2731_RIVER_LINE_2006_04</SrcLayer>
> > 
> >     <ExtentXMin>31.000000</ExtentXMin>
> >     <ExtentYMin>-28.000000</ExtentYMin>
> >     <ExtentXMax>32.250000</ExtentXMax>
> >     <ExtentYMax>-27.000000</ExtentYMax>
> >     <SrcDataSource>ESRI
> > 
> > Shapefile:2732/2732_RIVER_LINE_2006_04.shp</SrcDataSource>
> > 
> >     <relativeToVRT>1</relativeToVRT>
> > 
> > <SrcLayer>2732_RIVER_LINE_2006_04</SrcLayer>
> > 
> >     <ExtentXMin>32.000000</ExtentXMin>
> >     <ExtentYMin>-28.000000</ExtentYMin>
> >     <ExtentXMax>32.819133</ExtentXMax>
> >     <ExtentYMax>-27.000000</ExtentYMax>
> >   
> >   </OGRVRTLayer>
> > 
> > </OGRVRTDataSource>
> 
> Can someone please give me some pointers as to what is incorrect or
> missing in my VRT file?

You need to encapsulate the 3 layers in a OGRVRTUnionLayer. A single 
OVRTVRTLayer can only have a single SrcDataSource. And you need to put 
directly the file name, without the "ESRI Shapefile:" prefix.

From the doc :
"""Example: Union layer (GDAL >= 1.10.0)
The following example will return a layer that is the concatenation of 
source1.shp and source2.shp.

<OGRVRTDataSource>
    <OGRVRTUnionLayer name="unionLayer">
        <OGRVRTLayer name="source1">
            <SrcDataSource>source1.shp</SrcDataSource>
        </OGRVRTLayer>
        <OGRVRTLayer name="source2">
            <SrcDataSource>source2.shp</SrcDataSource>
        </OGRVRTLayer>
    </OGRVRTUnionLayer>
</OGRVRTDataSource>
"""

You don't need to specify the Extent generally.


> TIA,
> Zoltan

-- 
Spatialys - Geospatial professional services
http://www.spatialys.com


More information about the Qgis-developer mailing list