In the previous post: http://smathermather.wordpress.com/2014/10/25/airspace-is-complicated-and-so-i-abuse-postgis-once-again/ we explore the 3D shape and complexity of controlled airspace.
Now here’s the rest of the code. We’ll add our affine transformation ala Seth Fitsimmons:
SELECT ST_Affine( ST_Rotate(geom, -pi() / 2), -- isometric cos(pi() / 6), -cos(pi() / 6), 0, sin(pi() / 6), sin(pi() / 6), 1, 0, 0, 0, 0, 0, 0 ) AS geom
And integrate that into our original function:
-- Inputs are a geometry and an elevation to move the geometry to CREATE OR REPLACE FUNCTION threed_iso(footprint geometry, elevation numeric) RETURNS geometry AS $BODY$ -- Force 3D, then translate to the input elevation WITH floor AS ( SELECT ST_Translate( ST_Force3DZ(footprint), 0, 0, elevation ) AS geom ), -- Now make isometric (and begin Seth Code) iso AS ( SELECT ST_Affine( ST_Rotate(geom, -pi() / 2), -- isometric cos(pi() / 6), -cos(pi() / 6), 0, sin(pi() / 6), sin(pi() / 6), 1, 0, 0, 0, 0, 0, 0 ) AS geom FROM floor ) -- We'll force it back to 3D so QGIS is happy SELECT ST_Force2D(geom) FROM iso ; $BODY$ LANGUAGE sql VOLATILE COST 100;
And voila!
DROP TABLE IF EXISTS class_c_isoc; CREATE TABLE class_c_isoc AS SELECT gid, airspace, name, lowalt, highalt, threed_iso(geom, lowalt::numeric * 5) AS geom FROM class_c_subset;
Let’s take a look at Washington, DC and surrounds, another nice complicated example:
Image may be NSFW.
Clik here to view.
Clik here to view.

3D Figure of DC controlled airspace
And again with map tiles by Stamen Design, under CC BY 3.0. Data by OpenStreetMap, under ODbL:
Image may be NSFW.
Clik here to view.
Clik here to view.

3D Figure of DC controlled airspace
Image may be NSFW.
Clik here to view.

Clik here to view.
