<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Jay Varner</title>
    <description>Jay Varner</description>
    <link>/</link>
    <atom:link href="/feed.xml" rel="self" type="application/rss+xml"/>
    <pubDate>Wed, 07 Nov 2018 14:57:40 -0500</pubDate>
    <lastBuildDate>Wed, 07 Nov 2018 14:57:40 -0500</lastBuildDate>
    <generator>Jekyll v3.7.4</generator>
    
      <item>
        <title>My Golden Hammer - or - A Software Engineer Walks into a Design Class</title>
        <description>&lt;p&gt;&lt;em&gt;The notion of a golden hammer, “a familiar technology or concept applied obsessively to many software problems”, was introduced into information technology literature in 1998 as an anti-pattern: a programming practice to be avoided.&lt;/em&gt;&lt;sup id=&quot;fnref:yup&quot;&gt;&lt;a href=&quot;#fn:yup&quot; class=&quot;footnote&quot;&gt;1&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;

&lt;p&gt;For the past few weeks, I have been building a prototype of an app for my interaction design class. I have been laying out the screens in &lt;a href=&quot;https://www.switchtosketchapp.com/&quot;&gt;Sketch&lt;/a&gt;. This is not new to me. I often use Sketch to, well, sketch out ideas before writing code. I hit a frustrating snag when I went to convert the sketches into an interactive prototype using &lt;a href=&quot;https://proto.io/&quot;&gt;Proto.io&lt;/a&gt;. For the record, Proto.io was not the problem. It is a very compelling and powerful tool. I hope to learn a better workflow.&lt;/p&gt;

&lt;p&gt;I abandoned Proto.io for my three headed golden hammer – JavaScript, HTML, and CSS. I’m not going to say it saved me time, but it did make the exercise more comfortable. Using my day-to-day workflow, I was able to take my Sketch work and quickly build a functional version of the app.&lt;/p&gt;

&lt;p&gt;I learned an important thing. I should &lt;strong&gt;never&lt;/strong&gt; prototype with real code. It was kind of fun to not care and violate basic best practices in the interest of time. I cranked it out with the attitude of “this is a prototype…it’s not like this is ever going into production.”&lt;/p&gt;

&lt;p&gt;In the real world, it would be so easy to say…&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Hey, I spent a lot of time building this prototype. It does “work.” Let’s just get started with this. We’ll fix it before it goes to production.”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;We all know it will not get fixed before going to production.&lt;/p&gt;

&lt;div class=&quot;footnotes&quot;&gt;
  &lt;ol&gt;
    &lt;li id=&quot;fn:yup&quot;&gt;
      &lt;p&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/Law_of_the_instrument#Computer_programming&quot;&gt;https://en.wikipedia.org/wiki/Law_of_the_instrument#Computer_programming&lt;/a&gt; &lt;a href=&quot;#fnref:yup&quot; class=&quot;reversefootnote&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
  &lt;/ol&gt;
&lt;/div&gt;
</description>
        <pubDate>Wed, 16 Aug 2017 09:00:00 -0400</pubDate>
        <link>/2017/08/16/my-golden-hammer</link>
        <guid isPermaLink="true">/2017/08/16/my-golden-hammer</guid>
        
        <category>school</category>
        
        
      </item>
    
      <item>
        <title>An Overview of Overviews</title>
        <description>&lt;p&gt;In our previous post, &lt;a href=&quot;/2016/06/13/bringing-your-maps-into-focus&quot;&gt;&lt;em&gt;Bringing Your Maps into Focus&lt;/em&gt;&lt;/a&gt;, we covered a two-step process using &lt;a href=&quot;http://gdal.org&quot;&gt;GDAL&lt;/a&gt;. There is a lot going on in the second step, internal tiling and overviews. These processes are hard to research and understand what’s really going on.&lt;/p&gt;

&lt;p&gt;We’re going to walk through what is happening using two command line tools; &lt;a href=&quot;https://en.wikipedia.org/wiki/ExifTool&quot;&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;exiftool&lt;/code&gt;&lt;/a&gt; to inspect the GeoTIFF’s internal metadata and GDAL’s &lt;a href=&quot;http://www.gdal.org/gdalsrsinfo.html&quot;&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;gdalinfo&lt;/code&gt;&lt;/a&gt;. Installing both is not really a pain. For Mac there are &lt;a href=&quot;http://brewformulas.org/&quot;&gt;Homebrew formulas&lt;/a&gt; for each. Most Linux distros have packages, and there are &lt;a href=&quot;http://owl.phy.queensu.ca/~phil/exiftool/&quot;&gt;downloads&lt;/a&gt; for &lt;a href=&quot;https://trac.osgeo.org/osgeo4w/&quot;&gt;Windows&lt;/a&gt; .&lt;/p&gt;

