[gdal-dev] VRT OGRVRTDataSource filter & python function

Even Rouault even.rouault at spatialys.com
Tue Jul 29 09:59:18 PDT 2025


Hi Peter,

> I have two GDAL questions that are Mapserver adjacent (or perhaps 
> vice-versa?).
>
> 1.  Does OGRVRTDataSource allow Python code similar to raster VRT 
> Python Pixel Functions?
No. There is the possibility of writing a OGR driver in Python 
(https://gdal.org/en/stable/development/rfc/rfc76_ogrpythondrivers.html), 
but this is rather experimental, and will not have great performance.
> 2.  Is there a reasonable way to pass custom arguments to a VRT?
>
> Is there a reasonable way to pass some argument to filter the VRT?  
> For example, a condition like `WHERE some_table.id 
> <http://some_table.id> = 123`.  Imagine the query has a very large 
> number of records. I dont want to process the filter "client side":  
> Ideally the condition gets executed in SQL before OGR gets any 
> results.  I am aware of ogr2ogr's -sql statement 
> https://gdal.org/en/stable/programs/ogr2ogr.html#cmdoption-ogr2ogr-sql

That would require some tweaks in the OGR PostgreSQL driver so that a 
SQL result layer can forward an attribute filter to the server (not a 
huge deal), and also in the MapServer OGR connector, so that it detect 
that the OGR dataset is a VRT of a PostgreSQL layer and forwards its the 
filter.

Another possibility (admitedly with some initial setup cost, but 
potentially opening more future possibilities) is that you don't 
directly use the MapServer CGI, but have a Python WSGI server that 
intercepts requests and generate mapfiles on the fly, and use Python 
MapScript to get the result.

Even

-- 
http://www.spatialys.com
My software is free, but my time generally not.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20250729/ae20ec8b/attachment.htm>


More information about the gdal-dev mailing list