[postgis-users] Help please with PL/R

Gery gamejihou at hotmail.com
Thu Apr 12 10:12:27 PDT 2012


Thanks Ben for your answer, I see the problem now... so, let me understand
this well, I have two tables, one table of points (as the one I posted
before) and the table of lines, which was made from the table of points. I
think in my case it'd be better to smooth just the table of lines, so I have
to use the code that accepts geometry and a double precision number, and
also the code that uses 'dump_linestring_points', so something like this?:

*****
CREATE OR REPLACE FUNCTION dump_linestring_points(geometry)
RETURNS SETOF geometry AS
$BODY$
        SELECT (
                'SRID=' ||
                bar ||
                ';POINT(' ||
                foo ||
                ')'
                )::geometry
        FROM
                regexp_split_to_table(
                rtrim(
                substring(asewkt($1) from 23)
                ,')'
                ),
                ','
                ) as foo , srid($1) as bar
        WHERE st_geometrytype($1)='ST_LineString';
$BODY$
LANGUAGE sql IMMUTABLE STRICT
COST 1
ROWS 100;

CREATE OR REPLACE FUNCTION loess(geometry, double precision)
RETURNS geometry AS
$BODY$
        SELECT makeline(setsrid(makepoint(x,y),srid($1)))
        FROM (
                SELECT unnest(x) AS x, unnest(y) AS y
                FROM (
                        SELECT loess(array_agg(st_x(point))) AS x,
loess(array_agg(st_y(point))) AS y
                        FROM (
                                SELECT dump_linestring_points($1) AS point
                        ) AS foo
                ) AS bar
        ) AS baz
$BODY$
LANGUAGE sql VOLATILE
COST 100; 
*****

I haven't tested so far but I think this should work without a problems


--
View this message in context: http://postgis.17.n6.nabble.com/Help-please-with-PL-R-tp4716619p4858676.html
Sent from the PostGIS - User mailing list archive at Nabble.com.



More information about the postgis-users mailing list