I should ignori it, but I had to correct a typo, the last query I think should be:
Select st_collectionextract(st_collect(whole_table.the_geom), 3) from (Select (st_dump(the_geom)).geom as the_geom,(st_dump(the_geom)).path as the_path, id from myTable) as whole_table left join (SELECT a.the_path, a.id FROM (SELECT (st_dump(the_geom)).geom as the_geom ,(st_dump(the_geom)).path as the_path, id from myTable) as a left join (SELECT (st_dump(the_geom)).geom as the_geom, id from myTable) as b on st_dwithin(a.the_geom, b.the_geom, theDistance) where b.id is null) too_far_away on whole_table.id=too_far_away.id and whole_table.the_path=too_far_away.path where too_far_away.path is null group by whole_table.id; /Nicklas > I want to clean up some multipolygons and remove any polygons over a > certain > distance by using a postgis function. > > This is the closest I've come: > > CREATE OR REPLACE FUNCTION filter_polygons_within(geometry, double > precision) > RETURNS geometry AS > $BODY$ > SELECT ST_Multi(ST_Collect(final_geom.poly)) AS filtered_geom > FROM ( > SELECT DISTINCT a.poly > FROM ( > SELECT ST_GeometryN(ST_Multi($1), generate_series(1, > ST_NumGeometries(ST_Multi($1)))) AS poly, > (SELECT ST_GeometryN(ST_Multi($1), generate_series(1, > ST_NumGeometries(ST_Multi($1))))) as poly_b > ) AS a > WHERE a.poly != a.poly_b > AND ST_DWithin(a.poly, a.poly_b, $1) > ) as final_geom > $BODY$ > LANGUAGE 'sql' IMMUTABLE; > > However, the where clause isn't working for me - any ideas on how to > achieve > this? I'm not sure on how to compare all polygons with each other, I > know > how to get a list of polygons; > > ST_GeometryN(ST_Multi($1), generate_series(1, > ST_NumGeometries(ST_Multi($1)))) > > I'm just not sure how to compare each one with another and return the > distinct polygon results. > > Thanks in advance, > > Ross > > _______________________________________________ > postgis-users mailing list > [email protected] > http://postgis.refractions.net/mailman/listinfo/postgis-users > _______________________________________________ postgis-users mailing list [email protected] http://postgis.refractions.net/mailman/listinfo/postgis-users
