22
Skeletonizing Polygons Using PostGIS

Skeletonizing Polygons Using PostGIS - Amazon Web Servicesgwmap.s3.amazonaws.com/www/presentations/WyGEO-Casper-2015.pdf · maps and mapserver. Questions? Angie Rudolph, GISP [email protected]

Embed Size (px)

Citation preview

Page 1: Skeletonizing Polygons Using PostGIS - Amazon Web Servicesgwmap.s3.amazonaws.com/www/presentations/WyGEO-Casper-2015.pdf · maps and mapserver. Questions? Angie Rudolph, GISP angie@greenwoodmap.com

Skeletonizing PolygonsUsing PostGIS

Page 2: Skeletonizing Polygons Using PostGIS - Amazon Web Servicesgwmap.s3.amazonaws.com/www/presentations/WyGEO-Casper-2015.pdf · maps and mapserver. Questions? Angie Rudolph, GISP angie@greenwoodmap.com

● Vegetation Layer

DATA SET

● Water data extracted

1:150,000

● Snake River

Page 3: Skeletonizing Polygons Using PostGIS - Amazon Web Servicesgwmap.s3.amazonaws.com/www/presentations/WyGEO-Casper-2015.pdf · maps and mapserver. Questions? Angie Rudolph, GISP angie@greenwoodmap.com

PreviousSimplification Results

Original

Different Algorithms = Different Results

Mapshaper 0.7%

1:150,000

QGIS, PostGIS, OpenJump

Douglas-Peucker Algorithm Visvalingam Algorithm

Page 4: Skeletonizing Polygons Using PostGIS - Amazon Web Servicesgwmap.s3.amazonaws.com/www/presentations/WyGEO-Casper-2015.pdf · maps and mapserver. Questions? Angie Rudolph, GISP angie@greenwoodmap.com

THE GOAL

Extract the center line of a river from a polygon data set

1:34,000

Page 5: Skeletonizing Polygons Using PostGIS - Amazon Web Servicesgwmap.s3.amazonaws.com/www/presentations/WyGEO-Casper-2015.pdf · maps and mapserver. Questions? Angie Rudolph, GISP angie@greenwoodmap.com

Tools

GRASS GIS

QGIS

Page 6: Skeletonizing Polygons Using PostGIS - Amazon Web Servicesgwmap.s3.amazonaws.com/www/presentations/WyGEO-Casper-2015.pdf · maps and mapserver. Questions? Angie Rudolph, GISP angie@greenwoodmap.com

PostGIS/SFCGAL

SFCGAL is a C++ wrapper library around CGAL that provides 2D and 3D geometric functions.

CGAL = The Computational Geometry Algorithms Library

PostGIS is a spatial database extender for PostgreSQL object-relational database.

Page 7: Skeletonizing Polygons Using PostGIS - Amazon Web Servicesgwmap.s3.amazonaws.com/www/presentations/WyGEO-Casper-2015.pdf · maps and mapserver. Questions? Angie Rudolph, GISP angie@greenwoodmap.com

2D Straight Skeleton and Polygon Offsetting

The straight skeleton of a polygon is defined by a continuous shrinking process in which the edges of the polygon are moved inwards parallel to themselvesat a constant speed.

As the edges move in this way, the vertices where pairsof edges meet also move.

If one of these moving vertices collides with a nonadjacentedge, the polygon is split in two by the collision.The straight skeleton is the set of curves traced out by the moving vertices in this process.

Page 8: Skeletonizing Polygons Using PostGIS - Amazon Web Servicesgwmap.s3.amazonaws.com/www/presentations/WyGEO-Casper-2015.pdf · maps and mapserver. Questions? Angie Rudolph, GISP angie@greenwoodmap.com

ST_StraightSkeleton — Compute a straight skeleton from a geometry

CREATE TABLE snake_partskeleton AS SELECT st_straightskeleton(snake_part.wkb_geometry) AS wkb_geometry FROM snake_part;

ALTER TABLE snake_partskeleton OWNER TO postgres;GRANT ALL ON TABLE snake_partskeleton TO postgres;GRANT SELECT ON TABLE snake_partskeleton TO pgselectonly;

Page 9: Skeletonizing Polygons Using PostGIS - Amazon Web Servicesgwmap.s3.amazonaws.com/www/presentations/WyGEO-Casper-2015.pdf · maps and mapserver. Questions? Angie Rudolph, GISP angie@greenwoodmap.com

Output Problem: Need to get rid of the dangles