&lt;p&gt;Let’s look at the exiftool output for a non-georeferenced TIFF. It’s really not that interesting. We’re providing here as a starting point.&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;exiftool Atlanta_1928_Sheet45.tif
ExifTool Version Number         : 10.02
File Name                       : Atlanta_1928_Sheet45.tif
Directory                       : &lt;span class=&quot;nb&quot;&gt;.&lt;/span&gt;
File Size                       : 90 MB
File Modification Date/Time     : 2016:05:24 20:59:18-04:00
File Access Date/Time           : 2016:05:24 20:58:53-04:00
File Inode Change Date/Time     : 2016:05:24 20:59:40-04:00
File Permissions                : rw-r--r--
File Type                       : TIFF
File Type Extension             : tif
MIME Type                       : image/tiff
Exif Byte Order                 : Little-endian &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;Intel, II&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
Subfile Type                    : Full-resolution Image
Image Width                     : 5347
Image Height                    : 6348
Bits Per Sample                 : 8 8 8
Compression                     : LZW
Photometric Interpretation      : RGB
Image Description               :
Strip Offsets                   : &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;Binary data 3521 bytes, use &lt;span class=&quot;nt&quot;&gt;-b&lt;/span&gt; option to extract&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
Orientation                     : Horizontal &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;normal&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
Samples Per Pixel               : 3
Rows Per Strip                  : 16
Strip Byte Counts               : &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;Binary data 2778 bytes, use &lt;span class=&quot;nt&quot;&gt;-b&lt;/span&gt; option to extract&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
X Resolution                    : 300
Y Resolution                    : 300
Planar Configuration            : Chunky
Resolution Unit                 : inches
Software                        : Adobe Photoshop CS5.1 Windows
Modify Date                     : 2012:02:08 17:22:10
Predictor                       : Horizontal differencing
XMP Toolkit                     : Adobe XMP Core 5.0-c061 64.140949, 2010/12/07-10:57:01
Create Date                     : 2010:06:15 15:11:38-04:00
Metadata Date                   : 2012:02:08 17:22:10-05:00
Creator Tool                    : Adobe Photoshop CS3 Windows
Format                          : image/tiff
Description                     :
Color Mode                      : RGB
Instance ID                     : xmp.iid:DDF74EAAA152E111A8D59B79B1F6E115
Document ID                     : uuid:32FACA12C678DF11BE5CBF86910F7516
Original Document ID            : uuid:32FACA12C678DF11BE5CBF86910F7516
History Action                  : saved
History Instance ID             : xmp.iid:DDF74EAAA152E111A8D59B79B1F6E115
History When                    : 2012:02:08 17:22:10-05:00
History Software Agent          : Adobe Photoshop CS5.1 Windows
History Changed                 : /
Marked                          : False
Current IPTC Digest             : 54de4a51baba1e48176bd21acf562b86
Coded Character Set             : UTF8
Application Record Version      : 0
Caption-Abstract                :
IPTC Digest                     : 54de4a51baba1e48176bd21acf562b86
Displayed Units X               : inches
Displayed Units Y               : inches
Global Angle                    : 30
Global Altitude                 : 30
Copyright Flag                  : False
Photoshop Thumbnail             : &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;Binary data 5790 bytes, use &lt;span class=&quot;nt&quot;&gt;-b&lt;/span&gt; option to extract&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
Color Space                     : Uncalibrated
Exif Image Width                : 5347
Exif Image Height               : 6348
Image Size                      : 5347x6348
Megapixels                      : 33.9
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;If we run it on a GeoTIFF, we see some extra stuff:&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;exiftool Atlanta_1928_Sheet45.tif
…
Rows Per Strip                  : 64
…
Geo Tiff Version                : 1.1.0
GT Model Type                   : Projected
GT Raster Type                  : Pixel Is Area
GT Citation                     : NAD83 Georgia State Planes, West Zone, US Foot
Geographic Type                 : NAD83
Geog Citation                   : NAD83
Geog Geodetic Datum             : North American Datum 1983
Geog Angular Units              : Angular Degree
Geog Ellipsoid                  : GRS 1980
Geog Semi Major Axis            : 6378137
Geog Inv Flattening             : 298.257222100911
Projected CS Type               : Unknown &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;2240&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
Projection                      : User Defined
Proj Coord Trans                : Transverse Mercator
Proj Linear Units               : Linear Foot US Survey
Proj Nat Origin Long            : &lt;span class=&quot;nt&quot;&gt;-84&lt;/span&gt;.1666666666667
Proj Nat Origin Lat             : 30
Proj False Easting              : 699999.999999999
Proj False Northing             : 0
Proj Scale At Nat Origin        : 0.9999
Image Size                      : 5364x6328
Megapixels                      : 33.9
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;And let’s look at what &lt;code class=&quot;highlighter-rouge&quot;&gt;gdalinfo&lt;/code&gt; has to say:&lt;/p&gt;

&lt;div class=&quot;language-text highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ gdalinfo Atlanta_1928_Sheet45.tif
Driver: GTiff/GeoTIFF
Files: Atlanta_1928_Sheet45.tif
Size is 5364, 6328
Coordinate System is:
PROJCS[&quot;NAD83 / Georgia West (ftUS)&quot;,
    GEOGCS[&quot;NAD83&quot;,
        DATUM[&quot;North_American_Datum_1983&quot;,
            SPHEROID[&quot;GRS 1980&quot;,6378137,298.2572221009113,
                AUTHORITY[&quot;EPSG&quot;,&quot;7019&quot;]],
            AUTHORITY[&quot;EPSG&quot;,&quot;6269&quot;]],
        PRIMEM[&quot;Greenwich&quot;,0],
        UNIT[&quot;degree&quot;,0.0174532925199433],
        AUTHORITY[&quot;EPSG&quot;,&quot;4269&quot;]],
    PROJECTION[&quot;Transverse_Mercator&quot;],
    PARAMETER[&quot;latitude_of_origin&quot;,30],
    PARAMETER[&quot;central_meridian&quot;,-84.1666666666667],
    PARAMETER[&quot;scale_factor&quot;,0.9999],
    PARAMETER[&quot;false_easting&quot;,699999.9999999991],
    PARAMETER[&quot;false_northing&quot;,0],
    UNIT[&quot;US survey foot&quot;,0.3048006096012192,
        AUTHORITY[&quot;EPSG&quot;,&quot;9003&quot;]],
    AUTHORITY[&quot;EPSG&quot;,&quot;2240&quot;]]
