Friday, August 15, 2014

PDFs get Geospatial

Printing Geospatial PDFs that can be used in programs like Avenza PDF Maps is an oft-requested feature that's been hanging over my head for some time.  Having looked into it and abandoned the effort, I've lived life dreading the prospect of wading back into the fray.  However I took another crack at it this week and, armed with a better understanding of the PDF spec, it turned out not to be so bad.

Starting now, all single-page PDFs generated by CalTopo are Geospatial PDFs.  Edit: Looks like I jumped the gun a bit.  There were some compatibility issues with the iOS version of Avenza that have now been fixed.

Complementing this is a new short-URL feature that makes it easier to share CalTopo PDFs or load them onto a phone.  Step 1 is, as usual, to click Print and then Create a PDF:


Underneath the Generate PDF button is a new Generate Link button.  This behaves just like Generate PDF, but instead a new browser tab opening with a long query string or a blank form post, it opens with a short URL.


Anyone with this URL can now download your PDF; no need to save it to a computer and then share using a 3rd part hosting service.  While the print page indicates that links expire in 30 days, I may keep them around longer if they don't occupy too much space - currently I have to go in and purge them manually.

The only reason for a separate Generate Link button is to avoid cluttering my database with PDFs that will never be shared.  If that proves to be a non-issue, I'll merge them into one button that always generates a short URL.

I have no affiliation with Avenza, but their free PDF Maps app allows you to import directly from the CalTopo URL:


Thursday, June 19, 2014

Revised Marker Icons

In keeping with the recent line style update, I've made some changes to marker icons.  While a few icons have been added, the focus was adding colorability and rotatability, and laying the groundwork to add additional icons at a later date.

Instead of showing all possible icons, the marker dialog now shows the icon's style, and optionally its color and orientation.  Click on the style swatch to bring up a full-screen dialog similar to the line style dialog:


Mostly this is a retread of the previous set of icons.  A few wildland fire icons have been added, along with a letter-in-circle option.  However unlike the previous all-in-one dialog, this one has room to grow.

The color and orientation sections are selectively enabled for icon styles that support them.  Currently color is supported for all the circle and arrow icons, and rotation is supported for arrows and the wildland fire line breaks.  Click on the color swatch to bring up a color picker, just like with lines and polygons.


For icon styles that support rotation, you can set the orientation by entering a number of degrees, or by clicking on the axes overlaid with a directional arrow.


Thursday, May 29, 2014

USGS Stream and Reservoir Gauges

Building on the code already in place for Snotel, I'm pleased to announce another real-time datasource: USGS water gauges.  While it's more of a frontcountry source than a backcountry one, streamflow information can still give you a good picture of the snowmelt situation and help determine whether rivers are easily crossable.  Of course boaters use it all the time, but large rivers only make up a small portion of the network, and those gauges are better covered by sites like dreamflows.com.

that's a lot of gauges

There are 7500 stream and reservoir gauges, v. 850 snotel sites.  I haven't modified the code to be more selective about how many stations get displayed at once, so users with slower, older machines may find their browser slowing down after enabling the water gauge layer.  If this proves to be problematic, let me know - if enough people complain, I'll look into fixing it.  On my 3 year old laptop, it was a non-issue.


Much like the snotel layer, zooming in displays the current real-time value for individual gauges.  Streams show the flow in cfs (cubic feet per second), and also the water temperature in degrees F, if available.  Reservoirs show the current capacity in acft (acre feet).  When you mouse over a station, the tooltip shows the time at which it was last updated.


Click on a station to bring up a graph of the last week.  Cubic feet per second is in blue, degrees F in red, and acre feet in black - although no station will support all 3 values at once.  Mousing over the graph brings up a vertical bar and provides the time and reported values at that point.  Because station update frequency varies, there is no time range selector like with the snotel sites, at least for now.


The layer is available via the "Water Gauges" checkbox underneath the Snotel layer, or click here to try it.

Tuesday, May 13, 2014

New Fire Activity Layer

