Hello again,

I seem to have misunderstood the semantics of ROI support in JAI-Ext 
operations. Apparently pixels outside the ROI get the value of NoData, instead 
of passing through unchanged (having the same value as in the source coverage). 
Sadly this means that the operation will not work for our purposes and we will 
need to roll our own (or use a modified version of the Rescale op).

Still curious to know why I only get zero values when making use of the ROI..

Also, does anyone have any pointers to where I can find information on the 
difference of using a "normal" ROI and and ROI RasterAccessor?

Regards,
Tobias

-----Ursprungligt meddelande-----
Från: Tobias Gerdin
Skickat: den 14 april 2020 12:50
Till: 'geotools-gt2-users@lists.sourceforge.net' 
<geotools-gt2-users@lists.sourceforge.net>
Ämne: How to make use of ROI parameter for JAI operations?

Hello,

I am trying to make use of the "Rescale" GT operation with a ROI (a ROIShape). 
However, as soon as I specify a "ROI" parameter (with or without the 
"useRoiAccessor" parameter) the resulting GridCoverage is just zero. I do not 
specify any NoData parameter. When not specifying the ROI parameters the 
operation works as expected.

I make use of the CoverageProcessor like so:

    CoverageProcessor processor = CoverageProcessor.getInstance();
    var params = processor.getOperation("Rescale").getParameters();
    params.parameter("Source").setValue(coverage);

    var multipliers = new double[coverage.getNumSampleDimensions()];
    var offsets = new double[coverage.getNumSampleDimensions()];
    for (int i=0; i<multipliers.length;i++) {
        multipliers[i] = 1.0;
        offsets[i] = 0.0;
    }
    multipliers[2] = 1.1; // increase values in ROI in band 2 by 10%
    params.parameter("constants").setValue(multipliers);
    params.parameter("offsets").setValue(offsets);

    Geometry targetRoi = JTS.transform(roi, transform); // reproject roi 
geometry to coverage CRS
    var shape = new LiteShape(targetRoi, 
(AffineTransform)gridGeometry.getCRSToGrid2D(), false);
    ROI roi = new ROIShape(shape);
    params.parameter("ROI").setValue(roi);
    params.parameter("useRoiAccessor").setValue(true);

    GridCoverage2D changed = (GridCoverage2D)processor.doOperation(params);

I noticed that the first argument to handleROINoDataProperties at 
https://github.com/geotools/geotools/blob/d8d3fa7bc5a33d0f93a84ab6c51bec852cfe47cf/modules/library/coverage/src/main/java/org/geotools/coverage/processing/operation/Rescale.java#L121
Is set to null, which seems to cause getProperties to return an empty map. This 
does not seem right.

Is ROI not supposed be supported for this operation?

I am using Geotools 22.3 with Maven on Windows 10.

Regards,

Tobias Gerdin

Havs- och vattenmyndigheten behandlar dina personuppgifter i enlighet med 
dataskyddsförordningen och myndighetens dataskyddspolicy, läs mer på 
www.havochvatten.se/sa-behandlar-hav-dina-personuppgifter<https://www.havochvatten.se/sa-behandlar-hav-dina-personuppgifter>
SwAM processes your personal data in accordance with the General Data 
Protection Regulation (GDPR) and our Data Protection Policy, see 
www.havochvatten.se/sa-behandlar-hav-dina-personuppgifter<https://www.havochvatten.se/sa-behandlar-hav-dina-personuppgifter>


_______________________________________________
GeoTools-GT2-Users mailing list
GeoTools-GT2-Users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to