My 02c... If you have a table with a geometry column, you can add a second geometry column for the simplified ones. As in the script below, for a national coastline with about 10,000 polygons
You can generate the simplified ones using a series of update SQL statements, based on a variety of criteria, including neighbouring (or not) via a ST_Distance() in the where clause. If you hand craft the update SQL's, you can just copy rather than simplify smaller polygons (ST_Area in the where clause), etc. A slowish way, but viable for a 1-off is to have a where clause with an ST_IsValid in the where clause testing the result of the simplification. If the where clause includes a test for the target geometry being not-null, the series can apply a large simplification initially, then progressively apply a decreasing simplifcation buffer to features that failed previous iterations, until the last statement copies any remaining features with zero simplification. I prefer a script with a set of SQL's rather than a function, as it is easier to tweak case requirements. The advantage of this approach over the preserving topology simplify function is the degree of control the hand crafted SQL's provide over exactly how to simplify the dataset. But, as always, your mileage may vary :-) Cheers, Brent Wood #! /bin/bash # # script to simplify NZ coastline for zoom layer DB=nzcoast TAB=nz_all # add new geometry column psql -d $DB -c "alter table nz_all drop column simple_geom;" psql -d $DB -c "alter table nz_all add column simple_geom geometry(multipolygon,4326);" # populate # do small islands with no simplification psql -d $DB -qc "update nz_all set simple_geom=geom where ST_Area(geom) < 0.0000000001;" psql -d $DB -qc "update nz_all set simple_geom=ST_Simplify(geom, 0.001) where simple_geom isnull and ST_IsValid(ST_Simplify(geom, 0.001));" psql -d $DB -qc "update nz_all set simple_geom=ST_Simplify(geom, 0.0001) where simple_geom isnull and ST_IsValid(ST_Simplify(geom, 0.0001));" psql -d $DB -qc "update nz_all set simple_geom=ST_Simplify(geom, 0.00001) where simple_geom isnull and ST_IsValid(ST_Simplify(geom, 0.00001));" psql -d $DB -qc "update nz_all set simple_geom=geom where simple_geom isnull;" --- On Sat, 5/26/12, Carson Farmer <carson.far...@gmail.com> wrote: From: Carson Farmer <carson.far...@gmail.com> Subject: Re: [Qgis-developer] Vector Layer Generalization To: "Evgeniy Pashentsev" <ugnp...@gmail.com> Cc: qgis-developer@lists.osgeo.org Date: Saturday, May 26, 2012, 10:11 AM Excellent! Topology preserving simplification is something I've been looking for! > But I want to ask your advice on one thing. Is it normal for user > to simplify all the features on a layer at once? I'm just not sure > which way is more suitable for a regular user: > - simplify all the features at once as it is now in my current prototype; > - simplify selected feature and all the corresponding vertexes of > the neighboring features; > - or simplify only selected features; > - or even something else. > Although it is not very important for current work, I want to make sure > I don't implement useless functionality. Personally, I normally simplify an entire layer at once... for mapping purposes, or simply to reduce drawing time or for computational/space efficiency. It might be nice to also have the option to simplify selected features only, but if this was an option, then I would expect *only* those selected features to be simplified... and *not* their neighbouring features... That's my two cents anyway, looking forward to trying it out! Carson -- Dr. Carson J. Q. Farmer Centre for GeoInformatics (CGI) School of Geography and Geosciences Irvine Building, University of St Andrews St Andrews, Fife, KY16 9AL Scotland, UK _______________________________________________ Qgis-developer mailing list Qgis-developer@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/qgis-developer
_______________________________________________ Qgis-developer mailing list Qgis-developer@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/qgis-developer