Opened 13 years ago

Closed 13 years ago

Last modified 13 years ago

#1567 closed defect (invalid)

[raster] The SRID of the empty raster returned by ST_MapAlgebraExpr(rast, rast, 'intersection') should be 0

Reported by: pracine Owned by: pracine
Priority: low Milestone: PostGIS 2.0.0
Component: raster Version: master
Keywords: Cc:

Description

CREATE OR REPLACE FUNCTION ST_TestRaster(ulx float8, uly float8, val float8) 
    RETURNS raster AS 
    $$
    DECLARE
    BEGIN
        RETURN ST_AddBand(ST_MakeEmptyRaster(3, 3, ulx, uly, 1, 1, 0, 0, -1), '32BF', val, -1);
    END;
    $$
    LANGUAGE 'plpgsql';

SELECT ST_Metadata(ST_MapAlgebraExpr(ST_TestRaster(0, 0, 1), ST_TestRaster(4, 4, 1), '[rast1.val] + [rast2.val]', '32BF', 'INTERSECTION'));

Change History (6)

comment:1 by dustymugs, 13 years ago

Shouldn't the SRID of the empty raster be the SRID of the input rasters (assuming the input rasters have the same SRID)? I'm assuming that is the current behavior.

comment:2 by pracine, 13 years ago

Hum. It might make sense.

Does it make sense to give a SRID to en empty raster?

Do empty geometries have a SRID?

Is it normal to be able to create and empty raster with SRID equal to -1? Should not SRID be clamped to 0?

in reply to:  2 comment:3 by dustymugs, 13 years ago

Replying to pracine:

Hum. It might make sense.

Does it make sense to give a SRID to en empty raster?

In this situation, I'd say yes since the output is based upon the input rasters.

Do empty geometries have a SRID?

No. The following returns NULL

SELECT ST_SRID(NULL::geometry(POINT, 4326))

Is it normal to be able to create and empty raster with SRID equal to -1? Should not SRID be clamped to 0?

SRID < 0 is clamped to 0.

So, change the empty raster's SRID to zero?

comment:4 by pracine, 13 years ago

Resolution: invalid
Status: newclosed

As a last test I would check the SRID of the empty geometry resulting from an intersection. If it's the same as the input geometry then no. If it's 0 then yes.

SELECT ST_SRID(ST_Intersection(ST_Buffer(ST_SetSRID(ST_MakePoint(1.5, -1.5), 4269), 0.2), ST_Buffer(ST_SetSRID(ST_MakePoint(4.5, -1.5), 4269), 0.2)));

Gives 4269… so it should be the same as the input raster…

I set it to invalid.

However:

SELECT ST_SRID(ST_MakeEmptyRaster(4, 4, 0, 0, 1, -1, 0, 0, -10))

should return 0 no? Since:

SELECT ST_SRID(ST_SetSRID(ST_MakePoint(4.5, -1.5), -4269));

Does…

comment:5 by dustymugs, 13 years ago

The return of -10 for the following is invalid and should be ticketed as a bug.

SELECT ST_SRID(ST_MakeEmptyRaster(4, 4, 0, 0, 1, -1, 0, 0, -10))

in reply to:  2 comment:6 by strk, 13 years ago

Replying to pracine:

Do empty geometries have a SRID?

Yes !

SELECT ST_Srid('SRID=4326;POINT EMPTY');
Note: See TracTickets for help on using tickets.