ExtractROI parameter setting

Hi,
I know it seems simple but almost a whole day that I struggle to resolve it!

I have a Geotif file in UTM projection, 10m resolution:

Image general information:
Number of bands : 15
No data flags : Not found
Start index : [0,0]
Size : [1521,3541]
Origin : [694595,4.13662e+06]
Spacing : [10,-10] Estimated ground spacing (in meters): [9.97571,10.0183]
Image acquisition information:
Sensor :
Image identification number:
Image projection : PROJCS[“WGS 84 / UTM zone 29N”,
GEOGCS[“WGS 84”,
DATUM[“WGS_1984”,
SPHEROID[“WGS 84”,6378137,298.257223563,
AUTHORITY[“EPSG”,“7030”]],
AUTHORITY[“EPSG”,“6326”]],
PRIMEM[“Greenwich”,0,
AUTHORITY[“EPSG”,“8901”]],
UNIT[“degree”,0.0174532925199433,
AUTHORITY[“EPSG”,“9122”]],
AUTHORITY[“EPSG”,“4326”]],
PROJECTION[“Transverse_Mercator”],
PARAMETER[“latitude_of_origin”,0],
PARAMETER[“central_meridian”,-9],
PARAMETER[“scale_factor”,0.9996],
PARAMETER[“false_easting”,500000],
PARAMETER[“false_northing”,0],
UNIT[“metre”,1,
AUTHORITY[“EPSG”,“9001”]],
AXIS[“Easting”,EAST],
AXIS[“Northing”,NORTH],
AUTHORITY[“EPSG”,“32629”]]

and a GeoPoint in lat/lon format :

POINT (-6.538311613999999 37.119295829)

I wanted to use ExtractROI application to get a patch from the image centred with my point and sized 64x64 pixels, but got really confused how to configure the application in Radius mode:
the center x,y should be considered physical, while radius should be in pixel? it sounds logical but not functional :smiley:

ExtractROI = otbApplication.Registry.CreateApplication(“ExtractROI”)

ExtractROI.SetParameterString(“in”, “/workspace/ML/S2A_MSIL2A_20190122_R137_T29SPB.tif”)
ExtractROI.SetParameterString(“mode”,“radius”)
ExtractROI.SetParameterFloat(“mode.radius.r”, 32)
ExtractROI.SetParameterString(“mode.radius.unitr”, ‘pxl’)
ExtractROI.SetParameterFloat(“mode.radius.cx”,718707.136771) #converted to UTM
ExtractROI.SetParameterFloat(“mode.radius.cy”, 4110942.70878) #converted to UTM
ExtractROI.SetParameterString(“mode.radius.unitc”,‘phy’ )
ExtractROI.SetParameterString(“out”, “/workspace/data/ExtractROI.tif”)

ExtractROI.ExecuteAndWriteOutput()

Anyone ever got it worked in this manner?
I tried it in standard mode and all in ‘pixel’ units for arbitrary pixel positions (I do not understand how to identify in which pixel my point is located in order to locate properly 'startx,y , sizex,y)

Any help or suggestion is much appreciated.
Panteha

Hello,

which version of OTB are you using ? There have been some changes to this application since last release. Also, there is a bug on the radius and extent mode in the develop version of otb :confused: .

If we want to use the standard mode, I think you can locate your point using the origin and spacing contained in the metadata of your image.

Cédric

Hi,
My OTB version is 6.6.1.
I played around with the parameters but did not get it done neither with ‘radius’ nor ‘extent’.
‘standard’ mode for my need was too complicated to adapt, I skipped this process out of OTB, doing a projection, and then gdal_translate.
Thank you for the confirmation, I was wondering why I can not realise it.
Best
Panteha

Hi,
I am not aware of such a bug in 6.6.1, but did you check the projection of your image? Because when entering physical unit the application will use the image projection to convert it to pixel. If you have the GUI application you can try and see if you can spot changes in the standard parameter values.
When you say it is not working, do you have an image? An error? A crash?
Antoine