[postgis-tickets] [PostGIS] #2800: [raster] Coverage topology broken by ST_Rescale
PostGIS
trac at osgeo.org
Mon Jul 14 06:45:47 PDT 2014
#2800: [raster] Coverage topology broken by ST_Rescale
--------------------+-------------------------------------------------------
Reporter: strk | Owner: dustymugs
Type: defect | Status: new
Priority: medium | Milestone:
Component: raster | Version: trunk
Keywords: |
--------------------+-------------------------------------------------------
Comment(by strk):
Adding some debugging lines I find that ST_Resize (the working one, being
passed percent width/height) ends up calling rt_raster_gdal_warp with an
integer width/height like this:
{{{
NOTICE: rt_raster_gdal_warp user-defined width 3, computed xscale 0.6144
NOTICE: rt_raster_gdal_warp user-defined height 3, computed yscale 0.6144
}}}
While ST_Rescale ends up calling rt_raster_gdal_warp with a float scale
like this:
{{{
NOTICE: rt_raster_gdal_warp user-defined scale x=0.6, y=0.6
NOTICE: rt_raster_gdal_warp computed dims w=3, h=3
}}}
The source scale of the raster is: 0.00719999999999928 (both X and Y).
The source size is 256 x 256.
ST_Resize ends up being called with percent parameters 0.0119999999999988,
being the result of
source scale / target scale (0.6). The full query is:
{{{
SELECT ST_Resize("rast", CASE WHEN abs(ST_ScaleX("rast"))::float8 < 1 THEN
abs(ST_ScaleX("rast"))::float8/1 ELSE 1.0 END, CASE WHEN
abs(ST_ScaleY("rast"))::float8 < 1 THEN abs(ST_ScaleY("rast"))::float8/1
ELSE 1.0 END) AS geom,"rid" FROM dataraster
}}}
ST_Rescale gets called with 0.6 instead.
The result from ST_Resize retains the original extent while the result
from ST_Rescale makes it slightly smaller:
{{{
with r as ( select rast from hyp_1250m limit 1 ) select
box2d(st_envelope(rast)) as orig,
box2d(st_envelope(st_resize(rast,.0119999999999988,.0119999999999988))) as
resized, box2d(st_envelope(st_rescale(rast,0.6,0.6))) as rescaled from r;
-[ RECORD 1 ]-------------------------------------
orig | BOX(-180 88.1568000000002,-178.1568 90)
resized | BOX(-180 88.1568000000002,-178.1568 90)
rescaled | BOX(-180 88.2,-178.2 90)
}}}
I guess all of this is expected, which would make the confusion simply due
to lack of documentation.
It should be stated in the manual page when ST_Resize retains extent (I
guess when passed a factor of original size, but not when passed fixed
size) and when (if ever) ST_Rescale retains extent.
--
Ticket URL: <http://trac.osgeo.org/postgis/ticket/2800#comment:4>
PostGIS <http://trac.osgeo.org/postgis/>
The PostGIS Trac is used for bug, enhancement & task tracking, a user and developer wiki, and a view into the subversion code repository of PostGIS project.
More information about the postgis-tickets
mailing list