Below is a script that combines the
USGS
Product API and Google's
Geolocation API to make a shell script to retrieve topo
maps from the command line. 'Product' in this context refers to
mapping products that the USGS makes freely available to the world.
This is a relatively easy script to write because the USGS API finds products
given lat / long bounding box. Google
Geolocation API will happily give you back just such a bounding box. This means you
can seamlessly convert a place names into a searchable geographic
location.
Here's the script in action. As you can see the USGS mapping
products are treasure trove just waiting to be mined.
# Topo containing the White House
$ usgsassist -a topos -l "1600 Pennsylvania Ave, Washington DC"
Washington West, DC,MD,VA 2019|2019-11-22|https://prd-tnm.s3.amazonaws.com/StagedProducts/Maps/USTopo/PDF/DC/DC_Washington_West_20191122_TM_geo.pdf
# Topo maps for Chicago
$ usgsassist -a topos -l "Chicago, IL"
Arlington Heights, IL 2021|2021-04-16|https://prd-tnm.s3.amazonaws.com/StagedProducts/Maps/USTopo/PDF/IL/IL_Arlington_Heights_20210416_TM_geo.pdf
Berwyn, IL 2021|2021-04-23|https://prd-tnm.s3.amazonaws.com/StagedProducts/Maps/USTopo/PDF/IL/IL_Berwyn_20210423_TM_geo.pdf
Blue Island, IL 2021|2021-04-20|https://prd-tnm.s3.amazonaws.com/StagedProducts/Maps/USTopo/PDF/IL/IL_Blue_Island_20210420_TM_geo.pdf
Chicago Loop OE E, IL 2021|2021-04-20|https://prd-tnm.s3.amazonaws.com/StagedProducts/Maps/USTopo/PDF/IL/IL_Chicago_Loop_OE_E_20210420_TM_geo.pdf
Chicago Loop, IL 2021|2021-04-20|https://prd-tnm.s3.amazonaws.com/StagedProducts/Maps/USTopo/PDF/IL/IL_Chicago_Loop_20210420_TM_geo.pdf
Elmhurst, IL 2021|2021-04-20|https://prd-tnm.s3.amazonaws.com/StagedProducts/Maps/USTopo/PDF/IL/IL_Elmhurst_20210420_TM_geo.pdf
Englewood, IL 2021|2021-04-20|https://prd-tnm.s3.amazonaws.com/StagedProducts/Maps/USTopo/PDF/IL/IL_Englewood_20210420_TM_geo.pdf
Evanston, IL 2021|2021-04-16|https://prd-tnm.s3.amazonaws.com/StagedProducts/Maps/USTopo/PDF/IL/IL_Evanston_20210416_TM_geo.pdf
Hinsdale, IL 2021|2021-04-20|https://prd-tnm.s3.amazonaws.com/StagedProducts/Maps/USTopo/PDF/IL/IL_Hinsdale_20210420_TM_geo.pdf
Jackson Park, IL,IN 2021|2021-04-20|https://prd-tnm.s3.amazonaws.com/StagedProducts/Maps/USTopo/PDF/IL/IL_Jackson_Park_20210420_TM_geo.pdf
Lake Calumet, IL,IN 2021|2021-04-20|https://prd-tnm.s3.amazonaws.com/StagedProducts/Maps/USTopo/PDF/IL/IL_Lake_Calumet_20210420_TM_geo.pdf
Palos Park, IL 2021|2021-04-20|https://prd-tnm.s3.amazonaws.com/StagedProducts/Maps/USTopo/PDF/IL/IL_Palos_Park_20210420_TM_geo.pdf
Park Ridge, IL 2021|2021-04-16|https://prd-tnm.s3.amazonaws.com/StagedProducts/Maps/USTopo/PDF/IL/IL_Park_Ridge_20210416_TM_geo.pdf
River Forest, IL 2021|2021-04-20|https://prd-tnm.s3.amazonaws.com/StagedProducts/Maps/USTopo/PDF/IL/IL_River_Forest_20210420_TM_geo.pdf
Sag Bridge, IL 2021|2021-04-20|https://prd-tnm.s3.amazonaws.com/StagedProducts/Maps/USTopo/PDF/IL/IL_Sag_Bridge_20210420_TM_geo.pdf
# Topo maps for all of Virginia
# Peek at the start of list.
$ usgsassist -a topos -l "Virginia, USA" | head -5
Abilene, VA|2022-09-14|https://prd-tnm.s3.amazonaws.com/StagedProducts/Maps/USTopo/PDF/VA/VA_Abilene_20220914_TM_geo.pdf
Abingdon, VA|2022-09-16|https://prd-tnm.s3.amazonaws.com/StagedProducts/Maps/USTopo/PDF/VA/VA_Abingdon_20220916_TM_geo.pdf
Accomac, VA|2022-08-31|https://prd-tnm.s3.amazonaws.com/StagedProducts/Maps/USTopo/PDF/VA/VA_Accomac_20220831_TM_geo.pdf
Achilles, VA|2022-09-09|https://prd-tnm.s3.amazonaws.com/StagedProducts/Maps/USTopo/PDF/VA/VA_Achilles_20220909_TM_geo.pdf
Adams Grove, VA|2022-09-14|https://prd-tnm.s3.amazonaws.com/StagedProducts/Maps/USTopo/PDF/VA/VA_Adams_Grove_20220914_TM_geo.pdf
# Peek at the end
$ usgsassist -a topos -l "Virginia, USA" | tail -5
Woodsboro, MD 2019|2019-11-22|https://prd-tnm.s3.amazonaws.com/StagedProducts/Maps/USTopo/PDF/MD/MD_Woodsboro_20191122_TM_geo.pdf
Wye Mills, MD 2019|2019-12-02|https://prd-tnm.s3.amazonaws.com/StagedProducts/Maps/USTopo/PDF/MD/MD_Wye_Mills_20191202_TM_geo.pdf
Wyoming, DE 2019|2019-11-21|https://prd-tnm.s3.amazonaws.com/StagedProducts/Maps/USTopo/PDF/DE/DE_Wyoming_20191121_TM_geo.pdf
Yellow Spring, WV 2019|2019-12-12|https://prd-tnm.s3.amazonaws.com/StagedProducts/Maps/USTopo/PDF/WV/WV_Yellow_Spring_20191212_TM_geo.pdf
Zaleski, OH 2019|2019-12-03|https://prd-tnm.s3.amazonaws.com/StagedProducts/Maps/USTopo/PDF/OH/OH_Zaleski_20191203_TM_geo.pdf
# the total number of maps
$ usgsassist -a topos -l "Virginia, USA" | wc -l
1697
# Topo maps for a National Park
$ usgsassist -a topos -l "Rocky Mountain National Park, Colorado"
Allenspark, CO|2022-03-25|https://prd-tnm.s3.amazonaws.com/StagedProducts/Maps/USTopo/PDF/CO/CO_Allenspark_20220325_TM_geo.pdf
Bowen Mountain, CO|2022-03-25|https://prd-tnm.s3.amazonaws.com/StagedProducts/Maps/USTopo/PDF/CO/CO_Bowen_Mountain_20220325_TM_geo.pdf
Chambers Lake, CO|2022-03-25|https://prd-tnm.s3.amazonaws.com/StagedProducts/Maps/USTopo/PDF/CO/CO_Chambers_Lake_20220325_TM_geo.pdf
Clark Peak, CO|2022-03-25|https://prd-tnm.s3.amazonaws.com/StagedProducts/Maps/USTopo/PDF/CO/CO_Clark_Peak_20220325_TM_geo.pdf
Comanche Peak, CO|2022-03-25|https://prd-tnm.s3.amazonaws.com/StagedProducts/Maps/USTopo/PDF/CO/CO_Comanche_Peak_20220325_TM_geo.pdf
Crystal Mountain, CO|2022-03-15|https://prd-tnm.s3.amazonaws.com/StagedProducts/Maps/USTopo/PDF/CO/CO_Crystal_Mountain_20220315_TM_geo.pdf
Estes Park, CO|2022-03-15|https://prd-tnm.s3.amazonaws.com/StagedProducts/Maps/USTopo/PDF/CO/CO_Estes_Park_20220315_TM_geo.pdf
Fall River Pass, CO|2022-03-25|https://prd-tnm.s3.amazonaws.com/StagedProducts/Maps/USTopo/PDF/CO/CO_Fall_River_Pass_20220325_TM_geo.pdf
Glen Haven, CO|2022-03-25|https://prd-tnm.s3.amazonaws.com/StagedProducts/Maps/USTopo/PDF/CO/CO_Glen_Haven_20220325_TM_geo.pdf
Grand Lake, CO|2022-03-16|https://prd-tnm.s3.amazonaws.com/StagedProducts/Maps/USTopo/PDF/CO/CO_Grand_Lake_20220316_TM_geo.pdf
Isolation Peak, CO|2022-03-15|https://prd-tnm.s3.amazonaws.com/StagedProducts/Maps/USTopo/PDF/CO/CO_Isolation_Peak_20220315_TM_geo.pdf
Longs Peak, CO|2022-03-25|https://prd-tnm.s3.amazonaws.com/StagedProducts/Maps/USTopo/PDF/CO/CO_Longs_Peak_20220325_TM_geo.pdf
McHenrys Peak, CO|2022-03-25|https://prd-tnm.s3.amazonaws.com/StagedProducts/Maps/USTopo/PDF/CO/CO_McHenrys_Peak_20220325_TM_geo.pdf
Mount Richthofen, CO|2022-03-25|https://prd-tnm.s3.amazonaws.com/StagedProducts/Maps/USTopo/PDF/CO/CO_Mount_Richthofen_20220325_TM_geo.pdf
Panorama Peak, CO|2022-03-25|https://prd-tnm.s3.amazonaws.com/StagedProducts/Maps/USTopo/PDF/CO/CO_Panorama_Peak_20220325_TM_geo.pdf
Pingree Park, CO|2022-03-25|https://prd-tnm.s3.amazonaws.com/StagedProducts/Maps/USTopo/PDF/CO/CO_Pingree_Park_20220325_TM_geo.pdf
Raymond, CO|2022-03-25|https://prd-tnm.s3.amazonaws.com/StagedProducts/Maps/USTopo/PDF/CO/CO_Raymond_20220325_TM_geo.pdf
Shadow Mountain, CO|2022-03-25|https://prd-tnm.s3.amazonaws.com/StagedProducts/Maps/USTopo/PDF/CO/CO_Shadow_Mountain_20220325_TM_geo.pdf
Trail Mountain, CO|2022-03-25|https://prd-tnm.s3.amazonaws.com/StagedProducts/Maps/USTopo/PDF/CO/CO_Trail_Mountain_20220325_TM_geo.pdf
Trail Ridge, CO|2022-03-15|https://prd-tnm.s3.amazonaws.com/StagedProducts/Maps/USTopo/PDF/CO/CO_Trail_Ridge_20220315_TM_geo.pdf
# Historic maps of Boston published from 1910-39
$ usgsassist -a historic -l "Boston, MA" | grep '|19[123][0-9]'
USGS 1:24000-scale Quadrangle for Blue Hills, MA 1936|1936-01-01|https://prd-tnm.s3.amazonaws.com/StagedProducts/Maps/HistoricalTopo/PDF/MA/24000/MA_Blue%20Hills_350022_1936_24000_geo.pdf
USGS 1:24000-scale Quadrangle for Cohasset, MA 1936|1936-01-01|https://prd-tnm.s3.amazonaws.com/StagedProducts/Maps/HistoricalTopo/PDF/MA/24000/MA_Cohasset_350067_1936_24000_geo.pdf
USGS 1:24000-scale Quadrangle for Nantasket, MA 1936|1936-01-01|https://prd-tnm.s3.amazonaws.com/StagedProducts/Maps/HistoricalTopo/PDF/MA/24000/MA_Nantasket_350329_1936_24000_geo.pdf
USGS 1:24000-scale Quadrangle for Norwood, MA 1936|1936-01-01|https://prd-tnm.s3.amazonaws.com/StagedProducts/Maps/HistoricalTopo/PDF/MA/24000/MA_Norwood_350406_1936_24000_geo.pdf
USGS 1:24000-scale Quadrangle for Scituate, MA 1935|1935-01-01|https://prd-tnm.s3.amazonaws.com/StagedProducts/Maps/HistoricalTopo/PDF/MA/24000/MA_Scituate_350536_1935_24000_geo.pdf
USGS 1:24000-scale Quadrangle for Weymouth, MA 1936|1936-01-01|https://prd-tnm.s3.amazonaws.com/StagedProducts/Maps/HistoricalTopo/PDF/MA/24000/MA_Weymouth_350724_1936_24000_geo.pdf
USGS 1:62500-scale Quadrangle for Abington, MA 1920|1920-01-01|https://prd-tnm.s3.amazonaws.com/StagedProducts/Maps/HistoricalTopo/PDF/MA/62500/MA_Abington_352433_1920_62500_geo.pdf
USGS 1:62500-scale Quadrangle for Dedham, MA 1919|1919-01-01|https://prd-tnm.s3.amazonaws.com/StagedProducts/Maps/HistoricalTopo/PDF/MA/62500/MA_Dedham_352583_1919_62500_geo.pdf
USGS 1:62500-scale Quadrangle for Duxbury, MA 1918|1918-01-01|https://prd-tnm.s3.amazonaws.com/StagedProducts/Maps/HistoricalTopo/PDF/MA/62500/MA_Duxbury_462916_1918_62500_geo.pdf
USGS 1:62500-scale Quadrangle for Duxbury, MA 1918|1918-01-01|https://prd-tnm.s3.amazonaws.com/StagedProducts/Maps/HistoricalTopo/PDF/MA/62500/MA_Duxbury_462918_1918_62500_geo.pdf
# The 10 oldest maps of New York city
$ usgsassist -a historic -l "New York, NY" | sort -t'|' -k2 | head -20
USGS 1:62500-scale Quadrangle for Morristown, NJ 1888|1888-01-01|https://prd-tnm.s3.amazonaws.com/StagedProducts/Maps/HistoricalTopo/PDF/NJ/62500/NJ_Morristown_255268_1888_62500_geo.pdf
USGS 1:62500-scale Quadrangle for New Brunswick, NJ 1888|1888-01-01|https://prd-tnm.s3.amazonaws.com/StagedProducts/Maps/HistoricalTopo/PDF/NJ/62500/NJ_New%20Brunswick_255290_1888_62500_geo.pdf
USGS 1:62500-scale Quadrangle for Paterson, NJ 1888|1888-01-01|https://prd-tnm.s3.amazonaws.com/StagedProducts/Maps/HistoricalTopo/PDF/NJ/62500/NJ_Paterson_255310_1888_62500_geo.pdf
USGS 1:62500-scale Quadrangle for Plainfield, NJ 1888|1888-01-01|https://prd-tnm.s3.amazonaws.com/StagedProducts/Maps/HistoricalTopo/PDF/NJ/62500/NJ_Plainfield_255320_1888_62500_geo.pdf
USGS 1:62500-scale Quadrangle for Sandy Hook, NJ 1888|1888-01-01|https://prd-tnm.s3.amazonaws.com/StagedProducts/Maps/HistoricalTopo/PDF/NJ/62500/NJ_Sandy%20Hook_255362_1888_62500_geo.pdf
USGS 1:62500-scale Quadrangle for Brooklyn, NY 1889|1889-01-01|https://prd-tnm.s3.amazonaws.com/StagedProducts/Maps/HistoricalTopo/PDF/NY/62500/NY_Brooklyn_8033200_1889_62500_geo.pdf
USGS 1:62500-scale Quadrangle for Harlem, NJ 1891|1891-01-01|https://prd-tnm.s3.amazonaws.com/StagedProducts/Maps/HistoricalTopo/PDF/NJ/62500/NJ_Harlem_472515_1891_62500_geo.pdf
USGS 1:62500-scale Quadrangle for Brooklyn, NY 1891|1891-01-01|https://prd-tnm.s3.amazonaws.com/StagedProducts/Maps/HistoricalTopo/PDF/NY/62500/NY_Brooklyn_8033120_1891_62500_geo.pdf
USGS 1:62500-scale Quadrangle for Paterson, NJ 1892|1892-01-01|https://prd-tnm.s3.amazonaws.com/StagedProducts/Maps/HistoricalTopo/PDF/NJ/62500/NJ_Paterson_472458_1892_62500_geo.pdf
USGS 1:62500-scale Quadrangle for New Brunswick, NJ 1893|1893-01-01|https://prd-tnm.s3.amazonaws.com/StagedProducts/Maps/HistoricalTopo/PDF/NJ/62500/NJ_New%20Brunswick_255291_1893_62500_geo.pdf
USGS 1:62500-scale Quadrangle for New Brunswick, NJ 1893|1893-01-01|https://prd-tnm.s3.amazonaws.com/StagedProducts/Maps/HistoricalTopo/PDF/NJ/62500/NJ_New%20Brunswick_255292_1893_62500_geo.pdf
USGS 1:62500-scale Quadrangle for Plainfield, NJ 1893|1893-01-01|https://prd-tnm.s3.amazonaws.com/StagedProducts/Maps/HistoricalTopo/PDF/NJ/62500/NJ_Plainfield_255321_1893_62500_geo.pdf
USGS 1:62500-scale Quadrangle for Plainfield, NJ 1893|1893-01-01|https://prd-tnm.s3.amazonaws.com/StagedProducts/Maps/HistoricalTopo/PDF/NJ/62500/NJ_Plainfield_255323_1893_62500_geo.pdf
USGS 1:62500-scale Quadrangle for Sandy Hook, NJ 1893|1893-01-01|https://prd-tnm.s3.amazonaws.com/StagedProducts/Maps/HistoricalTopo/PDF/NJ/62500/NJ_Sandy%20Hook_255363_1893_62500_geo.pdf
USGS 1:62500-scale Quadrangle for Sandy Hook, NJ 1893|1893-01-01|https://prd-tnm.s3.amazonaws.com/StagedProducts/Maps/HistoricalTopo/PDF/NJ/62500/NJ_Sandy%20Hook_255364_1893_62500_geo.pdf
USGS 1:62500-scale Quadrangle for Morristown, NJ 1894|1894-01-01|https://prd-tnm.s3.amazonaws.com/StagedProducts/Maps/HistoricalTopo/PDF/NJ/62500/NJ_Morristown_255269_1894_62500_geo.pdf
USGS 1:62500-scale Quadrangle for Brooklyn, NY 1897|1897-01-01|https://prd-tnm.s3.amazonaws.com/StagedProducts/Maps/HistoricalTopo/PDF/NY/62500/NY_Brooklyn_123118_1897_62500_geo.pdf
USGS 1:62500-scale Quadrangle for Brooklyn, NY 1897|1897-01-01|https://prd-tnm.s3.amazonaws.com/StagedProducts/Maps/HistoricalTopo/PDF/NY/62500/NY_Brooklyn_123119_1897_62500_geo.pdf
USGS 1:62500-scale Quadrangle for Brooklyn, NY 1897|1897-01-01|https://prd-tnm.s3.amazonaws.com/StagedProducts/Maps/HistoricalTopo/PDF/NY/62500/NY_Brooklyn_123121_1897_62500_geo.pdf
USGS 1:62500-scale Quadrangle for Harlem, NY 1897|1897-01-01|https://prd-tnm.s3.amazonaws.com/StagedProducts/Maps/HistoricalTopo/PDF/NY/62500/NY_Harlem_129718_1897_62500_geo.pdf
# Historic maps of Rochester from the 1800's
$ usgsassist -a historic -l "Rochester, NY" -v | jq -r '.items[] | select(.publicationDate | test("^18")) | .title'
USGS 1:62500-scale Quadrangle for Ontario Beach, NY 1895
USGS 1:62500-scale Quadrangle for Ontario Beach, NY 1899
USGS 1:62500-scale Quadrangle for Ontario Beach, NY 1899
USGS 1:62500-scale Quadrangle for Ontario Beach, NY 1899
USGS 1:62500-scale Quadrangle for Rochester, NY 1895
USGS 1:62500-scale Quadrangle for Rochester, NY 1898
USGS 1:62500-scale Quadrangle for Rochester, NY 1898
USGS 1:62500-scale Quadrangle for Rochester, NY 1898
USGS 1:62500-scale Quadrangle for Rochester, NY 1898
USGS 1:62500-scale Quadrangle for Rochester, NY 1898
# An preview image of these maps
$ usgsassist -a historic -l "Rochester, NY" -v | jq -r '.items[] | select(.publicationDate | test("^18")) | .previewGraphicURL'
https://prd-tnm.s3.amazonaws.com/StagedProducts/Maps/HistoricalTopo/PDF/NY/62500/NY_Ontario%20Beach_148062_1895_62500_tn.jpg
https://prd-tnm.s3.amazonaws.com/StagedProducts/Maps/HistoricalTopo/PDF/NY/62500/NY_Ontario%20Beach_148065_1899_62500_tn.jpg
https://prd-tnm.s3.amazonaws.com/StagedProducts/Maps/HistoricalTopo/PDF/NY/62500/NY_Ontario%20Beach_148064_1899_62500_tn.jpg
https://prd-tnm.s3.amazonaws.com/StagedProducts/Maps/HistoricalTopo/PDF/NY/62500/NY_Ontario%20Beach_148063_1899_62500_tn.jpg
https://prd-tnm.s3.amazonaws.com/StagedProducts/Maps/HistoricalTopo/PDF/NY/62500/NY_Rochester_148337_1895_62500_tn.jpg
https://prd-tnm.s3.amazonaws.com/StagedProducts/Maps/HistoricalTopo/PDF/NY/62500/NY_Rochester_148339_1898_62500_tn.jpg
https://prd-tnm.s3.amazonaws.com/StagedProducts/Maps/HistoricalTopo/PDF/NY/62500/NY_Rochester_148345_1898_62500_tn.jpg
https://prd-tnm.s3.amazonaws.com/StagedProducts/Maps/HistoricalTopo/PDF/NY/62500/NY_Rochester_148344_1898_62500_tn.jpg
https://prd-tnm.s3.amazonaws.com/StagedProducts/Maps/HistoricalTopo/PDF/NY/62500/NY_Rochester_148340_1898_62500_tn.jpg
https://prd-tnm.s3.amazonaws.com/StagedProducts/Maps/HistoricalTopo/PDF/NY/62500/NY_Rochester_148343_1898_62500_tn.jpg
# Now grab these images and make a contact sheet
$ usgsassist -a historic -l "Rochester, NY" -v | \
jq -r '.items[] | select(.publicationDate | test("^18")) | .previewGraphicURL' | \
while read url ; do wget -q $url ; done
$ montage *_tn.jpg contact.jpg
Fun, right? Here's the script. Happy Hacking!
#!/bin/bash
##
## Tools to work with the USGS
##
PER_PAGE=50
if [ -f $HOME/.config/usgsassist/config ] ; then
. $HOME/.config/usgsassist/config
else
echo "Missing: ~/.config/usgassist/config file"
exit
fi
usage() {
cmd=$(basename $0)
echo "Usage: $cmd -a topos -l location "
echo "Usage: $cmd -a historic -l location "
echo "Usage: $cmd -a geobox -l location"
exit 1
}
summarize_json() {
if [ "$verbose" = "yes" ] ; then
jq '.items[]' | sed 's/^{/,{/' | sed '1s/^,//'
else
jq -r '.items[] | .title + "|" + .publicationDate + "|" + .downloadURL' | sed -E 's/^(USGS )?US Topo 7.5-minute map for //'
fi
}
get() {
dataset="$1" ; shift
bb="$1" ; shift
offset="$1" ; shift
curl -s -G \
--data-urlencode datasets="$dataset" \
--data-urlencode bbox="$bb" \
--data-urlencode offset="$offset" \
--data-urlencode max="$PER_PAGE" \
https://tnmaccess.nationalmap.gov/api/v1/products | tee $HOME/.usgs.last | summarize_json
}
all() {
dataset="$1" ; shift
bb="$1" ; shift
if [ "$verbose" = "yes" ] ; then
echo '{ "items" : [ '
fi
get "$dataset" "$bb" 0
total=$(cat $HOME/.usgs.last | jq .total)
remaining=$((total - PER_PAGE))
if [ $remaining -gt 0 ] ; then
pages=$(((remaining / PER_PAGE) + 1))
for page in $(seq 1 $pages) ; do
offset=$((page * PER_PAGE))
if [ "$verbose" = "yes" ] ; then
echo ","
fi
get "$dataset" "$bb" "$offset"
done
fi
if [ "$verbose" = "yes" ] ; then
echo '] }'
fi
}
while getopts ":a:l:hv" o; do
case "$o" in
a) action=$OPTARG ;;
l) loc=$OPTARG ;;
v) verbose=yes ;;
*|h) usage ;;
esac
done
case "$action" in
topos)
if [ -z "$loc" ] ; then
echo "Missing -l location"
exit
fi
bb=$(usgsassist -a geobox -l "$loc")
all "US Topo Current" "$bb"
;;
historic)
if [ -z "$loc" ] ; then
echo "Missing -l location"
exit
fi
bb=$(usgsassist -a geobox -l "$loc")
all "Historical Topographic Maps" "$bb"
;;
geobox)
if [ -z "$loc" ] ; then
echo "Missing -l address"
exit
fi
bounds=$HOME/.usgs.bounds
curl -s -G "https://maps.googleapis.com/maps/api/geocode/json" \
--data-urlencode address="$loc" \
-d key=$GOOGLE_MAPS_API_KEY > $bounds
if [ "$verbose" = "yes" ] ; then
cat $bounds
else
ne_lat=$(cat $bounds | jq '.results[0].geometry.viewport.northeast.lat')
ne_lng=$(cat $bounds | jq '.results[0].geometry.viewport.northeast.lng')
sw_lat=$(cat $bounds | jq '.results[0].geometry.viewport.southwest.lat')
sw_lng=$(cat $bounds | jq '.results[0].geometry.viewport.southwest.lng')
echo "$ne_lng,$ne_lat,$sw_lng,$sw_lat"
fi
;;
*) usage ;;
esac