Opened 3 years ago

Closed 3 years ago

#2545 closed defect (fixed)

petascope - use gdal VRT for transform bounding box to get the most correct result

Reported by: Bang Pham Huu Owned by: Bang Pham Huu
Priority: major Milestone: 10.0
Component: petascope Version: 9.8
Keywords: Cc:
Complexity: Medium

Description

A common idea is, for projecting a given bbox(xmin,ymin,xmax,ymax), e.g. from EPSG:4326 to UTM 32632, one can just do 2 coordinates transformations:

  • First transform for xmin,ymin → xmin_projected,ymin_projected
  • Second transform for xmax,ymax → xmax_projected,ymax_projected

Then, xmin_projected,ymin_projected,xmax_projected,ymax_projected is the projected bbox in target CRS.

However, that this is not the case, see image

https://i.imgur.com/aJYkASb.png

Transforming a rectangle is not transforming the 4 corners of that rectangle. In image below, the corners of the red rectangle are not the transformed points of the black rectangle.

Above figure was for the simple case of an affine transform. Things are even more complicated with non-linear transforms such as rotated poles, because straight lines in a CRS become curves in another CRS.

It means, in petascope, typically for WMS requesting a bbox in EPSG:4326 on a coverage with different CRS. Then, these codes below return incorrect results:

        // e.g: native layer's CRS: UTM 32 to request CRS: EPSG:4326
        List<BigDecimal> mins = CrsProjectionUtil.transform(nativeCRS, this.outputCRS, sourceCoordinatesMin);
        List<BigDecimal> maxs = CrsProjectionUtil.transform(nativeCRS, this.outputCRS, sourceCoordinatesMax);

It needs to use gdal VRT file for projecting an image to targetCRS and collect the projected bbox in the targetCRS.

Change History (1)

comment:1 by Bang Pham Huu, 3 years ago

Resolution: fixed
Status: assignedclosed
Note: See TracTickets for help on using tickets.