Opened 11 years ago

Closed 10 years ago

#2251 closed defect (fixed)

[raster ] Rescaling raster chooses wrong values

Reported by: dzwarg Owned by: Bborie Park
Priority: critical Milestone: PostGIS 2.1.0
Component: raster Version: master
Keywords: Cc:


Using a test raster with 1 band, 8BUI, rescale uses the wrong scale factor to rescale the raster.

The raster with id=1 was created with {{{ select ST_AddBand(ST_MakeEmptyRaster(10,10,0,0,1,-1,0,0,0), '8BUI'::text, 1); }}}

Running rescale works on rasters that are not positioned on the origin, but the (0,0) upperleftx, upperlefty raster is scaled by the wrong factor.

raster=# select id,st_metadata(rast), st_metadata(st_rescale(rast, 2, -2, 'NearestNeighbor'::text)) from test order by id;
 id |         st_metadata         |        st_metadata
  1 | (0,0,10,10,1,-1,0,0,0,1)    | (0,0,50,50,1,-1,0,0,0,1)

Change History (6)

comment:1 by Bborie Park, 11 years ago

Component: postgisraster
Keywords: raster removed
Milestone: PostGIS 2.1.0
Status: newassigned
Version: 2.0.xtrunk

The following should result in the same answer and exposes the error in this ticket.

-- edge case
WITH foo AS (
	SELECT ST_AddBand(ST_MakeEmptyRaster(10, 10, 0, 0, 1, -1, 0, 0, 0), 1, '8BUI', 1, 0) AS rast
	ST_Metadata(ST_Rescale(rast, 2, 2)) AS rescale,
	ST_Metadata(ST_Resize(rast, 0.5, 0.5)) AS resize
FROM foo;

comment:2 by Bborie Park, 11 years ago

Resolution: fixed
Status: assignedclosed

Fixed in r11215

comment:3 by strk, 10 years ago

The fix for this may have caused #2911

comment:4 by strk, 10 years ago

Resolution: fixed
Status: closedreopened

I'm reopening this because the test introduced for it is clearly bogus to me. Using ST_Resize asking for halfing the size and ST_Rescale asking for doubling the scale are both expected to return a tile which has the same scale as the input tile, which is exactly the problem reported in #2911

comment:5 by strk, 10 years ago

Why are we multiplying scales by 10 in the "subgt" case in r11215 ? In trunk it bacame a division by 10, what is 10 ? What's the division for ?

comment:6 by strk, 10 years ago

Resolution: fixed
Status: reopenedclosed

re-closing for mental sanity. Better handled in #2911

Note: See TracTickets for help on using tickets.