Page 10: Skeletonizing Polygons Using PostGIS - Amazon Web Servicesgwmap.s3.amazonaws.com/www/presentations/WyGEO-Casper-2015.pdf · maps and mapserver. Questions? Angie Rudolph, GISP angie@greenwoodmap.com

1. PostGIS - negative buffer and st_crosses

2. GRASS GIS – remove dangles

Possible Solutions

Page 11: Skeletonizing Polygons Using PostGIS - Amazon Web Servicesgwmap.s3.amazonaws.com/www/presentations/WyGEO-Casper-2015.pdf · maps and mapserver. Questions? Angie Rudolph, GISP angie@greenwoodmap.com

PostGIS negative buffer and st_crosses

Page 12: Skeletonizing Polygons Using PostGIS - Amazon Web Servicesgwmap.s3.amazonaws.com/www/presentations/WyGEO-Casper-2015.pdf · maps and mapserver. Questions? Angie Rudolph, GISP angie@greenwoodmap.com
Page 13: Skeletonizing Polygons Using PostGIS - Amazon Web Servicesgwmap.s3.amazonaws.com/www/presentations/WyGEO-Casper-2015.pdf · maps and mapserver. Questions? Angie Rudolph, GISP angie@greenwoodmap.com

PostGIS negative buffer and st_crosses

Page 14: Skeletonizing Polygons Using PostGIS - Amazon Web Servicesgwmap.s3.amazonaws.com/www/presentations/WyGEO-Casper-2015.pdf · maps and mapserver. Questions? Angie Rudolph, GISP angie@greenwoodmap.com

Increase buffer – loose parts

Page 15: Skeletonizing Polygons Using PostGIS - Amazon Web Servicesgwmap.s3.amazonaws.com/www/presentations/WyGEO-Casper-2015.pdf · maps and mapserver. Questions? Angie Rudolph, GISP angie@greenwoodmap.com

Using simplified polygon layer

Page 16: Skeletonizing Polygons Using PostGIS - Amazon Web Servicesgwmap.s3.amazonaws.com/www/presentations/WyGEO-Casper-2015.pdf · maps and mapserver. Questions? Angie Rudolph, GISP angie@greenwoodmap.com

GRASS GIS via QGIS

Page 17: Skeletonizing Polygons Using PostGIS - Amazon Web Servicesgwmap.s3.amazonaws.com/www/presentations/WyGEO-Casper-2015.pdf · maps and mapserver. Questions? Angie Rudolph, GISP angie@greenwoodmap.com

Tool = v.clean.rmdangle

A line/boundary is considered to be a dangle if no other line of given type is on at least one end node.

The rmdangle tool deletes a dangle if the length is shorter than thresh or thresh < 0.

Page 18: Skeletonizing Polygons Using PostGIS - Amazon Web Servicesgwmap.s3.amazonaws.com/www/presentations/WyGEO-Casper-2015.pdf · maps and mapserver. Questions? Angie Rudolph, GISP angie@greenwoodmap.com

Threshold = 200'Threshold = 100'

Page 19: Skeletonizing Polygons Using PostGIS - Amazon Web Servicesgwmap.s3.amazonaws.com/www/presentations/WyGEO-Casper-2015.pdf · maps and mapserver. Questions? Angie Rudolph, GISP angie@greenwoodmap.com

Threshold = 200'Threshold = 100'

Using simplified polygon layer

Page 20: Skeletonizing Polygons Using PostGIS - Amazon Web Servicesgwmap.s3.amazonaws.com/www/presentations/WyGEO-Casper-2015.pdf · maps and mapserver. Questions? Angie Rudolph, GISP angie@greenwoodmap.com

Remember THE GOALExtract the center line of a river from a

polygon data set

PostGIS

GRASS

simplified polygon

simplified polygon

Page 21: Skeletonizing Polygons Using PostGIS - Amazon Web Servicesgwmap.s3.amazonaws.com/www/presentations/WyGEO-Casper-2015.pdf · maps and mapserver. Questions? Angie Rudolph, GISP angie@greenwoodmap.com

Next Steps

● ST_ApproximateMedialAxis● Use to create a stream flow

network?● Use for labeling purposes on

maps and mapserver

Page 22: Skeletonizing Polygons Using PostGIS - Amazon Web Servicesgwmap.s3.amazonaws.com/www/presentations/WyGEO-Casper-2015.pdf · maps and mapserver. Questions? Angie Rudolph, GISP angie@greenwoodmap.com

Questions?

Angie Rudolph, GISP

[email protected]