VRT derived raster bands Error

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

VRT derived raster bands Error

james_Welly
This post has NOT been accepted by the mailing list yet.
I am trying to use a VRT to do a simple multiplier of each cell into a new geotiff. I am using the OSGeo4W shell that comes with QGIS 2.18, it has GDAL version 2.1.3

I have created a VRT from my tif and then added the Python code to the vrt. I then run the gdal_translate command and get the following error

Error message:

0ERROR 5: VRTDerivedRasterBand::IRasterIO:Derived band pixel function 'test.multiply' not registered

Can anyone help with what I am doing wrong?

gdal_translate

gdal_translate.exe -co COMPRESS=PACKBITS -co BIGTIFF=YES -a_nodata 0 -of GTiff vrt_path out_tif_name


VRT File:

<VRTDataset rasterXSize="27991" rasterYSize="38195">
  <SRS>PROJCS["British_National_Grid",GEOGCS["GCS_OSGB_1936",DATUM["OSGB_1936",SPHEROID["Airy_1830",6377563.396,299.3249646,AUTHORITY["EPSG","7001"]],AUTHORITY["EPSG","6277"]],PRIMEM["Greenwich",0],UNIT["degree",0.0174532925199433]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",49],PARAMETER["central_meridian",-2],PARAMETER["scale_factor",0.9996012717],PARAMETER["false_easting",400000],PARAMETER["false_northing",-100000],UNIT["metre",1,AUTHORITY["EPSG","9001"]]]</SRS>
  <GeoTransform> 3.1157000000000000e+005, 5.0000000000000000e+000, 0.0000000000000000e+000, 3.5895000000000000e+005, 0.0000000000000000e+000,-5.0000000000000000e+000</GeoTransform>
  <VRTRasterBand dataType="Byte" band="1" subClass="VRTDerivedRasterBand">
    <NoDataValue>255</NoDataValue>
    <ComplexSource>
      <SourceFilename relativeToVRT="1">...name of raster.tif...</SourceFilename>
      <SourceBand>1</SourceBand>
      <SourceProperties RasterXSize="27991" RasterYSize="38195" DataType="Byte" BlockXSize="128" BlockYSize="128" />
      <SrcRect xOff="0" yOff="0" xSize="27991" ySize="38195" />
      <DstRect xOff="0" yOff="0" xSize="27991" ySize="38195" />
      <NODATA>128</NODATA>
    </ComplexSource>
        <PixelFunctionLanguage>Python</PixelFunctionLanguage>
        <PixelFunctionType>test.multiply</PixelFunctionType>   
        <PixelFunctionArguments factor="2"/>
  </VRTRasterBand>
</VRTDataset>

Python File:

import numpy as np
def multiply(in_ar, out_ar, xoff, yoff, xsize, ysize, raster_xsize,
                   raster_ysize, buf_radius, gt, **kwargs):
    factor = float(kwargs['factor'])
    out_ar[:] = np.round_(np.clip(in_ar[0] * factor,0,255))

Reply | Threaded
Open this post in threaded view
|

Re: VRT derived raster bands Error

Luke
According to the VRT Tutorial, this functionality is available from GDAL 2.2 on. GDAL 2.2 has not been released yet.
Reply | Threaded
Open this post in threaded view
|

Re: VRT derived raster bands Error

Even Rouault-2

On vendredi 17 mars 2017 04:25:44 CET Luke wrote:

> According to the VRT Tutorial

> <http://www.gdal.org/gdal_vrttut.html#gdal_vrttut_derived_python> , this

> functionality is available from GDAL 2.2 on. GDAL 2.2 has not been released

> yet.

 

You don't need to wait for the release that should occur in May probably.

Just grab the sources of the trunk (2.2.0dev) and build it :

https://trac.osgeo.org/gdal/wiki/DownloadSource#Developmentversionandsourcecontrol

 

Or if you are on Windows :

http://gisinternals.com/development.php

or gdal-dev package on OSGeo4W.

 

>

>

>

> --

> View this message in context:

> http://osgeo-org.1560.x6.nabble.com/VRT-derived-raster-bands-Error-tp531221

> 8p5312821.html Sent from the GDAL - Dev mailing list archive at Nabble.com.

> _______________________________________________

> gdal-dev mailing list

> [hidden email]

> https://lists.osgeo.org/mailman/listinfo/gdal-dev

 

 

--

Spatialys - Geospatial professional services

http://www.spatialys.com


_______________________________________________
gdal-dev mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/gdal-dev