Context
I am trying to use Segmentation app from Python API.
Input raster data is passed as numpy array, but I couldn’t find a way to give projection information to the app.
I know that I can generate geotiff with projection metadatas with rasterio, and give the file as app’s input.
But, since the input data is created from upstream process, I want to avoid the array to write on a disk as a file such as GeoTiff to reduce I/O overhead.
Configuration setup
Minimum setup which I tried so far:
import numpy as np
import otbApplication as otb
params = {
'filter': 'meanshift',
'mode': 'vector',
}
array = np.random.random(30000).reshape(100, 100, 3)
app = otb.Registry.CreateApplication('Segmentation')
app.SetVectorImageFromNumpyArray('in', array)
app.SetParameters(params)
app.Execute()
and raise following error.
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
Cell In[37], line 12
10 app.SetVectorImageFromNumpyArray('in', array)
11 app.SetParameters(params)
---> 12 app.Execute()
13 # app_out = ExtractROI.GetVectorImageAsNumpyArray('out')
14 # app_out
File ~/Documents/git/cellcounter/otb/lib/otb/python/otbApplication.py:2445, in Application.Execute(self)
2444 def Execute(self):
-> 2445 return _otbApplication.Application_Execute(self)
RuntimeError: Exception thrown in otbApplication Application_Execute: ../Modules/Core/Adapters/GdalAdapters/src/otbOGRDataSourceWrapper.cxx:152:
itk::ERROR: No OGR driver known to OTB to create and handle a DataSource named <>.