As the summer fire season approaches, I decided to take another look at integrating current fire activity with CalTopo.  There's a wealth of government supplied fire information out there, and I've long thought about integrating this into a custom source that plays well with CalTopo's other map layers.  When the MODIS layer I'd previously been using went down and stayed offline for several months, it gave me the nudge I needed.

The old MODIS layer has now been replaced by a "Recent Fire Activity" layer which pulls data from several different sources.


The first of these sources is, no surprise, MODIS detections.  The MODIS system consists of two satellite imagers (Aqua and Terra) that take daily multispectral imagery of the planet; the IR band can be used determine surface temperature and, from that, detect wildfires.  Wide swaths of imagery are taken at approximately 10:30AM and 1:30PM local time; while they don't follow timezones exactly, the East Coast is imaged 3 hours before the West Coast.

The Forest Service's Remote Sensing Applications Center processes MODIS images into wildfire hotspots and makes the locations available at http://activefiremaps.fs.fed.us/gisdata.php.  While there are other sources available that have better global coverage or a faster update time, the RSAC dataset has additional metadata I couldn't find elsewhere, like the actual observed surface temperature.

Edit: Shortly after this post, Southern California saw a bout of fire activity, unfortunately giving me an opportunity to put the RSAC data through its paces.  Due to the time lag between satellite passes and their shapefile updates, I've switched to a new NASA Source which still includes temperature observations.

Starting at a wide zoom, these detections appear as multicolored Xs and *s on the map.  I wanted to convey two different attributes, severity and recency, so I needed to vary both the color and symbology.  Government maps use a red->orange->yellow color gradient to indicate the age of MODIS detections, and I decided to follow that for consistency.  Red spots were detected in the last 12 hours, orange in the last 24 and yellow in the last 36.


The asterisks represent hotter, more likely hotspots, while the Xs represent colder, less probable spots.  Zoom in a little further and each spot is marked with its average temperature.  In busy locations this can get a little crowded:


Each MODIS pixel is at least 1km square, sometimes larger, and the surface temperature is an average across the entire pixel.  So a 122 degree spot could be small, intense hotspot or a large, smoldering fire.  As the temperature drops, the certainty that there's a wildfire there drops; based on this and presumably other factors I don't understand, the RSAC assigns a confidence number to each detection.

At high zoom levels, detections are represented as a circle with additional information.  The X and Y dimensions of the MODIS pixel are averaged to get the circle's radius, so the circle shows approximate coverage size.  The detection date - which may be later than when the hotspot actually started - is shown in Mountain Daylight Time (MDT), regardless of actual timezone.  Temperature and confidence are given on the next line, followed by the satellite that made the detection and the center that processed it (RSAC or GSFC, for the Goddard Space Flight Center).


Another data source I'm pulling in is smoke polygons from NOAA's Office of Satellite and Product Operations.  Color (gray->black) represents smoke severity, while crosshatching is used for current smoke and empty polygons show where the smoke was several hours previously.


The final source is large fire perimeters from GeoMAC.  Unlike the previous two products, which are based on satellite data, fire perimeters are manually reported by an incident's management team.  As a result, they seem slow to update and I'm on the hunt for a more reliable source.  In the meantime, I'm marking perimeters with the last date at which they were updated, in addition to the incident name, so that you know how recent/reliable the data is:


Because fire season is just ramping up, I haven't had the opportunity to test this layer as thoroughly as I'd like.  Normally I wouldn't add it to CalTopo until I'd had the chance to vet it more thoroughly, but since the MODIS layer already on the site was still having issues, it made sense to sub this in as quickly as possible.  Expect things to change, and please send me any feedback or bug reports.


Tuesday, April 29, 2014

Line Modification

Tips for creating a line - like dropping points, freehand drawing and undo - were previously covered in this blog post.  Options for modifying existing lines have slowly been growing, and I think it's time to take a detailed look at them.

All of these options are accessed by right clicking on an existing line.  Vertex dragging is also enabled when clicking the edit icon in the left bar.

the right click context menu