Origin = (2232544.649310299195349,1362031.125677362782881)
Pixel Size = (0.668734999999993,-0.668735000000005)
Metadata:
  AREA_OR_POINT=Area
Image Structure Metadata:
  INTERLEAVE=BAND
Corner Coordinates:
Upper Left  ( 2232544.649, 1362031.126) ( 79d 8' 0.51&quot;W, 33d38'30.07&quot;N)
Lower Left  ( 2232544.649, 1357799.371) ( 79d 8' 2.94&quot;W, 33d37'48.36&quot;N)
Upper Right ( 2236131.744, 1362031.126) ( 79d 7'18.24&quot;W, 33d38'28.34&quot;N)
Lower Right ( 2236131.744, 1357799.371) ( 79d 7'20.68&quot;W, 33d37'46.64&quot;N)
Center      ( 2234338.197, 1359915.248) ( 79d 7'40.59&quot;W, 33d38' 8.35&quot;N)
Band 1 Block=5364x64 Type=Byte, ColorInterp=Red
Band 2 Block=5364x64 Type=Byte, ColorInterp=Green
Band 3 Block=5364x64 Type=Byte, ColorInterp=Blue
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;strips&quot;&gt;Strips&lt;/h3&gt;
&lt;blockquote&gt;
  &lt;p&gt;TIFF image data can be organized into strips for faster random access and efficient I/O buffering.&lt;sup id=&quot;fnref:strips&quot;&gt;&lt;a href=&quot;#fn:strips&quot; class=&quot;footnote&quot;&gt;1&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Looking at the “Rows Per Strip” tag in the &lt;code class=&quot;highlighter-rouge&quot;&gt;exiftool&lt;/code&gt; output, we can see that, prior to georeferencing, our TIFF had strips that were 16 rows/pixels tall. Our GeoTIFF’s strips are 64 rows/pixels tall. &lt;code class=&quot;highlighter-rouge&quot;&gt;gdalinfo&lt;/code&gt; confirms that:&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;Band 1 &lt;span class=&quot;nv&quot;&gt;Block&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;5364x64 &lt;span class=&quot;nv&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;Byte, &lt;span class=&quot;nv&quot;&gt;ColorInterp&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;Red
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;This will help the speed that our maps are loaded. Rather than loading all 33,943,392 pixels at once, the image will be rendered in 343,296 pixel strips. But what if the only part of the map that is requested is one corner? The client will get the whole strip and a lot of unwanted data. The main point of using WMS and slippy maps is only serving the tile(s) that are requested.&lt;/p&gt;

&lt;h3 id=&quot;tiles&quot;&gt;Tiles&lt;/h3&gt;

&lt;blockquote&gt;
  &lt;p&gt;For low-resolution to medium-resolution images, the standard TIFF method of breaking the image into strips is adequate. However high-resolution images can be accessed more efficiently—and compression tends to work better—if the image is broken into roughly square tiles instead of horizontally wide, but vertically narrow, strips.&lt;sup id=&quot;fnref:tiles&quot;&gt;&lt;a href=&quot;#fn:tiles&quot; class=&quot;footnote&quot;&gt;2&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Above, we see with &lt;code class=&quot;highlighter-rouge&quot;&gt;gdalinfo&lt;/code&gt; that each band’s block spans the whole image and in the &lt;code class=&quot;highlighter-rouge&quot;&gt;exiftool&lt;/code&gt; output, our GeoTIFF has no internal tiling. The standard tile size used by OpenStreetMap, Google Maps, etc. is 256 x 256. In the previous post, we ran &lt;a href=&quot;http://www.gdal.org/gdalwarp.html&quot;&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;gdalwarp&lt;/code&gt;&lt;/a&gt; on our GeoTIFF we generated tiles that are 256 x 256 &lt;code class=&quot;highlighter-rouge&quot;&gt;-co 'TILED=YES' -co 'BLOCKXSIZE=256'&lt;/code&gt;&lt;sup id=&quot;fnref:tiffdriver&quot;&gt;&lt;a href=&quot;#fn:tiffdriver&quot; class=&quot;footnote&quot;&gt;3&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;

