id,summary,reporter,owner,description,type,status,priority,milestone,component,version,resolution,keywords,cc
2384,"[raster] Problem in ST_Neighborhood(raster, integer, geometry, integer, integer, boolean)",jawj,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$
}}}
",defect,closed,medium,PostGIS 2.1.0,raster,2.1.x,fixed,history,