Ticket #1567 (closed defect: invalid)

Opened 16 months ago

Last modified 15 months ago

[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: trunk
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

  Changed 16 months ago by dustymugs

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.

follow-ups: ↓ 3 ↓ 6   Changed 16 months ago by pracine

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   Changed 16 months ago by dustymugs

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?

  Changed 16 months ago by pracine

  • status changed from new to closed
  • resolution set to invalid

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...

  Changed 16 months ago by dustymugs

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   Changed 15 months ago by strk

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.