Trying out PostGIS 2.2’s ST_ApproximateMedialAxis capabilities today. I’m going to use it to label parcels. So here is my parcel fabric:
And here’s what the skeleton of that fabric looks like:
It get’s pretty interesting where the parcels are more complicated:
more:
Oh, the code you say? Well, it couldn’t be much easier:
SELECT gid, ST_ApproximateMedialAxis(geom) AS geom FROM cuy_parcel_2015;
Or the full version for a new table:
DROP TABLE IF EXISTS cuy_parcel_2015_medial; CREATE TABLE cuy_parcel_2015_medial AS ( SELECT gid, ST_ApproximateMedialAxis(geom) AS geom FROM cuy_parcel_2015 );
ALTER TABLE cuy_parcel_2015_medial ADD PRIMARY KEY (gid); CREATE INDEX cuy_parcel_2015_medial_geom_idx ON cuy_parcel_2015_medial USING GIST ( geom ); Happy New Year.
There’s gonna be a Pt 2, right?!
Of course…