-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Expanded Yosemite pack; added tool for searching NGMDB
- Loading branch information
Showing
11 changed files
with
344 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
# https://ngmdb.usgs.gov/ngm-bin/ngm_search_json.pl?State=CA&Counties=Contra%20Costa&Counties=Alameda | ||
|
||
import argparse | ||
import re | ||
import requests | ||
from rich.console import Console | ||
from rich.table import Table | ||
from rich.highlighter import RegexHighlighter | ||
from rich.theme import Theme | ||
|
||
SEARCH_ENDPOINT = "https://ngmdb.usgs.gov/ngm-bin/ngm_search_json.pl" | ||
STATE_CODES = [ | ||
"AK", "AL", "AR", "AS", "AZ", "CA", "CO", "CT", "DC", "DE", "FL", "GA", "GU", | ||
"HI", "IA", "ID", "IL", "IN", "KS", "KY", "LA", "MA", "MD", "ME", "MI", "MN", | ||
"MO", "MP", "MS", "MT", "NC", "ND", "NE", "NH", "NJ", "NM", "NV", "NY", "OH", | ||
"OK", "OR", "PA", "PR", "RI", "SC", "SD", "TN", "TX", "UT", "VA", "VI", "VT", | ||
"WA", "WI", "WV", "WY" | ||
] | ||
|
||
class GeologicMapHighlighter(RegexHighlighter): | ||
"""Highlight text relative to geologic maps""" | ||
base_style = "underfoot." | ||
highlights = [ | ||
re.compile(r"(?P<geologic>geologic|geology)", re.IGNORECASE), | ||
re.compile(r"(?P<geologic_map>geologic map)", re.IGNORECASE), | ||
re.compile(r"(?P<database>database)", re.IGNORECASE) | ||
] | ||
|
||
|
||
theme = Theme({ | ||
"underfoot.geologic_map": "bold green", | ||
"underfoot.geologic": "green", | ||
"underfoot.database": "bold yellow" | ||
}) | ||
|
||
if __name__ == "__main__": | ||
parser = argparse.ArgumentParser(description="Search NGMDB for geologic sources") | ||
parser.add_argument( | ||
"--state", | ||
type=str, | ||
choices=STATE_CODES, | ||
help="US state (two-letter)" | ||
) | ||
parser.add_argument( | ||
"--counties", | ||
type=str, | ||
action="append" | ||
) | ||
args = parser.parse_args() | ||
print(f"args: {args}") | ||
response = requests.get(SEARCH_ENDPOINT, { | ||
"State": args.state, | ||
"Counties": args.counties, | ||
"format": "gis" | ||
}) | ||
# headers = ["title", "scale", "year", "url"] | ||
# data = [[ | ||
# result["title"], | ||
# result["scale"], | ||
# result["year"], | ||
# f"https://ngmdb.usgs.gov/Prodesc/proddesc_{result['id']}.htm", | ||
|
||
# ] ] | ||
# table = PrettyTable() | ||
# table.field_names = headers | ||
# table.align["title"] = "l" | ||
# table.align["url"] = "l" | ||
# table.add_rows(data) | ||
# print(table) | ||
table = Table(title="NGMDB Results", highlight=True) | ||
table.add_column("title") | ||
table.add_column("scale", justify="right") | ||
table.add_column("year", justify="right") | ||
table.add_column("url") | ||
for result in response.json()["ngmdb_catalog_search"]["results"]: | ||
table.add_row( | ||
result["title"], | ||
result["scale"], | ||
str(result["year"]), | ||
f"https://ngmdb.usgs.gov/Prodesc/proddesc_{result['id']}.htm" | ||
) | ||
console = Console(highlighter=GeologicMapHighlighter(), theme=theme) | ||
console.print(table) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,8 @@ | ||
{ | ||
"coordinates": [ | ||
[ | ||
[ | ||
[ | ||
-120, | ||
37.4 | ||
], | ||
[ | ||
-120, | ||
38.3 | ||
], | ||
[ | ||
-119, | ||
38.3 | ||
], | ||
[ | ||
-119, | ||
37.4 | ||
], | ||
[ | ||
-120, | ||
37.4 | ||
] | ||
] | ||
] | ||
], | ||
"type": "MultiPolygon" | ||
"type": "FeatureCollection", | ||
"name": "us-ca-yosemite", | ||
"crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } }, | ||
"features": [ | ||
{ "type": "Feature", "properties": { }, "geometry": { "type": "Polygon", "coordinates": [ [ [ -120.382118026905886, 37.983248080837676 ], [ -119.548444680299653, 38.68819417598732 ], [ -118.435167636308194, 37.901303110554608 ], [ -119.319612926281664, 37.106095341234457 ], [ -120.382118026905886, 37.983248080837676 ] ] ] } } | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
""" | ||
Geologic map of California : Walker Lake sheet | ||
""" | ||
|
||
from gam_25_walkerlake_1963_gis import run | ||
|
||
if __name__ == "__main__": | ||
run() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
""" | ||
Geologic map of California : Walker Lake sheet | ||
""" | ||
|
||
import os | ||
import re | ||
|
||
from util.rocks import process_usgs_source | ||
from util.proj import NAD83_CA_ALBERS | ||
|
||
|
||
def run(): | ||
process_usgs_source( | ||
base_path=os.path.realpath(__file__), | ||
url="https://www.conservation.ca.gov/cgs/Documents/Publications/Geologic-Atlas-Maps/" | ||
"GAM_25-WalkerLake-1963-GIS.zip", | ||
extracted_file_path="GAM_25-WalkerLake-1963-GIS/GAM_25_WalkerLake-open/GM_MapUnitPolys.shp", | ||
srs=NAD83_CA_ALBERS, | ||
use_unzip=True, | ||
polygons_join_col="MapUnit", | ||
mappable_metadata_csv_path="GAM_25-WalkerLake-1963-GIS/GAM_25_WalkerLake-open/" | ||
"DescriptionOfMapUnits.csv", | ||
mappable_metadata_mapping={ | ||
"code": "MapUnit", | ||
"title": "FullName", | ||
"span": "Age", | ||
"description": "Descr" | ||
} | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
[ | ||
{ | ||
"type": "map", | ||
"edition": "1st", | ||
"publisher": "California Department of Conservation", | ||
"scale": "1:250000", | ||
"title": "Geologic map of California : Walker Lake Sheet", | ||
"URL": "https://www.conservation.ca.gov/cgs/rgm", | ||
"author": [ | ||
{ | ||
"family": "Koenig", | ||
"given": "James B." | ||
} | ||
], | ||
"issued": { | ||
"date-parts": [ | ||
[ | ||
"1963" | ||
] | ||
] | ||
} | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
""" | ||
Geologic Map of the Bodie Hills, California and Nevada | ||
""" | ||
|
||
from sim3318 import run | ||
|
||
if __name__ == "__main__": | ||
run() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import util | ||
import os | ||
|
||
from util.rocks import process_usgs_source | ||
|
||
|
||
def run(): | ||
process_usgs_source( | ||
base_path=os.path.realpath(__file__), | ||
url="https://pubs.usgs.gov/sim/3318/downloads/SIM3318_Geodatabase_Shapefiles.zip", | ||
extracted_file_path="SIM3318_Geodatabase_Shapefiles/SIM3318_shapefiles/Polygons.shp", | ||
use_unzip=True, | ||
srs=util.WGS84_UTM11_PROJ4, | ||
metadata_csv_path=os.path.join( | ||
os.path.dirname(os.path.realpath(__file__)), | ||
"units.csv" | ||
) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
[ | ||
{ | ||
"id": "http://zotero.org/users/local/b90sdi4a/items/KE9JXDA7", | ||
"type": "map", | ||
"collection-title": "Scientific Investigations Map", | ||
"language": "en", | ||
"note": "collection-title: Scientific Investigations Map", | ||
"publisher": "U.S. Geological Survey", | ||
"scale": "1:50000", | ||
"title": "Geologic Map of the Bodie Hills, California and Nevada", | ||
"URL": "https://pubs.usgs.gov/sim/3318/", | ||
"author": [ | ||
{ | ||
"family": "John", | ||
"given": "David A." | ||
}, | ||
{ | ||
"family": "Bray", | ||
"given": "Edward A.", | ||
"non-dropping-particle": "du" | ||
}, | ||
{ | ||
"family": "Box", | ||
"given": "Stephen E." | ||
}, | ||
{ | ||
"family": "Vikre", | ||
"given": "Peter G." | ||
}, | ||
{ | ||
"family": "Rytuba", | ||
"given": "James J." | ||
}, | ||
{ | ||
"family": "Fleck", | ||
"given": "Robert J." | ||
}, | ||
{ | ||
"family": "Moring", | ||
"given": "Barry C." | ||
} | ||
], | ||
"issued": { | ||
"date-parts": [ | ||
[ | ||
"2015" | ||
] | ||
] | ||
} | ||
} | ||
] |
Oops, something went wrong.