<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Closed Contour &#187; cartography</title>
	<atom:link href="http://blog.closedcontour.com/category/cartography/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.closedcontour.com</link>
	<description>Modernizing the topographic map</description>
	<lastBuildDate>Sat, 09 Apr 2011 06:11:00 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>v2 SPS Tiles Posted</title>
		<link>http://blog.closedcontour.com/2010/06/27/v2-sps-tiles-posted/</link>
		<comments>http://blog.closedcontour.com/2010/06/27/v2-sps-tiles-posted/#comments</comments>
		<pubDate>Mon, 28 Jun 2010 04:34:57 +0000</pubDate>
		<dc:creator>Dan</dc:creator>
				<category><![CDATA[Closed Contour]]></category>
		<category><![CDATA[cartography]]></category>

		<guid isPermaLink="false">http://blog.closedcontour.com/?p=118</guid>
		<description><![CDATA[I&#8217;ve posted new tiles with the following changes:

Whiter glaciers/permanent snow with blue contour lines. I talked about this in a previous post.
Change forest color depending on density (only in Yosemite and Sequoia/King&#8217;s Canyon NP so far). I also mentioned this in a previous post.
Non-SPS peak names.  Discussed earlier as well.
Pass names.
Trail names, mostly in the [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve posted new tiles with the following changes:</p>
<ul>
<li>Whiter glaciers/permanent snow with blue contour lines. I talked about this in <a href="http://blog.closedcontour.com/2010/06/07/glacier-contours/" target="_self">a previous post</a>.</li>
<li>Change forest color depending on density (only in Yosemite and Sequoia/King&#8217;s Canyon NP so far). I also mentioned this in <a href="http://blog.closedcontour.com/2010/06/09/lessons-from-the-weekend/" target="_self">a previous post</a>.</li>
<li>Non-SPS peak names.  <a href="http://blog.closedcontour.com/2010/06/26/fixing-gnis-data/" target="_self">Discussed earlier</a> as well.</li>
<li>Pass names.</li>
<li>Trail names, mostly in the NPs.</li>
<li>Removed many bogus &#8216;lakes&#8217; which were actually mischaracterized permanent snow.</li>
<li>Added styling for scree, talus, and meadow/marshes.</li>
<li>Changed font for SPS peaks to slightly larger, darker, and italic to set them apart from non-SPS peaks.</li>
<li>Not a tile change, but I added UTM coordinate display in lower right.</li>
</ul>
<p>Here&#8217;s an image showing most of these new features:</p>
<div id="attachment_120" class="wp-caption alignnone" style="width: 645px"><a href="http://blog.closedcontour.com/wp-content/uploads/2010/06/v2_sample.jpg"><img class="size-full wp-image-120 " title="v2_sample" src="http://blog.closedcontour.com/wp-content/uploads/2010/06/v2_sample.jpg" alt="" width="635" height="417" /></a><p class="wp-caption-text">v2 Sample</p></div>
<p>Note that I screwed up the land cover in Yosemite National Park by accidentally styling it with two sets of landcover data.  Obvious side effects of this are that the whole area is generally too green and the permanent snow sections look funny.  It will take me a few days to fix this.</p>
<p>Enjoy the new tiles!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.closedcontour.com/2010/06/27/v2-sps-tiles-posted/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Glacier Contours</title>
		<link>http://blog.closedcontour.com/2010/06/07/glacier-contours/</link>
		<comments>http://blog.closedcontour.com/2010/06/07/glacier-contours/#comments</comments>
		<pubDate>Tue, 08 Jun 2010 03:39:37 +0000</pubDate>
		<dc:creator>Dan</dc:creator>
				<category><![CDATA[Closed Contour]]></category>
		<category><![CDATA[Technique]]></category>
		<category><![CDATA[cartography]]></category>
		<category><![CDATA[contours]]></category>
		<category><![CDATA[glaciers]]></category>
		<category><![CDATA[postgis]]></category>
		<category><![CDATA[postgresql]]></category>
		<category><![CDATA[sql]]></category>

		<guid isPermaLink="false">http://blog.closedcontour.com/?p=45</guid>
		<description><![CDATA[I consider the USGS 7.5&#8242; quads to be among the best topographic maps around.  That said, working around their shortcomings is the primary cartographic motivation for Closed Contour.  Right now I feel like I have a ways to go before I can claim that my maps are &#8216;better&#8217; (how ever you define it) than the [...]]]></description>
			<content:encoded><![CDATA[<p>I consider the <a href="http://topomaps.usgs.gov/drg/" target="_blank">USGS 7.5&#8242; quads</a> to be among the best topographic maps around.  That said, working around their shortcomings is the primary cartographic motivation for Closed Contour.  Right now I feel like I have a ways to go before I can claim that my maps are &#8216;better&#8217; (how ever you define it) than the USGS quads.  Really this is a long-winded way of saying that I&#8217;m going to blatantly steal ideas and styling from the USGS quads until they don&#8217;t have anything more to offer!</p>
<p>Here&#8217;s a prime example: contour lines on glaciers (or, in California, permanent snow).  Take a look at the area around <a href="http://www.closedcontour.com/?zoom=7&amp;lat=4106852.8&amp;lon=131515.2&amp;layers=B" target="_blank">North Palisade</a>:</p>
<div id="attachment_70" class="wp-caption aligncenter" style="width: 266px"><a href="http://blog.closedcontour.com/wp-content/uploads/2010/06/glacier-contour-usgs.jpg"><img class="size-full wp-image-70" title="glacier-contour-usgs" src="http://blog.closedcontour.com/wp-content/uploads/2010/06/glacier-contour-usgs.jpg" alt="" width="256" height="256" /></a><p class="wp-caption-text">USGS Topo</p></div>
<p>And now the same area as rendered in the v1 SPS Map tiles:</p>
<div id="attachment_69" class="wp-caption aligncenter" style="width: 266px"><a href="http://blog.closedcontour.com/wp-content/uploads/2010/06/glacier-contour-cc.jpg"><img class="size-full wp-image-69" title="glacier-contour-cc" src="http://blog.closedcontour.com/wp-content/uploads/2010/06/glacier-contour-cc.jpg" alt="" width="256" height="256" /></a><p class="wp-caption-text">Closed Contour</p></div>
<p>See the problem?  On the USGS map, contour lines on the Palisade Glacier are light blue, as is the outline.  Even though the glacier is white on the Closed Contour map you can barely see it.  I decided that my maps needed this feature, both for usability and aesthetics.</p>
<p>Another motivation for making this map was to learn some new technologies.  Sure, I&#8217;d written a little SQL before and I&#8217;m pretty familiar with geospatial software and techniques, but I hadn&#8217;t ever really used <a href="http://www.postgresql.org/" target="_blank">PostgreSQL</a> and/or <a href="http://postgis.refractions.net/" target="_blank">PostGIS</a>.  This would be a great opportunity to try to do something useful purely in SQL.</p>
<p>A little background: at this point all of the map data (except the hillshade raster)  are stored in a haphazardly organized PostgreSQL with PostGIS database; each data source with it&#8217;s own table.  Actually, in the case of contours I have them separated into 3 tables, one for 40&#8242;, one for 200&#8242;, and one for 1000&#8242; intervals.  This is an artifact of the contour generation/import process and something I&#8217;ll hopefully clean up.  There&#8217;s also a polygon land-cover table.</p>
<p>So all I need to do is to iterate over the snow/glacier land-cover polygons, find all contours inside them, slice them to be exactly inside the snow and mark them as such, and then subtract out the contours from the original data set.  No problem, right?  Here&#8217;s how I accomplished that in SQL:</p>
<pre class="brush: sql; light: true;">
CREATE OR REPLACE FUNCTION find_snow_contours()
    RETURNS  void AS $$
DECLARE
   contour_line RECORD;
   snow_poly RECORD;
   g geometry;
BEGIN
   -- Holding place for contours that are purely contained by snow/glacier
   DROP TABLE IF EXISTS temp_snow_contours;
   CREATE TABLE temp_snow_contours (like contours_40);

   -- Iterate over all snow polygons ('snow' is a temporary table with just snow polygons')
   FOR snow_poly IN SELECT * FROM snow LOOP
      -- Iterate over all contour lines that intersect this snow polygon
      FOR contour_line IN SELECT * from contours_40 WHERE ST_Intersects(the_geom, snow_poly.the_geom) LOOP

         -- Subtract off the snow section and save resulting lines as non-snow contours
         SELECT INTO g ST_Difference(contour_line.the_geom, snow_poly.the_geom);

         -- Delete the original contour line and replace it with the remaining segments
         -- It's common for there to be many segments after the difference, hence the 'ST_Dump'
         DELETE FROM contours_40 WHERE gid = contour_line.gid;
         INSERT INTO contours_40 (elev, is_snow, the_geom)
            SELECT contour_line.elev, 0, (ST_Dump(g)).geom;

         -- Add the intersection as snow contours
         SELECT INTO g ST_Intersection(contour_line.the_geom, snow_poly.the_geom);
         INSERT INTO temp_snow_contours (gid, elev, is_snow, the_geom) VALUES (contour_line.gid, contour_line.elev, 1, g);

      END LOOP;
   END LOOP;

   -- Finally put the snow contours back in the main table.
   INSERT INTO contours_40 (elev, the_geom, is_snow)
      SELECT  elev, (ST_Dump(the_geom)).geom, is_snow FROM temp_snow_contours;
   DROP TABLE temp_snow_contours;
   RETURN;
END;
$$
</pre>
<p>I imagine that a PostGIS SQL-guru would look at this function and shudder&#8230; forgive me, I&#8217;m a newb.  Anyway, this technique worked out nicely and I&#8217;m pretty happy with the result:</p>
<div id="attachment_68" class="wp-caption aligncenter" style="width: 450px"><a href="http://blog.closedcontour.com/wp-content/uploads/2010/06/glacier-contour-before-after.jpg"><img class="size-full wp-image-68" title="glacier-contour-before-after" src="http://blog.closedcontour.com/wp-content/uploads/2010/06/glacier-contour-before-after.jpg" alt="Before on the left, After on the right" width="440" height="380" /></a><p class="wp-caption-text">(L) Before, (R) After</p></div>
<p>Not sure when I&#8217;ll generate them but I&#8217;ll definitely be rolling this feature into v2 of the tiles.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.closedcontour.com/2010/06/07/glacier-contours/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

