Friday, September 14, 2012

Custom Map Layers

Taking an image and turning it into a custom map layer through georeferencing is something that was previously supported - poorly - as a SAR-only feature.  Storing and rotating the image server side took too much memory and wouldn't scale well to a broad public user base.  Now that all 3 major browsers support CSS image rotation, I've taken another crack at implementing it as a browser-only solution.

There are a couple restrictions on the type of image you can use.  First, it has to be hosted online somewhere - web server, flikr account, whatever.  CalTopo won't upload and host the image for you.  Second, it needs to be drawn to scale.  CalTopo will scale and rotate an image, but it won't do any warping.

Custom layers are shown on the left nav bar below markers and shapes.  Click New Layer to get started.

First, supply the image URL and click Set.

The image should appear on your screen, with the bottom left and upper right corners aligned to the corresponding corners of the map viewer.  You can mark the two image points, and their corresponding  real-world coordinates, by right-clicking on the map background and selecting Georeference.

Use the opacity slider on the custom layer dialog to hide the image and show the underlying map.  Once you've marked both point/coordinate pairs, you can fine tune the results by continuing to click on the map or through the dialog.  When done, click save.

Once the layer has been created, it appears in the overlay dropdown along with all the other layers.  You can't use the custom layer as a base layer.

If you're working on named map, the custom layer will be saved along with that map.  If you're just using the regular map browser, the custom layer will be added on to the URL hash string, so that you can bookmark it or send a link to other people without saving anything to CalTopo.  As an example, here's the Huddart County Park map with shaded relief and contours.   Click here to see it in person.


  1. Any way to straighten the Huddart map? I just made one like it and I'd like the map to be level. My next idea was to download PDF with extra space on all sides. convert to JPG, then straighten. Alas, I can't get the "custom" layer to be included on the PDF. Thanks so much for your work. I just found your site yesterday and am still pretty amazed at all that you've designed.

    1. The custom layer should work with the PDF generator, except for very large files so as to avoid memory issues with my server. Unfortunately in that case the error reporting isn't the best; I'll look into it and make sure I didn't introduce a bug.

      CalTopo only supports printing maps where true north is straight up, so as long the map you're georeferencing has north in a different direction, there's no way to to make it come out the way you want.