Opened 10 years ago
Closed 10 years ago
#2384 closed defect (fixed)
[raster] Problem in ST_Neighborhood(raster, integer, geometry, integer, integer, boolean)
|Reported by:||jawj||Owned by:||Bborie Park|
I've just been trying to get to grips with st_neighborhood, and I think there's a problem in the variant that accepts a point (alternatively, if I've misunderstood what's going on here, then please accept my apologies).
In a certain query I'm getting the following error:
ERROR: invalid input syntax for integer: "-0.6465376" CONTEXT: PL/pgSQL function "st_neighborhood" line 15 at assignment
The problem is that the function seems to expect the x and y coordinates of the provided point geometry to be integers. (The PL/pgSQL source of the function is reproduced below for convenience).
Firstly, I don't think there's any reason to suppose that the x and y coordinates of the point argument will be integers.
Secondly, they're simply used as inputs to st_worldtorastercoordx/y, and those functions expect double precision input in any case.
CREATE OR REPLACE FUNCTION public.st_neighborhood(rast raster, band integer, pt geometry, distancex integer, distancey integer, exclude_nodata_value boolean DEFAULT true) RETURNS double precision LANGUAGE plpgsql IMMUTABLE STRICT AS $function$ DECLARE wx int; wy int; rtn double precision; BEGIN IF (st_geometrytype($3) != 'ST_Point') THEN RAISE EXCEPTION 'Attempting to get the neighbor of a pixel with a non-point geometry'; END IF; IF ST_SRID(rast) != ST_SRID(pt) THEN RAISE EXCEPTION 'Raster and geometry do not have the same SRID'; END IF; wx := st_x($3); wy := st_y($3); SELECT _st_neighborhood( $1, $2, st_worldtorastercoordx(rast, wx, wy), st_worldtorastercoordy(rast, wx, wy), $4, $5, $6 ) INTO rtn; RETURN rtn; END; $function$
Change History (4)
comment:1 by , 10 years ago
|Component:||postgis → raster|
comment:2 by , 10 years ago
I'm not in front of the relevant computer at the moment, but if it helps:
- I'm on 2.1.0rc1
- The problem seems to be present still on trunk (function begins on line 6603 of http://trac.osgeo.org/postgis/browser/trunk/raster/rt_pg/rtpostgis.sql.in)
comment:3 by , 10 years ago
|Status:||new → assigned|
comment:4 by , 10 years ago
|Status:||assigned → closed|
I haven't tried this on my version of PostGIS. Can you please state output of: