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
  2. A BLAST FROM THE PAST

  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!)
  4. COMMAND LINE? MAPS FROM TEXT? NO GUI?

  5. *

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

  7. Daily, data-driven visuals (maps + satellite imagery) 14,600 images since

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

    images since 1999 457 individual stories in 2017 earthobservatory.nasa.gov
  9. EARTH OBSERVATORY

  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
  11. WHY BOTHER WITH CLI? Some Examples

  12. None
  13. Global data @ 500 m/px Consistent data scaling Multiple layers

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

    (land, water, night lights, +clouds) Processed with GDAL
  15. None
  16. New data every 3 hours NetCDF format Multiple variables

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

    with GDAL
  18. None
  19. Two weeks of hourly data (336 files) NetCDF format Processed

    in GDAL
  20. None
  21. High-dimensional data (lat, lon, temp, depth, time) Map component +

    temp at depth Two years of daily measurements (730 frames)
  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)
  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)
  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)
  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)
  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 …
  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**
  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
  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
  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)
  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
  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
  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
  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
  35. MAKE A MAP SANDWICH Base map (GIS, Illustrator, …)

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

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

    (CLI, Python, …) Base map (GIS, Illustrator, …)
  38. MAKE A MAP SANDWICH https://xkcd.com/303/ (THEN EAT IT… OR BE

    PRODUCTIVE WITH NEWFOUND TIME)
  39. Joshua Stevens joshua.e.stevens@nasa.gov T H A N K Y O

    U ! Get in touch: @jscarto JoshuaStevens.net/contact