&lt;p&gt;The full command from our previous post:&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;gdalwarp &lt;span class=&quot;nt&quot;&gt;-s_srs&lt;/span&gt; &amp;lt;&lt;span class=&quot;nb&quot;&gt;source &lt;/span&gt;ESPG&amp;gt; &lt;span class=&quot;nt&quot;&gt;-t_srs&lt;/span&gt; &amp;lt;target EPSG&amp;gt; &lt;span class=&quot;nt&quot;&gt;-r&lt;/span&gt; average &lt;span class=&quot;nt&quot;&gt;-co&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'TILED=YES/NO'&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-co&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'BLOCKXSIZE=XXX'&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-co&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'BLOCKYSIZE=XXX'&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-co&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'COMPRESS=JPEG'&lt;/span&gt; &amp;lt;/path/to/source/geo.tif&amp;gt; &amp;lt;/path/to/new/geo.tif&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Running &lt;code class=&quot;highlighter-rouge&quot;&gt;exiftool&lt;/code&gt; on the warped GeoTIFF shows:&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;Tile Width    : 256
Tile Length   : 256
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;And &lt;code class=&quot;highlighter-rouge&quot;&gt;gdalinfo&lt;/code&gt; shows:&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;Band 1 &lt;span class=&quot;nv&quot;&gt;Block&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;256x256 &lt;span class=&quot;nv&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;Byte, &lt;span class=&quot;nv&quot;&gt;ColorInterp&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;Red
Band 2 &lt;span class=&quot;nv&quot;&gt;Block&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;256x256 &lt;span class=&quot;nv&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;Byte, &lt;span class=&quot;nv&quot;&gt;ColorInterp&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;Green
Band 3 &lt;span class=&quot;nv&quot;&gt;Block&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;256x256 &lt;span class=&quot;nv&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;Byte, &lt;span class=&quot;nv&quot;&gt;ColorInterp&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;Blue
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;overviews-aka-subfiles&quot;&gt;Overviews aka Subfiles&lt;/h3&gt;
&lt;p&gt;A TIFF file can contain multiple subfiles&lt;sup id=&quot;fnref:subfile&quot;&gt;&lt;a href=&quot;#fn:subfile&quot; class=&quot;footnote&quot;&gt;4&lt;/a&gt;&lt;/sup&gt;. Using &lt;code class=&quot;highlighter-rouge&quot;&gt;gdaladdo&lt;/code&gt; we can create multiple subfiles of our map at different resolutions. GDAL calls subfiles &lt;a href=&quot;http://www.gdal.org/frmt_gtiff.html#overviews&quot;&gt;overviews&lt;/a&gt;. Let’s look back at our example:&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;gdaladdo &lt;span class=&quot;nt&quot;&gt;--config&lt;/span&gt; GDAL_TIFF_OVR_BLOCKSIZE 256 &lt;span class=&quot;nt&quot;&gt;-r&lt;/span&gt; average processed/atlanta_1928_sheet45.tif 2 4 8 16 32
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;gdaladdo&lt;/code&gt; tiles the map again and defaults to 128. You can set &lt;code class=&quot;highlighter-rouge&quot;&gt;GDAL_TIFF_OVR_BLOCKSIZE&lt;/code&gt; as an &lt;a href=&quot;https://en.wikipedia.org/wiki/Environment_variable&quot;&gt;environment variable&lt;/a&gt;, but here we’re just passing it in as an option. The &lt;code class=&quot;highlighter-rouge&quot;&gt;-r&lt;/code&gt; is choosing the resampling algorithm for the overviews. We played around with a few and landed on &lt;code class=&quot;highlighter-rouge&quot;&gt;average&lt;/code&gt;. You might want to try others.&lt;/p&gt;

&lt;p&gt;Finally, that list of numbers at the end is the amount the image will be reduced: 2 will reduce by half, 4 will reduce by a quarter, and so on.&lt;/p&gt;

&lt;p&gt;Let’s look at what happened by looking at the &lt;code class=&quot;highlighter-rouge&quot;&gt;gdalinfo&lt;/code&gt; output:&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;Band 1 &lt;span class=&quot;nv&quot;&gt;Block&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;256x256 &lt;span class=&quot;nv&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;Byte, &lt;span class=&quot;nv&quot;&gt;ColorInterp&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;Red
  Overviews: 2673x3186, 1337x1593, 669x797, 335x399, 168x200
Band 2 &lt;span class=&quot;nv&quot;&gt;Block&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;256x256 &lt;span class=&quot;nv&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;Byte, &lt;span class=&quot;nv&quot;&gt;ColorInterp&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;Green
  Overviews: 2673x3186, 1337x1593, 669x797, 335x399, 168x200
