[gdal-dev] VRT derived band pixel functions written in Python

Even Rouault even.rouault at spatialys.com
Wed Sep 14 08:50:17 PDT 2016


Le mercredi 14 septembre 2016 17:24:53, jramm a écrit :
> Trying to run this using a function relying on scipy.ndimage...
> 
> When running gdal_translate on the VRT, I get ImportError: No module named
> scipy.ndimage
> This comes after successfully import numpy. scipy.ndimage will happily
> import within the python interpreter.

Works for me for both inline or offline functions.

Are you sure GDAL loads the same python lib as the python version used in the 
python interpreter ? (check the debug traces with CPL_DEBUG=ON)

You can also add at the top of your script

import sys
print(sys.path)

and check if the output points to a location where your scipy package can be 
found.

> Any tips on how to track this down/debug?
> 
> The entire VRT file is as follows:

I guess this is not the entire VRT since it refers to an inline definition of 
the script but <PixelFunctionCode> has empty content.

> 
> <VRTDataset RasterXSize="111090" RasterYSize="259376">
>   <SRS>PROJCS["OSGB 1936 / British National Grid",GEOGCS["OSGB
> 1936",DATUM["OSGB_1936",SPHEROID["Airy
> 1830",6377563.396,299.3249646,AUTHORITY["EPSG","7001"]],TOWGS84[446.448,-12
> 5.157,542.06,0.15,0.247,0.842,-20.489],AUTHORITY["EPSG","6277"]],PRIMEM["Gr
> eenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHO
> RITY["EPSG","9122"]],AUTHORITY["EPSG","4277"]],PROJECTION["Transverse_Merca
> tor"],PARAMETER["latitude_of_origin",49],PARAMETER["central_meridian",-2],P
> ARAMETER["scale_factor",0.9996012717],PARAMETER["false_easting",400000],PAR
> AMETER["false_northing",-100000],UNIT["metre",1,AUTHORITY["EPSG","9001"]],A
> XIS["Easting",EAST],AXIS["Northing",NORTH],AUTHORITY["EPSG","27700"]]</SRS>
> <GeoTransform>100180.0,5.0,0.0,1215730.0,0.0,-5.0</GeoTransform>
> <VRTRasterBand dataType="Float32" band="1"
> subClass="VRTDerivedRasterBand">
>     <SimpleSource>
>       <SourceFilename
> relativeToVrt="0">F:\tif_data\large_sparse.tif</SourceFilename>
>       <SourceProperties BlockXSize="256" BlockYSize="256"
> RasterXSize="111090" RasterYSize="259376"/>
> 	  <OpenOptions>
> 		<OOI key="NUM_THREADS">4</OOI>
> 		<OOI key="SPARSE_OK">TRUE</OOI>
> 	  </OpenOptions>
>     </SimpleSource>
>     <PixelFunctionType>extract_blobs</PixelFunctionType>
>     <PixelFunctionLanguage>Python</PixelFunctionLanguage>
>     <PixelFunctionCode>
> 	</PixelFunctionCode>
>     <BufferRadius>5</BufferRadius>
>     <PixelFunctionArguments nodata="0" count_threshold="5"/>
>   </VRTRasterBand>
> </VRTDataset>
> 
> 
> 
> 
> --
> View this message in context:
> http://osgeo-org.1560.x6.nabble.com/gdal-dev-VRT-derived-band-pixel-functi
> ons-written-in-Python-tp5285323p5285882.html Sent from the GDAL - Dev
> mailing list archive at Nabble.com.
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/gdal-dev

-- 
Spatialys - Geospatial professional services
http://www.spatialys.com


More information about the gdal-dev mailing list