Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Commanding Cartography: Take Control of Faster, More Elegant Workflows from the Command Line

Joshua Stevens
October 17, 2018

Commanding Cartography: Take Control of Faster, More Elegant Workflows from the Command Line

Compelling cartography has never been easier or more abundant. We are inundated with new tools and technologies. All the while, one of the most powerful assets in the cartographer's arsenal is being overlooked: the command line. Using keystrokes to create maps might sound like a task of yesteryear, but I am here to tell you it is a wormhole to the future. Whether you design maps for national parks or newsrooms, the terminal will enable you to supercharge your workflows with speed and elegance. This talk will introduce some old tricks and new tools for designers on any deadline.

Joshua Stevens

October 17, 2018
Tweet

More Decks by Joshua Stevens

Other Decks in Science

Transcript

  1. C O M M A N D I N G
    Joshua Stevens
    C A R T O G R A P H Y

    View Slide

  2. A BLAST FROM THE PAST

    View Slide

  3. WHERE WE’RE GOING
    The case for the command line
    Some examples from the Earth Observatory
    3 must-know tools + how to apply them
    (and we’ll only scratch the surface!)

    View Slide

  4. COMMAND LINE?
    MAPS FROM TEXT?
    NO GUI?

    View Slide

  5. *

    View Slide

  6. EARTH OBSERVATORY
    Daily, data-driven visuals (maps + satellite imagery)
    earthobservatory.nasa.gov

    View Slide

  7. Daily, data-driven visuals (maps + satellite imagery)
    14,600 images since 1999
    EARTH OBSERVATORY
    earthobservatory.nasa.gov

    View Slide

  8. EARTH OBSERVATORY
    Daily, data-driven visuals (maps + satellite imagery)
    14,600 images since 1999
    457 individual stories in 2017
    earthobservatory.nasa.gov

    View Slide

  9. EARTH OBSERVATORY

    View Slide

  10. EARTH OBSERVATORY
    0
    50
    100
    150
    200
    250
    2010 2011 2012 2013 2014 2015 2016 2017
    2 images
    3+ images
    15
    30
    45
    60
    75
    2013 2014 2015 2016 2017
    Reporting is Increasingly Visual Visuals are Increasingly Map-only

    View Slide

  11. WHY BOTHER WITH CLI?
    Some Examples

    View Slide

  12. View Slide

  13. Global data @ 500 m/px
    Consistent data scaling
    Multiple layers (land, water, night lights, +clouds)

    View Slide

  14. Global data @ 500 m/px
    Consistent data scaling
    Multiple layers (land, water, night lights, +clouds)
    Processed with GDAL

    View Slide

  15. View Slide

  16. New data every 3 hours
    NetCDF format
    Multiple variables

    View Slide

  17. New data every 3 hours
    NetCDF format
    Multiple variables
    Processed with GDAL

    View Slide

  18. View Slide

  19. Two weeks of hourly data (336 files)
    NetCDF format
    Processed in GDAL

    View Slide

  20. View Slide

  21. High-dimensional data (lat, lon, temp, depth, time)

    Map component + temp at depth

    Two years of daily measurements (730 frames)

    View Slide

  22. Made with matplotlib + ImageMagick
    High-dimensional data (lat, lon, temp, depth, time)

    Map component + temp at depth

    Two years of daily measurements (730 frames)

    View Slide

  23. Made with matplotlib + ImageMagick
    High-dimensional data (lat, lon, temp, depth, time)

    Map component + temp at depth

    Two years of daily measurements (730 frames)

    View Slide

  24. Made with matplotlib + ImageMagick
    High-dimensional data (lat, lon, temp, depth, time)

    Map component + temp at depth

    Two years of daily measurements (730 frames)

    View Slide

  25. Made with matplotlib + ImageMagick
    High-dimensional data (lat, lon, temp, depth, time)

    Map component + temp at depth

    Two years of daily measurements (730 frames)

    View Slide

  26. TOOLS YOU NEED TO KNOW
    gdal_translate
    Convert formats
    Scale data (32, 16, 8 bit)
    Georeference
    Resize
    Resample
    Crop
    gdalwarp
    Reproject
    Resample
    gdaldem
    Hillshade
    Slope
    Aspect

    View Slide

  27. TOOLS YOU NEED TO KNOW
    gdal_translate
    Convert formats
    Scale data (32, 16, 8 bit)
    Georeference
    Resize
    Resample
    Crop
    gdalwarp
    Reproject
    Resample
    gdaldem
    Hillshade
    Slope
    Aspect

    Apply color palettes**

    View Slide

  28. EXAMPLE: SEA SURFACE TEMP
    https://coralreefwatch.noaa.gov/satellite/bleaching5km/index.php
    $ gdal_translate 'NETCDF:"ct5km_sst_v3.1_20181015.nc":sea_surface_temperature' sst_20181015.tif
    1: Convert NetCDF to GeoTIFF

    View Slide

  29. https://coralreefwatch.noaa.gov/satellite/bleaching5km/index.php
    $ gdal_translate -projwin -90 70 20 0 sst_20181015.tif sst_20181015_cropped.tif
    2: Crop to an area of interest
    EXAMPLE: SEA SURFACE TEMP

    View Slide

  30. EXAMPLE: SEA SURFACE TEMP
    https://coralreefwatch.noaa.gov/satellite/bleaching5km/index.php
    $ gdalwarp -t_srs '+proj=aea +lat_1=4 +lat_2=55 +lon_0=-35'
    sst_20181015_cropped.tif sst_20181015_projected.tif
    3: Reproject (Albers Equal Area)

    View Slide

  31. EXAMPLE: SEA SURFACE TEMP
    https://coralreefwatch.noaa.gov/satellite/bleaching5km/index.php
    $ gdaldem color-relief sst_20181015_projected.tif RdBu.txt sst_20181015_rgb.tif
    4: Apply a color palette

    View Slide

  32. EXAMPLE: SEA SURFACE TEMP
    https://coralreefwatch.noaa.gov/satellite/bleaching5km/index.php
    4: Apply a color palette
    value R G B
    nv = no data
    $ gdaldem color-relief sst_20181015_projected.tif RdBu.txt sst_20181015_rgb.tif

    View Slide

  33. ANIMATION IS EASY
    Just do the previous steps a bunch of times
    for f in *.tif; do
    gdaldem color-relief “$f" Colors.txt “${f%.*}_rgb.tif”
    done

    View Slide

  34. …then make a gif (or video)
    ANIMATION IS EASY
    Just do the previous steps a bunch of times
    for f in *.tif; do
    gdaldem color-relief “$f" Colors.txt “${f%.*}_rgb.tif”
    done
    convert -delay 0 *_rgb.tif animation.gif

    View Slide

  35. MAKE A MAP SANDWICH
    Base map (GIS, Illustrator, …)

    View Slide

  36. MAKE A MAP SANDWICH
    Thematic layers (CLI, Python, …)
    Base map (GIS, Illustrator, …)

    View Slide

  37. MAKE A MAP SANDWICH
    Annotations (Illustrator, PS, …)
    Thematic layers (CLI, Python, …)
    Base map (GIS, Illustrator, …)

    View Slide

  38. MAKE A MAP SANDWICH
    https://xkcd.com/303/
    (THEN EAT IT… OR BE PRODUCTIVE WITH NEWFOUND TIME)

    View Slide

  39. Joshua Stevens
    [email protected]
    T H A N K Y O U !
    Get in touch:
    @jscarto
    JoshuaStevens.net/contact

    View Slide