Band 3 &lt;span class=&quot;nv&quot;&gt;Block&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;256x256 &lt;span class=&quot;nv&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;Byte, &lt;span class=&quot;nv&quot;&gt;ColorInterp&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;Blue
  Overviews: 2673x3186, 1337x1593, 669x797, 335x399, 168x200
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Just for fun and to prove those low resolution versions really do exist, let’s use a bunch of exiftool options to inspect them (thanks Kyle Fenton!) The output is rather verbose, so we’ll really just show the important stuff.&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;exiftool &lt;span class=&quot;nt&quot;&gt;-s&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-a&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-e&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-G5&lt;/span&gt; atlanta_1928_sheet45.tif.tif
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;ExifTool]      ExifToolVersion                 : 10.02
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;System]        FileName                        : atlanta_1928_sheet45.tif
…
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;TIFF-IFD0]     ImageWidth                      : 5345
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;TIFF-IFD0]     ImageHeight                     : 6371
…
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;TIFF-IFD2]     ImageWidth                      : 1337
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;TIFF-IFD2]     ImageHeight                     : 1593
…
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;TIFF-IFD4]     ImageWidth                      : 335
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;TIFF-IFD4]     ImageHeight                     : 399
…
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;TIFF-IFD5]     SubfileType                     : Reduced-resolution image
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;TIFF-IFD5]     ImageWidth                      : 168
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;TIFF-IFD5]     ImageHeight                     : 200
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;TIFF-IFD5]     BitsPerSample                   : 8 8 8
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;TIFF-IFD5]     Compression                     : Uncompressed
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;TIFF-IFD5]     PhotometricInterpretation       : RGB
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;TIFF-IFD5]     SamplesPerPixel                 : 3
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;TIFF-IFD5]     PlanarConfiguration             : Chunky
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;TIFF-IFD5]     TileWidth                       : 256
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;TIFF-IFD5]     TileLength                      : 256
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;TIFF-IFD5]     TileOffsets                     : 142744474
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;TIFF-IFD5]     TileByteCounts                  : 196608
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;TIFF-IFD5]     SampleFormat                    : Unsigned&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; Unsigned&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; Unsigned
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Our process and understanding of these concepts have developed and evolved though collaboration, research, and a lot of trial and error. We would love any feedback and suggestions on how the process could be improved.&lt;/p&gt;
&lt;div class=&quot;footnotes&quot;&gt;
  &lt;ol&gt;
    &lt;li id=&quot;fn:strips&quot;&gt;
      &lt;p&gt;&lt;a href=&quot;http://www.awaresystems.be/imaging/tiff/tifftags/rowsperstrip.html&quot;&gt;http://www.awaresystems.be/imaging/tiff/tifftags/rowsperstrip.html&lt;/a&gt; &lt;a href=&quot;#fnref:strips&quot; class=&quot;reversefootnote&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:tiles&quot;&gt;
      &lt;p&gt;See page 66 of the &lt;a href=&quot;http://partners.adobe.com/public/developer/en/tiff/TIFF6.pdf&quot;&gt;TIFF spec document&lt;/a&gt; &lt;a href=&quot;#fnref:tiles&quot; class=&quot;reversefootnote&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:tiffdriver&quot;&gt;
      &lt;p&gt;The &lt;code class=&quot;highlighter-rouge&quot;&gt;-co&lt;/code&gt; stand for “creation option” and these are specific to the file format. All the options for GeoTIFFs, and all sorts of good info, can be found at &lt;a href=&quot;http://www.gdal.org/frmt_gtiff.html&quot;&gt;http://www.gdal.org/frmt_gtiff.html&lt;/a&gt; &lt;a href=&quot;#fnref:tiffdriver&quot; class=&quot;reversefootnote&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:subfile&quot;&gt;
      &lt;p&gt;See page 16 of the &lt;a href=&quot;http://partners.adobe.com/public/developer/en/tiff/TIFF6.pdf&quot;&gt;TIFF spec document&lt;/a&gt;. &lt;a href=&quot;#fnref:subfile&quot; class=&quot;reversefootnote&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
  &lt;/ol&gt;
&lt;/div&gt;
</description>
        <pubDate>Mon, 13 Jun 2016 09:30:00 -0400</pubDate>
        <link>/2016/06/13/an-overview-of-overviews</link>
        <guid isPermaLink="true">/2016/06/13/an-overview-of-overviews</guid>
        
        <category>gdal</category>
        
        <category>geospatial</category>
        
        <category>gis</category>
        
        <category>wms</category>
        
        <category>webmapping</category>
        
        <category>geotiff</category>
        
        
      </item>
    
      <item>
        <title>Bringing Your Maps into Focus</title>
        <description>&lt;p&gt;Here at Emory, we have some pretty cool old &lt;a href=&quot;http://www.digitalgallery.emory.edu/luna/servlet/view/all/where/Atlanta?sort=title%2Cpage_no_%2Ccity%2Cdate&quot;&gt;maps of Atlanta&lt;/a&gt; that we wanted to share in a more interactive way. But when we tried, the maps looked like this:&lt;/p&gt;

&lt;p data-height=&quot;500&quot; data-theme-id=&quot;0&quot; data-slug-hash=&quot;eExoyO&quot; data-default-tab=&quot;result&quot; data-user=&quot;jayvarner&quot; data-embed-version=&quot;2&quot; data-pen-title=&quot;eExoyO&quot; class=&quot;codepen&quot;&gt;See the Pen &lt;a href=&quot;https://codepen.io/jayvarner/pen/eExoyO/&quot;&gt;eExoyO&lt;/a&gt; by Jay Varner (&lt;a href=&quot;https://codepen.io/jayvarner&quot;&gt;@jayvarner&lt;/a&gt;) on &lt;a href=&quot;https://codepen.io&quot;&gt;CodePen&lt;/a&gt;.&lt;/p&gt;
&lt;script async=&quot;&quot; src=&quot;https://production-assets.codepen.io/assets/embed/ei.js&quot;&gt;&lt;/script&gt;

&lt;p&gt;After a good bit of research, lots of trial and error, and working with our colleagues &lt;a href=&quot;http://library.gsu.edu/profile/eric-willoughby/&quot;&gt;Eric Willoughby&lt;/a&gt; at Georgia State University and &lt;a href=&quot;https://twitter.com/gislibrarian&quot;&gt;Amanda Henley&lt;/a&gt; at the University of North Carolina, we came up with a process that gave us this:&lt;/p&gt;

