PostGIS - Functions to create topologically correct polygons, removing overlaps and filling gaps.
Creates a topology of all polygons from a given table, removes overlaps, fill gaps, writes the corrected geometries in a new column and leaf a bunch of statistic data and log table in the topology schema.
It takes the following arguments
- schema_name CHARACTER VARYING, origin and target schema
- table_name character varying, origin and target table
- id_column CHARACTER VARYING, name of a unique column in the origin table
- geom_column CHARACTER VARYING, name of the column of the geom that has to be corrected
- epsg_code INTEGER, CRS for the corrected geometry, must be a metric system with unit meter
- distance_tolerance DOUBLE PRECISION, Used for simplification in meter
- angle_toleracne DOUBLE PRECISION, Used for simplification in degree
- topo_tolerance DOUBLE PRECISION, Used as tolerance for the topology creation in meter
- area_tolerance DOUBLE PRECISION, Used to remove small isolated holes, in square meter
- prepare_topo BOOLEAN, false if not prepare the tables before starting the correction
- expression CHARACTER VARYING, Used in SQL WHERE section to select only a part of the data from table
It uses the other functions
- gdi_PreparePolygonTopo
- gdi_NoseRemoveCore
- gdi_NoseRemove
- gdi_RemoveTopoOverlaps
- gdi_ModEdgeHealException
- gdi_CloseTopoGaps
- gdi_CleanPolygonTopo
- gdi_RemoveNodesBetweenEdges
- Execute the create statements in the files in sub directory functions in alphabetic order
- File topoClean.sql contain all function create statements in the right order at once
see in sub directory examples
Clip overlapping areas and fill gaps of subordinated polygons.
The function gdi_SnapToParentOutline requires the following other functions, which must created befor running this function.
- gdi_intersections
- gdi_extendline
- gdi_split_multi
It takes the following arguments
- child_schema character varying, Schema name of the subordniated table.
- child_table character varying, Table name of the subordinated table.
- child_pk character varying, Primary key of the subordinated table.
- child_fk character varying, Foreign key of the subordinated table related to the superordinated table.
- child_geom character varying, Geometry column of the subordinated table.
- parent_schema character varying, Schema name of the superordinated table.
- parent_table character varying, Table name of the superordinated table.
- parent_pk character varying, Primary key of the superordinated table.
- parent_geom character varying, Geometry column of the superordinated table.
The function creates some columns and tables to store between results as one can see in the declaration section of the function.
- parent_table_poly character varying = parent_table || '_poly';
- gaps_table character varying = parent_table || '_' || child_table || '_gaps';
- gap_poly_n character varying = 'gap_poly_n';
- overlaps_table character varying = parent_table || '_' || child_table || '_overlaps';
- split_table character varying = parent_table || '_' || child_table || '_gap_splits';
- parent_poly character varying = parent_geom || '_poly';
- parent_poly_n character varying = parent_poly || '_n';
- parent_line character varying = parent_geom || '_line';
- child_agg_line character varying = child_geom || '_child_agg_line';
- child_cut character varying = child_geom || '_cut';
- child_korr character varying = child_geom || '_korr'; The final result, the korrected subordinated geometry will be found in column child_geom_korr
SELECT gdi_SnapToParentOutline( 'public', 'ortsteile_hro', 'gtl_schl', 'gvb_schl', 'geom', 'public', 'gemeindeverbaende_mv', 'gvb_schl', 'geom' );