[postgis-tickets] [PostGIS] #2384: [raster] Problem in ST_Neighborhood(raster, integer, geometry, integer, integer, boolean)
PostGIS
trac at osgeo.org
Wed Jul 17 05:48:29 PDT 2013
#2384: [raster] Problem in ST_Neighborhood(raster, integer, geometry, integer,
integer, boolean)
---------------------+------------------------------------------------------
Reporter: jawj | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.1.0
Component: postgis | Version: 2.1.x
Keywords: |
---------------------+------------------------------------------------------
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$
}}}
--
Ticket URL: <http://trac.osgeo.org/postgis/ticket/2384>
PostGIS <http://trac.osgeo.org/postgis/>
The PostGIS Trac is used for bug, enhancement & task tracking, a user and developer wiki, and a view into the subversion code repository of PostGIS project.
More information about the postgis-tickets
mailing list