&lt;p data-height=&quot;500&quot; data-theme-id=&quot;0&quot; data-slug-hash=&quot;brzJLx&quot; data-default-tab=&quot;result&quot; data-user=&quot;jayvarner&quot; data-embed-version=&quot;2&quot; data-pen-title=&quot;brzJLx&quot; class=&quot;codepen&quot;&gt;See the Pen &lt;a href=&quot;https://codepen.io/jayvarner/pen/brzJLx/&quot;&gt;brzJLx&lt;/a&gt; by Jay Varner (&lt;a href=&quot;https://codepen.io/jayvarner&quot;&gt;@jayvarner&lt;/a&gt;) on &lt;a href=&quot;https://codepen.io&quot;&gt;CodePen&lt;/a&gt;.&lt;/p&gt;
&lt;script async=&quot;&quot; src=&quot;https://production-assets.codepen.io/assets/embed/ei.js&quot;&gt;&lt;/script&gt;

&lt;h2 id=&quot;what-we-did&quot;&gt;What We Did&lt;/h2&gt;
&lt;p&gt;We &lt;a href=&quot;https://en.wikipedia.org/wiki/Georeference&quot;&gt;georeferenced&lt;/a&gt; our map in the appropriate &lt;a href=&quot;https://en.wikipedia.org/wiki/Coordinate_system&quot;&gt;coordinate system&lt;/a&gt; for the map’s area. In our case &lt;a href=&quot;http://spatialreference.org/ref/epsg/2240/&quot;&gt;EPSG:2240&lt;/a&gt;. We’ll refer to specific coordinate systems with their &lt;a href=&quot;https://en.wikipedia.org/wiki/International_Association_of_Oil_%26_Gas_Producers#European_Petroleum_Survey_Group&quot;&gt;EPSG code&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Next we took the resulting &lt;a href=&quot;https://en.wikipedia.org/wiki/GeoTIFF&quot;&gt;GeoTIFF&lt;/a&gt; and uploaded it to our &lt;a href=&quot;http://geoserver.org&quot;&gt;GeoServer&lt;/a&gt; so the map could be shared via &lt;a href=&quot;https://en.wikipedia.org/wiki/Web_Map_Service&quot;&gt;WMS&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Finally, like the examples above, we used &lt;a href=&quot;http://leafletjs.com/&quot;&gt;Leaflet&lt;/a&gt; to display the maps in the browser overlaid on a modern street map.&lt;/p&gt;

&lt;h2 id=&quot;what-we-did-wrong&quot;&gt;What We Did &lt;em&gt;Wrong&lt;/em&gt;&lt;/h2&gt;
&lt;p&gt;Our first problem was that the GeoTIFF is a high resolution image. In the first example on this page, we were squeezing a 5,931 x 5,779 pixel image (the full resolution) into a 326 x 276 pixel box (for the zoom level shown above). There’s just too much data to display clearly. Notice that if you zoom all the way in to our original example, the map looks great.&lt;/p&gt;

&lt;p data-height=&quot;500&quot; data-theme-id=&quot;0&quot; data-slug-hash=&quot;OjdGvE&quot; data-default-tab=&quot;result&quot; data-user=&quot;jayvarner&quot; data-embed-version=&quot;2&quot; data-pen-title=&quot;OjdGvE&quot; class=&quot;codepen&quot;&gt;See the Pen &lt;a href=&quot;https://codepen.io/jayvarner/pen/OjdGvE/&quot;&gt;OjdGvE&lt;/a&gt; by Jay Varner (&lt;a href=&quot;https://codepen.io/jayvarner&quot;&gt;@jayvarner&lt;/a&gt;) on &lt;a href=&quot;https://codepen.io&quot;&gt;CodePen&lt;/a&gt;.&lt;/p&gt;
&lt;script async=&quot;&quot; src=&quot;https://production-assets.codepen.io/assets/embed/ei.js&quot;&gt;&lt;/script&gt;

&lt;p&gt;Our other problem was that we used a coordinate system that is inappropriate for web display. Tiled base maps that are provided by organizations like &lt;a href=&quot;http://www.openstreetmap.org/about&quot;&gt;OpenSteetMap&lt;/a&gt; are based on &lt;a href=&quot;http://spatialreference.org/ref/sr-org/7483/&quot;&gt;EPSG:3857&lt;/a&gt;, aka &lt;a href=&quot;https://en.wikipedia.org/wiki/Web_Mercator#EPSG:3857&quot;&gt;WGS 84  Web Mercator&lt;/a&gt;.&lt;/p&gt;

&lt;h2 id=&quot;gdal-can-solve-those-problems&quot;&gt;GDAL Can Solve those Problems&lt;/h2&gt;
&lt;p&gt;“&lt;a href=&quot;http://www.gdal.org/&quot;&gt;GDAL&lt;/a&gt; is a translator library for raster and vector geospatial data formats…” This is our three step process.&lt;/p&gt;

&lt;h3 id=&quot;gdalwarp&quot;&gt;gdalwarp&lt;/h3&gt;
&lt;p&gt;We use &lt;code class=&quot;highlighter-rouge&quot;&gt;gdalwarp&lt;/code&gt; to reproject, resample, add internal tiling, and compress&lt;sup id=&quot;fnref:fewer&quot;&gt;&lt;a href=&quot;#fn:fewer&quot; class=&quot;footnote&quot;&gt;1&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;