The first option I want to cover is "Clone As".  This allows you turn a line into a polygon, add a styled line that matches a polygon border, or simply backup an existing line before editing or resampling:
right click -> Clone As -> Line.  Done.

Vertex dragging has been around for a while but it's worth a quick look.  Right click - > Modify -> Drag Vertices.

At this point each vertex along the line or polygon gets a draggable white circle.  Midpoints between vertices also get a partially transparent circle, which you can drag to create a new vertex.  To delete a point, right click on it and choose Delete Vertex.

When you're done modifying the line, right click on it and chose Save Changes - or, if you made a mistake, Discard Changes.

Sometimes it's useful to break a line in two - say to delete a bunch of points at once, or to get around a GPS' limitation on the number of points per route.  To do this, simply right click on a line at the point where you want it split, and choose Modify -> Split Here.

The opposite of splitting is joining.  To join lines,  one of the two must have a label.  Right click on the unlabeled line and choose Modify -> Join Lines.

A dialog will come up asking what line you want to join with.  If the two lines don't touch, CalTopo will automatically pick the best way to connect them.

Drawing a freehand line creates a lot of points.  This can exceed the limits of your GPS, resulting in only getting part of a route.  It also creates jitter, since no one has perfectly steady hands.  You can work around these problems by resampling a line, reducing the total number of points.

You can shrink a line down to a fixed number of points, or to create points at a fixed interval like 500 feet.  You can also optionally add a marker at each resampled point, in order to load them as waypoints onto a GPS.

Finally, you can reverse the order of a line so that directional styles will point in the opposite direction.

Friday, April 25, 2014

Line Styles

In a move that's been a long time coming, CalTopo now supports line styles.


When creating or editing a line, there's now a style option next to color, defaulting to solid.  Click on it to choose a line style.


A number of directional and nondirectional styles are provided, but if you'd like to see something specific, let me know.


Unfortunately, due to limitations in the Google Maps API, styles are not available on polygons.  Supplying polygon styles would mean dropping all the individual symbols on the map myself, which is doable from a technical perspective - that's how I support styles in the PDF generator and in the OpenLayers offline version - but might cause performance issues for large polygons.  It might get added at some point.

So what to do when you carefully draw a route and then realize you want the arrows to point in another direction?  Or when you want to add a line on top of a polygon boundary in order to style it?  That's the subject of the next blog post: line modification.

Thursday, April 24, 2014

Custom Map Layers

In the past, I've struggled with the balance between providing a wide range of map layers and keeping the layer list relevant for the majority of users.  The approach I originally adopted was to provide a large base list and a way to customize which layers were visible on the screen.

This turned out to be a bad idea all around.  It create a lot of work for me, most people never saw the customize link, and even those who did see it had no way of knowing if the list of available layers had changed.  Despite my best intentions, this was not the right way to expand CalTopo's support for regional or statewide map layers.

The almost-invisible layer customization link

The layer customization link is gone, as are some of the more obscure, little used map layers.  Instead, you can now add any tiled or WMS map source as a custom layer, and use it with almost all of CalTopo's features, including PDF generation and KMZ exports.  Start by clicking + Add New Layer in the left bar, and then Add Custom Source:


The two map types supported are tiled sources, which use Google Maps' tile pyramid structure popular with commercial map sources, and WMS, which is generally served up by government sites running some variation of ArcGIS.  The overlay property at the bottom of the dialog determines whether the layer shows up as a checkbox like the contour and fire history layers, or shows up in the standard layer dropdown with an opacity slider.


Max zoom applies to tiled layers only; many of these sources are supplied across a limited range of zoom levels (most of CalTopo's go to 16).  As long as this is set right, CalTopo will take over and automatically blow the source tiles up so you can keep zooming past this level.

This is all fairly advanced stuff.  For casual users, there's also a dropdown that auto-fills the form fields from a predefined layer list.  Currently this only has two options - the older USFS PBS maps and CalTopo's older Alaska-specific topo layer - but over time the list will grow to include datasources that don't meet the bar for inclusion in CalTopo's default list.

Beyond local and regional layers, I expect this will also include various federal government WMS datasources.