<!DOCTYPE html><html><head><title></title></head><body><div>Hi,</div><div><br></div><div>From the MapServer side, did you try a runtime substitution parameter in the VRT file? There is a chance it loads the file and does the replacement afterwards, although it probably just sends on the filename to GDAL. </div><div><br></div><div>The FILTER is indeed processed in MapServer. Does the PROCESSING 'NATIVE_FILTER=id=234' approach work?</div><div><br></div><div>Depending on how many unique values you have, you could generate multiple VRTs and use runtime substitution to load the correct one. </div><div><br></div><div>Seth</div><div><br></div><div id="sig62266145"><div class="signature">--</div><div class="signature">mastodon: @<a href="mailto:geographika@mastodon.social">geographika@mastodon.social</a></div><div><br></div></div><div>On Tue, Jul 29, 2025, at 12:18 AM, Peter Schmitt via gdal-dev wrote:</div><blockquote type="cite" id="qt" style=""><div dir="ltr"><div>Hi,</div><div><br></div><div>I have two GDAL questions that are Mapserver adjacent (or perhaps vice-versa?). </div><div><br></div><div>1. Does OGRVRTDataSource allow Python code similar to raster VRT Python Pixel Functions?</div><div>2. Is there a reasonable way to pass custom arguments to a VRT?</div><div><br></div><div><br></div><div>I have a VRT that executes some SQL:</div><div><br></div><div> <!-- file.vrt --></div><div> <OGRVRTDataSource></div><div> <OGRVRTLayer name="0"></div><div> <SrcDataSource>PG:host=db user=me dbname=datastore password=abc</SrcDataSource></div><div> <SrcSQL></div><div> SELECT some_table.location, <a href="http://some_table.id">some_table.id</a>, some_table.geom FROM some_table</div><div> </SrcSQL></div><div> </OGRVRTLayer></div><div> </OGRVRTDataSource></div><div><br></div><div>Is there a reasonable way to pass some argument to filter the VRT? For example, a condition like `WHERE <a href="http://some_table.id">some_table.id</a> = 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 <a href="https://gdal.org/en/stable/programs/ogr2ogr.html#cmdoption-ogr2ogr-sql">https://gdal.org/en/stable/programs/ogr2ogr.html#cmdoption-ogr2ogr-sql</a></div><div><br></div><div>Ultimately this will happen via MapServer, which is referencing the VRT layer. I would like the client to pass a QUERYSTRING argument `foo_id=123` to perform a filter on the data in the VRT. Usually I do this via MapServer Runtime substitution. This works if I embed the contents of file.vrt directly in my Mapfile </div><div><br></div><div><div> LAYER</div><div> NAME my_layer</div><div> TYPE POLYGON</div><div> EXTENT -180 -90 180 90</div><div> PROJECTION</div><div> "init=epsg:4326"</div><div> END</div><div> CONNECTIONTYPE OGR</div><div> TILEITEM 'location'</div><div> TILEINDEX "<OGRVRTDataSource>...WHERE <a href="http://some_table.id">some_table.id</a> = %foo_id%</SrcSQL></OGRVRTLayer></OGRVRTDataSource>"</div></div><div><br></div><div><div> VALIDATION</div><div> 'foo_id' "^[0-9]+$"</div><div> 'default_foo_id' "-1"</div><div> END</div></div><div> END</div><div><br></div><div>However, my actual OGRVRTDataSource file is large. If I inline a large VRT Mapserver complains "msBuildPath(): Unable to access file. Path is too long. Check server logs.". I could use a Mapserver FILTER <a href="https://mapserver.org/mapfile/layer.html#filter">https://mapserver.org/mapfile/layer.html#filter</a>, but I think that occurs AFTER the VRT is evaluated. . . so if there are millions of rows, that data gets filtered by the client (Mapserver) and not by SQL, so there's a lot of data moving around and very slow performance.</div><div><br></div><div>Thanks!</div><div>Pete</div></div><div>_______________________________________________</div><div>gdal-dev mailing list</div><div><a href="mailto:gdal-dev@lists.osgeo.org">gdal-dev@lists.osgeo.org</a></div><div><a href="https://lists.osgeo.org/mailman/listinfo/gdal-dev">https://lists.osgeo.org/mailman/listinfo/gdal-dev</a></div><div><br></div></blockquote><div><br></div></body></html>