&lt;h4 id=&quot;reproject&quot;&gt;Reproject&lt;/h4&gt;
&lt;p&gt;When you georeference a scanned map, you select a &lt;a href=&quot;https://en.wikipedia.org/wiki/Map_projection&quot;&gt;projection&lt;/a&gt;. For most GIS needs, you will want to use the projection appropriate for the chunk of Earth your map covers. However, for displaying maps on the web, you want to use EPSG:3857&lt;sup id=&quot;fnref:whcihcode&quot;&gt;&lt;a href=&quot;#fn:whcihcode&quot; class=&quot;footnote&quot;&gt;2&lt;/a&gt;&lt;/sup&gt;.&lt;/p&gt;

&lt;h4 id=&quot;resample&quot;&gt;Resample&lt;/h4&gt;
&lt;p&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;gdalwarp&lt;/code&gt; offers various algorithms&lt;sup id=&quot;fnref:man&quot;&gt;&lt;a href=&quot;#fn:man&quot; class=&quot;footnote&quot;&gt;3&lt;/a&gt;&lt;/sup&gt; for &lt;a href=&quot;https://en.wikipedia.org/wiki/Image_scaling&quot;&gt;resampling&lt;/a&gt;. We suggest you try a few and see what works best. We’ve had good results using &lt;code class=&quot;highlighter-rouge&quot;&gt;average&lt;/code&gt;, but many folks will suggest &lt;code class=&quot;highlighter-rouge&quot;&gt;near&lt;/code&gt;.&lt;/p&gt;

&lt;h4 id=&quot;tiling&quot;&gt;Tiling&lt;/h4&gt;
&lt;p&gt;GeoTIFFs are organized in 1 pixel strips by default. OpenStreetMap tiles are 256x256. We match OpenStreetMap by adding internal tiles. We’ll go deeper into tiling in our follow up &lt;a href=&quot;/2016/06/13/an-overview-of-overviews&quot;&gt;post&lt;/a&gt;.&lt;/p&gt;

&lt;h4 id=&quot;compress&quot;&gt;Compress&lt;/h4&gt;
&lt;p&gt;GeoTIFFs can be huge and it’s not very nice to make users load large files when they don’t have to. GDAL can also compress our GeoTIFFs. There are many compression algorithms, but we’re pretty happy with the results we’re getting with &lt;code class=&quot;highlighter-rouge&quot;&gt;JPEG&lt;/code&gt;.&lt;/p&gt;

&lt;h4 id=&quot;the-command&quot;&gt;The Command&lt;/h4&gt;
&lt;p&gt;Here is an example showing how to set all the options. Note the last argument is a path to a file the command will create. Your original GeoTIFF will be preserved.&lt;/p&gt;

&lt;h5 id=&quot;syntax&quot;&gt;Syntax&lt;/h5&gt;
&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;gdalwarp &lt;span class=&quot;nt&quot;&gt;-s_srs&lt;/span&gt; &amp;lt;&lt;span class=&quot;nb&quot;&gt;source &lt;/span&gt;ESPG&amp;gt; &lt;span class=&quot;nt&quot;&gt;-t_srs&lt;/span&gt; &amp;lt;target EPSG&amp;gt; &lt;span class=&quot;nt&quot;&gt;-r&lt;/span&gt; average &lt;span class=&quot;nt&quot;&gt;-co&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'TILED=YES/NO'&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-co&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'BLOCKXSIZE=XXX'&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-co&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'BLOCKYSIZE=XXX'&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-co&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'COMPRESS=ABC'&lt;/span&gt; &amp;lt;/path/to/source/geo.tif&amp;gt; &amp;lt;/path/to/new/geo.tif&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h5 id=&quot;example&quot;&gt;Example&lt;/h5&gt;
&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;gdalwarp &lt;span class=&quot;nt&quot;&gt;-s_srs&lt;/span&gt; EPSG:2240 &lt;span class=&quot;nt&quot;&gt;-t_srs&lt;/span&gt; EPSG:3857 &lt;span class=&quot;nt&quot;&gt;-r&lt;/span&gt; average &lt;span class=&quot;nt&quot;&gt;-co&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'TILED=YES'&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-co&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'BLOCKXSIZE=256'&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-co&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'BLOCKYSIZE=256'&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-co&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'COMPRESS=JPEG'&lt;/span&gt; atlanta_1928_sheet45.tif processed/atlanta_1928_sheet45.tif
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;&lt;em&gt;NOTE&lt;/em&gt;: We are creating a new copy of the GeoTIFF in a directory called “processed”. You can save it where ever you like.&lt;/p&gt;

&lt;p&gt;Now you have a new GeoTIFF projected in Web Mercator and preserved your original.&lt;/p&gt;

&lt;h3 id=&quot;add-overviews&quot;&gt;Add Overviews&lt;/h3&gt;
&lt;p&gt;We discuss overviews in greater depth in our follow-up &lt;a href=&quot;/2016/06/13/an-overview-of-overviews&quot;&gt;post&lt;/a&gt;. Remember when we said the main reason the map looked so bad was because there was just too much data? Well, overviews fix that. What happens here is we create internal versions of our image that are smaller and lower resolution.&lt;/p&gt;

