1

I am wondering if there is a way to create a .vrt using a shapefile, but specifying attributes through a where clause. I have made a .vrt from a sub section shapefile (pre selected the tiles and exported as a new file) using the following:

 gdalbuildvrt -tileindex fullpath output.vrt area4.shp

But I would like to not have to create new shapefiles based on selected areas, so something like:

 gdalbuildvrt -tileindex fullpath WHERE areaid = 4 output.vrt area4.shp

Any advice?

1 Answer 1

1

Create vrt file with gdalbuildvrt and hand edit it afterwards as in the SQLite/Spatialite SQL dialect (GDAL >=1.10.0) example in the document page of the VRT driver http://www.gdal.org/drv_vrt.html. What you need to do is to add into the layer definion this:

<SrcSQL dialect="sqlite">SELECT * from area4 where areaid=4</SrcSQL>
2
  • So would this be a two staged process? Create vrt, then edit? Or is this a single operation? Commented Feb 5, 2016 at 17:26
  • With two steps. But I am not sure if it would work because I thought that you were playing with OGR VRT gdal.org/drv_vrt.html but actually you have rasters gdal.org/gdal_vrttut.html. Anyway, you can create a vector vrt with SrcSQL and you that vrt as a tileindex for gdalbuildvrt.
    – user30184
    Commented Feb 5, 2016 at 19:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.