NASA SnowEx was a multi-year airborne and field campaign aimed at understanding the seasonal snowpack across the western United States and Alaska. Each campaign combined airborne remote sensing (lidar, radar, hyperspectral imagery) with intensive ground truth measurements across a variety of different snow climates. The goal was to improve snow water equivalent (SWE) retrieval algorithms for future spaceborne missions.
The SnowEx database consolidates measurements from all campaigns into a single queryable PostgreSQL/PostGIS database. It holds point measurements (snow depths, Federal Sampler SWE) and snow pit information (density, temperature, stratigraphy from snow pits). This software is a client for accessing the database using Python.
All data in the SnowEx database is publicly available and can be accessed via the [public records at the National Snow and Ice Data Center](https://nsidc.org/data/snowex/data). The data are a raw import of all the CSV files and not curated or cleaned
Install using pip:
pip install snowexsql
For a complete walkthrough of accessing and querying the SnowEx database, including spatial queries, filtering by campaign or instrument, and working with the returned data, see the Project Pythia Snow Observations Cookbook:
- SnowEx Database Tutorial — step-by-step guide to using the Lambda client and the API classes
There are two ways to access the SnowEx database. The preferred way is to use the Lambda Client, which does not require setting up credentials locally after a user installation and all queries are fully supported. There is a limit of 1000 records returned per query, which is sufficient for most use cases and good filtering.
Another option is to connect directely from your local machine to the database, which requires [authentication setup](#configuring-the-database-connection) and has less limits on returned records. However, it is more technical to query the database directly, and is recommended for advanced use cases. Rather than retrieving a large number of records the user is encouraged to use the filters to reduce the amount of data to the needed rows. See the SnowEx Database Tutorial for examples of filtering and querying the database.
Due to the heavy dependencies of GeoPandas on other libraries, the Lambda Client was stripped down to features that are only available via Pandas. The returned dataframe still has the ability to be converted to a GeoPandas dataframe locally.
- **Lambda Client (no credentials required) - Preferred **
The recommended approach for most users. The
SnowExLambdaClientconnects to a public Amazon AWS Lambda Function URL that proxies queries to the database. No AWS account or database credentials are needed.from snowexsql.lambda_client import SnowExLambdaClient client = SnowExLambdaClient() classes = client.get_measurement_classes() PointMeasurements = classes['PointMeasurements'] df = PointMeasurements.from_filter(type='depth', limit=100)
- Direct database access via local client (credentials required) - Technical users
For advanced users with database credentials, the
snowexsql.apiclasses can be used directly. This path also supports raster queries (in beta).from snowexsql.api import PointMeasurements, LayerMeasurements df = LayerMeasurements.from_filter(type='density', limit=100)
For users wishing to have direct access to the database, there are two options for setting up the credentials:
- Set database connection URL via
SNOWEX_DB_CONNECTIONenvironment variable Example:
export SNOWEX_DB_CONNECTION="user:password@127.0.0.1/db_name"- Point to a credentials JSON file via
SNOWEX_DB_CREDENTIALSenvironment variable Example
export SNOWEX_DB_CREDENTIALS="/path/to/credentials.json"{
"address": "localhost",
"db_name": "snowexdb",
"username": "user",
"password": "password"
}Jump over to our discussion forum and get help from our community.
Our read the docs pages include documentation of the API structure and provides a detailed description of the database schema.
Thank you for the interest!
Have a look at our contribution guide and see the many ways to get involved!
To run the test suite locally requires having a running instance of PostgreSQL. The test suite is configured to run against these credentials:
builder:db_builder@localhost/test
This requires a running database on localhost where the user builder has access
to the test database with the password db_builder.
It is possible to set a custom host and database via the SNOWEX_TEST_DB environment
variable. Example that would connect to a server on my.host and the database
snowex_test:
export SNOWEX_TEST_DB="my_host/snowex_test"More on connection strings to PostgreSQL can be found with the official documentation.