[gdal-dev] Passing Python PixelFunctionArguments or kwargs from command line?
Scott
public at postholer.com
Mon Jan 29 10:20:50 PST 2024
Thanks Even!
To re-iterate the value of passing arguments, here's a use case:
Say I have 20 years of climate data, 2001-2020, 1 raster per year. Using
gdalbuildvrt I create a .vrt with all those rasters in chronological order.
Now say I want to stat a range of years, such as:
gdal_translate ... -oo PixelFunctionArguments="startYear=2012" -oo
PixelFunctionArguments="endYear=2015"
In my .vrt python pixel function I might have something like this:
stIdx = startYear - 2001
endIdx = endYear - 2001
...
np.someMethod(ar_in[stIdx:endIdx])
This would truly make VRT's dynamic. Instead of a temporal set of
rasters, it could be a mix of elevation and land type. You get the idea.
Right now, it's easy enough to have the .vrt act as a template and do
substitution with desired values. Passing arguments would make it very,
very clean.
Thanks!
Scott
On 1/29/24 02:54, Even Rouault via gdal-dev wrote:
> Hi,
>
> no, the values of pixel function arguments are hardcoded in the VRT. If
> someone wanted to implement what you mention, that should rather be done
> as open option (-oo) of the VRT driver
>
> Even
>
> Le 29/01/2024 à 08:29, Scott via gdal-dev a écrit :
>> With a python pixel function in a .vrt file, is it possible to pass
>> values from the command line?
>>
>> Example:
>> gdal_translate ... -lco PixelFunctionArguments=? or -lco -kwargs=?
>>
>> Basically I want to change the 'min' and 'max' values on the command
>> line:
>> <PixelFunctionArguments min="0" max="100" />
>>
>> Thanks!
>> Scott
>>
>> _______________________________________________
>> gdal-dev mailing list
>> gdal-dev at lists.osgeo.org
>> https://lists.osgeo.org/mailman/listinfo/gdal-dev
>
More information about the gdal-dev
mailing list