Smathermather's Weblog

Remote Sensing, GIS, Ecology, and Oddball Techniques

Archive for the ‘Cartography’ Category

Airspace — A deep rabbit hole

Posted by smathermather on October 25, 2014

In previous maps we looked at Class B, C, and D airspace. Let’s add in Class E0 and E5… (not yet in 3D):

(Map tiles by Stamen Design, under CC BY 3.0. Data by OpenStreetMap, under ODbL)

Map showing Class B, C, D, E0, and E5 airspace

Map showing Class B, C, D, E0, and E5 airspace

Previous posts:

https://smathermather.wordpress.com/2014/10/25/airspace-is-complicated-and-so-i-abuse-postgis-once-again/

and

https://smathermather.wordpress.com/2014/10/25/airspace-is-complicated-and-so-i-abuse-postgis-once-again-reprise/

Posted in 3D, Cartography, Database, Drone, PostGIS, PostgreSQL, SQL, UAS | Tagged: , , , , , | Leave a Comment »

Airspace is complicated — and so I abuse PostGIS once again — Reprise…

Posted by smathermather on October 25, 2014

In the previous post: https://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:

3D Figure of DC controlled airspace

3D Figure of DC controlled airspace

And again with map tiles by Stamen Design, under CC BY 3.0. Data by OpenStreetMap, under ODbL:

3D Figure of DC controlled airspace

3D Figure of DC controlled airspace

 

Posted in 3D, Cartography, Database, Drone, PostGIS, PostgreSQL, SQL, UAS | Tagged: , , , , , | 3 Comments »

Airspace is complicated — and so I abuse PostGIS once again

Posted by smathermather on October 25, 2014

Let’s ignore for a moment the drone hobbiest / enthusiast. What is the shape of airspace for airplanes and commercial and government unmanned aircraft flying under Certificates of Authorization, and how can we visualize it?

Thanks to Anita in the last post, we have the Class B,C,D,E Airspace Shape Files which helps us define the overall shape of controlled airspace.

Map of Detroit, Cleveland, and Pittsburgh Class B Airspace

Map of Detroit, Cleveland, and Pittsburgh Class B Airspace

