Ticket #1536 (closed defect: fixed)
[raster] There should be an option for setting the nodata value in certain variants of ST_Intersection(raster, raster)
| Reported by: | pracine | Owned by: | pracine |
|---|---|---|---|
| Priority: | low | Milestone: | PostGIS 2.0.0 |
| Component: | raster | Version: | trunk |
| Keywords: | Cc: |
Description
All the variants of ST_Intersection accepting a extenttype argument should also allow to define a nodata value in case the input raster do not have one defined.
Otherwise it leads to strange results like this:
SELECT ST_AsBinary((gv).geom) geom, (gv).val
FROM (SELECT ST_PixelAsPolygons(
ST_Intersection(ST_AddBand(ST_MakeEmptyRaster(48, 63, 0, 0, 0.001, -0.001, 0, 0, 4269), '32BF'::text, 0, NULL),
ST_AddBand(ST_MakeEmptyRaster(48, 63, 0.1, 0.1, 0.001, -0.001, 0, 0, 4269), '32BF'::text, 0, NULL)::geometry,
'SECOND')) gv) foo;
in which:
-the first raster do not have a nodata value defined,
-the second parameter is just a dummy geometry to 'cut' the first raster,
-we want the result to cover the extent of the geometry ('SECOND')
so that we should get a lower left rectangle filled with zeros (0) and the rest of the extent filled with nodata.
Instead we get just nodata :-(
If ST_Intersection(raster, geometry, extenttype) would allow me to pass a nodata value, then I could make sure a correct nodata value is chosen and hence not annihilating my data.
On the same track, why do the variants of ST_Intersection() taking a geometry allow me to define the resulting extent but not the variant taking two rasters? Actually why does the one taking a geometry allows me to define the resulting extent at all? This is an intersection operation, the result should always cover just the intersection. If I want something more sophisticated I should use ST_MapAlgebra(raster, raster).
I'm working on a ST_Tile() plpgsql prototype using ST_Clip() and ST_Intersection(raster, geometry)...