&lt;p&gt;We also have to tell it to keep our blocks, or internal tiles, at 256, the default is 128. You can set &lt;code class=&quot;highlighter-rouge&quot;&gt;GDAL_TIFF_OVR_BLOCKSIZE&lt;/code&gt; as an &lt;a href=&quot;https://help.ubuntu.com/community/EnvironmentVariables&quot;&gt;environment variable&lt;/a&gt;, or just override the default with the &lt;code class=&quot;highlighter-rouge&quot;&gt;--config&lt;/code&gt; option.&lt;/p&gt;

&lt;h5 id=&quot;syntax-1&quot;&gt;Syntax&lt;/h5&gt;
&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;gdaladdo &lt;span class=&quot;nt&quot;&gt;--config&lt;/span&gt; GDAL_TIFF_OVR_BLOCKSIZE XXX &lt;span class=&quot;nt&quot;&gt;-r&lt;/span&gt; average &amp;lt;/path/to/new.tif&amp;gt; levels &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;list of numbers&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h5 id=&quot;example-1&quot;&gt;Example&lt;/h5&gt;
&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;gdaladdo &lt;span class=&quot;nt&quot;&gt;--config&lt;/span&gt; GDAL_TIFF_OVR_BLOCKSIZE 256 &lt;span class=&quot;nt&quot;&gt;-r&lt;/span&gt; average processed/atlanta_1928_sheet45.tif 2 4 8 16 32
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;automation&quot;&gt;Automation&lt;/h2&gt;
&lt;p&gt;Obviously if you have more than two maps to process, running these commands on each will get real old real fast. Fortunately, since GDAL is a command line tool, we can automate the whole process. There are wrappers for GDAL in many languages: &lt;a href=&quot;https://pcjericks.github.io/py-gdalogr-cookbook/&quot;&gt;Python&lt;/a&gt;, &lt;a href=&quot;https://github.com/geonef/php5-gdal&quot;&gt;PHP&lt;/a&gt;, &lt;a href=&quot;https://gdalnet.codeplex.com/&quot;&gt;.Net&lt;/a&gt;, &lt;a href=&quot;https://github.com/zhm/gdal-ruby&quot;&gt;Ruby&lt;/a&gt; (though the Ruby gem is no longer maintained and not updated for GDAL 2), etc.&lt;/p&gt;

&lt;p&gt;We have &lt;a href=&quot;https://github.com/zhm/gdal-ruby&quot;&gt;automated our process&lt;/a&gt;. It’s nice to just run a script and go enjoy some coffee while the computer does all the work.&lt;/p&gt;

&lt;h2 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;This has been an evolving process. We found ways to improve the process every time we prepared for a workshop, conference talk, or writing this post. We would love to hear any feedback or suggestions.&lt;/p&gt;
&lt;div class=&quot;footnotes&quot;&gt;
  &lt;ol&gt;
    &lt;li id=&quot;fn:fewer&quot;&gt;
      &lt;p&gt;In previous talks and workshops, we presented a three-step process where we did the tiling and compressed the image using &lt;code class=&quot;highlighter-rouge&quot;&gt;gdal_translate&lt;/code&gt;. While writing this post we realized a way to combine these processes with &lt;code class=&quot;highlighter-rouge&quot;&gt;gdalwarp&lt;/code&gt;. &lt;a href=&quot;#fnref:fewer&quot; class=&quot;reversefootnote&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:whcihcode&quot;&gt;
      &lt;p&gt;There is confusion between EPSG:3857 and EPSG:4326. For displaying raster data using something like Leaflet, OpenLayers, etc. 3857 will result in a much clearer image. Here are two links that helped us understand. &lt;a href=&quot;http://gis.stackexchange.com/a/48952&quot;&gt;http://gis.stackexchange.com/a/48952&lt;/a&gt; and &lt;a href=&quot;http://www.faqoverflow.com/gis/48949.html&quot;&gt;http://www.faqoverflow.com/gis/48949.html&lt;/a&gt; &lt;a href=&quot;#fnref:whcihcode&quot; class=&quot;reversefootnote&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:man&quot;&gt;
      &lt;p&gt;You can see a list of available algorithms by running &lt;code class=&quot;highlighter-rouge&quot;&gt;man gdadalwarp&lt;/code&gt; and reading the explanation of the &lt;code class=&quot;highlighter-rouge&quot;&gt;-r&lt;/code&gt; option. &lt;code class=&quot;highlighter-rouge&quot;&gt;man&lt;/code&gt; is short for manual. Use the space bar to scroll through the text and type &lt;code class=&quot;highlighter-rouge&quot;&gt;q&lt;/code&gt; to quit the man page viewer. Or you can &lt;a href=&quot;http://www.gdal.org/gdalwarp.html&quot;&gt;read it here&lt;/a&gt;. &lt;a href=&quot;#fnref:man&quot; class=&quot;reversefootnote&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
  &lt;/ol&gt;
&lt;/div&gt;
</description>
        <pubDate>Mon, 13 Jun 2016 09:00:00 -0400</pubDate>
        <link>/2016/06/13/bringing-your-maps-into-focus</link>
        <guid isPermaLink="true">/2016/06/13/bringing-your-maps-into-focus</guid>
        
        <category>gdal</category>
        
        <category>geospatial</category>
        
        <category>gis</category>
        
        <category>wms</category>
        
        <category>webmapping</category>
        
        
      </item>
    
  </channel>
</rss>