But, these are 3D things. I want to visualize them thus. Let us put some constraints on the problem. Let’s do it all in PostGIS, that way we can see it in QGIS or on the web. Let’s not use full PostGIS 3D (i.e. the SFCGAL library), not because it isn’t awesome (it truly is) but because it can be hard to install at the moment (although see https://github.com/vpicavet/docker-pggis for an easy way with docker). Finally, true 3D with unconstrained viewing angles and 100% flexibility is… is… well it usually sucks. So, we’ll stick to isometric viewing (thanks to Seth Fitzsimmons of Stamen http://stamen.com/ for his PostGIS isometric code which will be released upon his word). (Update — all the code is there…):

-- 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;

Ok, now let’s rock some geometries with this bad function:

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;

And what do our controlled airspaces look like?

Isometric view of Cleveland controlled airspace

Isometric view of Cleveland controlled airspace

Kind of conical, in this case with some “wings” that serve as approaches. It makes sense, I guess. At the center, where the airport is, controlled airspace goes from the ground up. As we get further from the airport, a set of concentric rings starting at higher elevations provide a controlled space that allows for landing and taking off.

Image of Cleveland airspace with Stamen Toner map as backdrop

Map tiles by Stamen Design, under CC BY 3.0. Data by OpenStreetMap, under ODbL.

There are more complicated ones, naturally. We need look no further than Detroit for additional complexity:

Visualization of Detroit controlled airspace

Visualization of Detroit controlled airspace

airspace_detroit_toner

No wonder every time I fly through Detroit, no matter where I’m going, I end up flying over Lake Erie.

If we want really complicated, we need look no further than Cincinnati:
airspace_cinci

What is going on there? Is that due to shape of the hills, or city boundaries?

Finally, what does airspace look like over Ohio, West Virginia, and Pennsylvania (etc.), overall?
airspace_is_complicated_regional

And while the following map isn’t quite right, here is a figure including many of the small airports sans controlled airspace:

View of all controlled and uncontrolled airspace across Ohio and neighbors.

View of all controlled and uncontrolled airspace across Ohio and neighbors.

May an aeronautical pox be upon you!
The above line was not intended in bad taste, but just an homage to the “red dot fever” of early neo-geography (neo-geography which I’m informed definitionally doesn’t exist). Only a few minutes ago, it dawned on me that the deleted phrase could be misinterpreted these days… .

On a related note, if you want an interesting analysis of ebola, read Zeynep Tufekci’s analysis.

(for the record, all heights are exagerated by 5x, for clarity of reading).

Also, in case it wasn’t obvious: Map tiles by Stamen Design, under CC BY 3.0. Data by OpenStreetMap, under ODbL.

Posted in 3D, Cartography, Database, Drone, PostGIS, PostgreSQL, SQL, UAS | Tagged: , , , , , | 4 Comments »

Parks Data Cake, part deux

Posted by smathermather on April 2, 2014

Following up on my previous post, I have started to detail the how of our parks map rendering works, including a GitHub repository with all the code and data to build your own in TileStache. One of these days, we’ll port this to TileMill, but in the mean time, it works and works wonderfully.

Screenshot of trailsforthepeople-styles github readme.md

 

— Addendum —

Truth in advertising– the contours data were not included in the repository as they are 1.3 GB all by themselves

— End Addendum —

 

Posted in Cartography, Recreation, TileStache, Trail Curation, Trails | Tagged: , | Leave a Comment »

Parks Data Cake

Posted by smathermather on March 24, 2014

Stamen has a great blog entry on mapping for parks on their blog. It’s a teaser for a deeper dive in mapping parks, and I’m staying tuned, as their write-ups tend to be detailed, thoughtful, and complete.

I thought I’d offer my own teaser– a bit of work done collaboratively with GreenInfo Network.  It started with their basemap– something they spent a few person-years refining from OSM data.

Example of GIN basemap

Example of GIN custom basemap

Custom basemap

We took it a little further by creating custom placed labels where the labels gave us some extra bang for the buck.

Custom text placement example

Custom text placement

And then we started to really play with the zoomed in versions, using nicely detailed streams, contours, and canopy boundaries (derived from LiDAR) to enrich the map, labeling natural features and major facilities with custom labels as well:

Image showing labeling, contours, vegetation, etc.

Detailed view of map

A couple of tricks we used here– first, the custom labels have shadows (convex hull) masks which match the background, ala this write up:

Example of masked text

Also, compositing is used heavily– the hillshade background is flattened significantly, and then overlayed with multiplied composites of park green, canopy green on top, contours, with all other layers being simple overlays. This results in a brightness and clarity to the information that allows for complexity without either muddling the map, or overwhelming the map reader.

Finally, since many of the parks are urban, major buildings are highlighted for context. In future revisions, we’ll add more (but still subdued) detail to the areas outside the parks, but this was a good start:

Example of major buildings showing on map near a park

In case you are wondering about technology, this is all done in TileStache (edit: and GeoServer).  In the future, this may well be replicated in Tilemill. More to come… .

Posted in Cartography, Recreation, TileStache, Trail Curation, Trails | Tagged: , | 4 Comments »

North American Cartographic Information Society (NACIS) Conference (yay #NACIS!)

Posted by smathermather on October 14, 2013

In a short blog post, I won’t be able to do the NACIS conference justice, but if you haven’t gone and you are a map geek, then I recommend you attend next year’s conference in Pittsburg.  First:

The People:

What a collegial and warm group of people.  NACIS was a very welcoming community, an interesting mix of private industry geniuses (ahem, Mapbox, Stamen, Vizzuality etc.), academics, students, National Geographic cartographers, and typically some serious Federal representation (although largely absent this year, a notable exception being Mamata Akella from NPSMaps who is technically not directly employed by the Feds and so was allowed to attend anyway).  As someone who spent the better part of a decade in the academic sector, it was fascinating (and comforting) to be back among (largely) introverts.  I would, however, argue the Nat Geo Cartographers were generally an exception to the introversion, but really pleasant and interesting folks as well.

Also, Andrew Hill from Vizzuality was there, so I picked his brain on features coming down the pike (including better Torque support, including a GUI soon), and bugged him to add pgRouting to the back end of CartoDB… .  He seemed receptive to this, and suggested following up under CartoDB support.

Presentations:

All the presentations were great.  From a very tech-practical standpoint, I enjoyed Carl Sack’s presentation on D3.  It was a great intro to D3js, and really got me over the basic barrier to using D3– getting the data in.  The TL;DR– order matters in the use of the API, queue.js is mighty useful, and all the data manipulation needs to go in the callback function to ensure your D3 goodness isn’t sunk by asynchronous execution.

The Maps:

Oh, boy there were some nice maps in the map gallery.  One trail map was an excellent theft of Swiss cartographic techniques, all the maps were interesting and well polished, and it was fun to look around at the diversity of approaches and topics.  Two maps of note that I really enjoyed– one is a map/infographic of wool exports from New Zeland, knitted in wool on a maker space constructed knitting machine:

Wool map

Also a really nice alternative piece was a bathymetry map by Carolyn Rose, which can be viewed at her blog: http://bathymetricbook.blogspot.com/

Other:

My presentation went well.  There were lots of questions about a project we’ve been working on for our public web interface to help people find trails, parks, picnic areas and other parky amenities.  We just posted the code for the project to GitHub (https://github.com/cleveland-metroparks/trailsforthepeople) and I’ll have my slides posted from the presentation shortly.  It was really great to connect with others working and starting to work in similar spaces of parks and recreation mapping.  I am already enjoying the follow-up and hope this builds in to a large spatial/web community servicing this sector.

 

Posted in Cartography, Conference, NACIS | Tagged: , | Leave a Comment »

QGIS Compositing, credits where due

Posted by smathermather on April 15, 2013

Credit where credit’s due on the great QGIS Compositing (as well as some stellar forthcoming raster tools):

http://nyalldawson.net/2013/03/coming-soon-in-qgis-2-0-blend-modes-for-layers/

I thought I had seen an unusually large spike in my Aussie traffic… .

Posted in Cartography, QGIS | Tagged: , , | Leave a Comment »

QGIS Compositing, more comparisons

Posted by smathermather on April 10, 2013

QGIS Compositing, more comparisons… .  You guess which is QGIS and which is TileStache… .

more_compositing_comparisons

Posted in Cartography, QGIS, TileStache | Tagged: , , | Leave a Comment »

QGIS Compositing, more gushing yet…

Posted by smathermather on April 9, 2013

Ever had a workflow on the web that resulted in stuff so nice, you wanted to replicate on the desktop?  Ya, me neither until recently.  I love the cartography a particular website, know all the bits and pieces of color and effects that go into, but had no desktop application that could do the same.   Until now.  On the left, QGIS, on the right, TileStache (i.e. mapnik).  There were a few practical differences in application which result in most of the differences you do see, but now we can wrap great cartography into all our products, printed or web.  And no, print is not dead yet, whatever the declaration.

blending_compositing_qgis

Posted in Cartography, QGIS, TileStache | Tagged: , , | Leave a Comment »

Quantum GIS Compositing Continued

Posted by smathermather on April 9, 2013

QGIS compositing is not limited just to between layers, but also for elements in the Print Composer. How is this useful? Every want a non-rectangular map? With 1.9 alpha, you can use an SVG to affect the elements under it.  On the right, the svg.  On the left, the map element inside the Print Composer.

01

Overlay the two with “Blending Mode” set to “Normal” and the svg covers the map.

02

Set the svg blending mode to “Dodge”, and we get an interesting mask, as well as (in this case) some additional affects related to the two different shades in our svg.

03

The svg shapes can be anything:

04

But let’s try something more meaningful, for example, using an svg to mask our map of a peninsula:

05

06

For your inner cartographer– behold!  A non-rectangular map!  Wrap some text around that puppy and call it art.

BTW, the map itself is a fake summer aerial created with povray, a winter aerial, and a little tinting of the winter aerial using blending mode “multiply” in the map itself.  But that is the topic of another post… .

 

Posted in Cartography, QGIS | Tagged: , | 2 Comments »