### Install NASADEM using pip Source: https://pypi.org/project/NASADEM/2.1.0 Install the NASADEM package using pip. This is the standard method for adding the package to your Python environment. ```bash pip install NASADEM ``` -------------------------------- ### NASADEM v2.0 Connection Source: https://pypi.org/project/NASADEM/2.1.0 Example of establishing a connection with NASADEM v2.0. The package now handles URLs automatically, simplifying the connection process. ```python from NASADEM import NASADEMConnection # Simpler - earthaccess handles the URLs nasadem = NASADEMConnection( username="user", password="pass" ) ``` -------------------------------- ### NASADEM v1.x Connection Source: https://pypi.org/project/NASADEM/2.1.0 Example of establishing a connection with NASADEM v1.x, including specifying the remote URL. ```python from NASADEM import NASADEMConnection nasadem = NASADEMConnection( username="user", password="pass", remote="https://e4ftl01.cr.usgs.gov" # Old URL ) ``` -------------------------------- ### Install NASADEM from source Source: https://pypi.org/project/NASADEM/2.1.0 Install the NASADEM package directly from its source code repository. This is useful for development or when using the latest unreleased version. ```bash git clone https://github.com/gregory-halverson/NASADEM.git cd NASADEM pip install -e . ``` -------------------------------- ### Get Elevation Data for a Geometry Source: https://pypi.org/project/NASADEM Retrieve elevation data for a specified geographic area defined by a RasterGrid object. This example shows how to get the minimum and maximum elevation values within the defined bounds. ```python from NASADEM import NASADEM from rasters import RasterGrid # Define target area geometry = RasterGrid.from_bbox( xmin=-118.5, ymin=33.5, xmax=-117.5, ymax=34.5, cell_size=30, crs="EPSG:4326" ) # Get elevation data elevation = NASADEM.elevation_m(geometry) print(f"Elevation range: {elevation.min():.1f} to {elevation.max():.1f} meters") # Get surface water body mask water = NASADEM.swb(geometry) ``` -------------------------------- ### Extract Elevation at a Single Point Source: https://pypi.org/project/NASADEM/2.1.0 Get the elevation value at a specific geographic point using the NASADEM package. Requires defining the point with its coordinates. ```python from rasters import Point, MultiPoint from NASADEM import NASADEM # Single point point = Point(-118.0, 34.0) elevation = NASADEM.elevation_m(point) print(f"Elevation at point: {elevation:.1f} m") ``` -------------------------------- ### Get Elevation Data for a Defined Area Source: https://pypi.org/project/NASADEM/2.1.0 Retrieve elevation data for a specified geographic bounding box using the NASADEM package. Requires defining the area with RasterGrid and specifying cell size and CRS. ```python from NASADEM import NASADEM from rasters import RasterGrid # Define target area geometry = RasterGrid.from_bbox( xmin=-118.5, ymin=33.5, xmax=-117.5, ymax=34.5, cell_size=30, crs="EPSG:4326" ) # Get elevation data elevation = NASADEM.elevation_m(geometry) print(f"Elevation range: {elevation.min():.1f} to {elevation.max():.1f} meters") ``` -------------------------------- ### Get Surface Water Body Mask Source: https://pypi.org/project/NASADEM/2.1.0 Retrieve the surface water body (SWB) mask for a defined geographic area using the NASADEM package. This function is used similarly to elevation data retrieval. ```python from NASADEM import NASADEM from rasters import RasterGrid # Define target area geometry = RasterGrid.from_bbox( xmin=-118.5, ymin=33.5, xmax=-117.5, ymax=34.5, cell_size=30, crs="EPSG:4326" ) # Get surface water body mask water = NASADEM.swb(geometry) ``` -------------------------------- ### Configure .netrc for Authentication Source: https://pypi.org/project/NASADEM/2.1.0 Set up a .netrc file in your home directory for authentication with NASA Earthdata. Ensure correct permissions are set for security. ```bash machine urs.earthdata.nasa.gov login YOUR_USERNAME password YOUR_PASSWORD ``` ```bash chmod 600 ~/.netrc ``` -------------------------------- ### Working with NASADEM Tiles Source: https://pypi.org/project/NASADEM Identify and download specific NASADEM data tiles. This allows for more granular control over data retrieval and management. ```python from NASADEM import NASADEM # Get tiles covering an area tiles = NASADEM.tiles(geometry) print(f"Tiles needed: {tiles}") # Download a specific tile granule = NASADEM.download_tile("n34w118") elevation = granule.elevation_m swb = granule.swb ``` -------------------------------- ### Earthaccess Authentication Source: https://pypi.org/project/NASADEM/2.1.0 How to log in and persist credentials using the earthaccess library to resolve authentication issues. ```python import earthaccess earthaccess.login(persist=True) # Save credentials ``` -------------------------------- ### Set Environment Variables for Authentication Source: https://pypi.org/project/NASADEM/2.1.0 Configure environment variables for username and password to authenticate with NASA Earthdata. This is a common method for automated systems. ```bash export EARTHDATA_USERNAME=your_username export EARTHDATA_PASSWORD=your_password ``` -------------------------------- ### Direct Credentials Authentication with NASADEMConnection Source: https://pypi.org/project/NASADEM/2.1.0 Authenticate directly using username and password when creating a NASADEMConnection instance. Optionally persist credentials to a .netrc file. ```python from NASADEM import NASADEMConnection nasadem = NASADEMConnection( username="your_username", password="your_password", persist_credentials=True # Optionally save to .netrc ) ``` -------------------------------- ### Custom Download Directory for NASADEM Source: https://pypi.org/project/NASADEM/2.1.0 Configure the NASADEMConnection to use a custom directory for downloaded data. This allows for better organization of downloaded files. ```python from NASADEM import NASADEMConnection # Create connection with custom download directory nasadem = NASADEMConnection( download_directory="~/my_nasadem_data" ) # Use it the same way elevation = nasadem.elevation_m(geometry) ``` -------------------------------- ### Interactive Earthaccess Login Source: https://pypi.org/project/NASADEM/2.1.0 Perform an interactive login using the earthaccess package. This method prompts for credentials and can optionally save them for future use. ```python import earthaccess earthaccess.login() # Will prompt for credentials and optionally save them ``` -------------------------------- ### Download and Access a Specific NASADEM Tile Source: https://pypi.org/project/NASADEM/2.1.0 Download a specific NASADEM data tile by its identifier and then access its elevation and surface water body data. The downloaded tile is represented by a granule object. ```python from NASADEM import NASADEM # Download a specific tile granule = NASADEM.download_tile("n34w118") elevation = granule.elevation_m swb = granule.swb ``` -------------------------------- ### NASADEMConnection Methods Source: https://pypi.org/project/NASADEM/2.1.0 Methods for interacting with NASADEM data, including retrieving elevation, surface water body masks, and managing tiles. ```APIDOC ## NASADEMConnection Main class for accessing NASADEM data. ### Methods * `elevation_m(geometry)`: Get elevation in meters * `elevation_km(geometry)`: Get elevation in kilometers * `swb(geometry)`: Get surface water body mask * `download_tile(tile)`: Download a specific tile * `tiles(geometry)`: Get list of tiles covering a geometry ### Parameters * `username` (str, optional): NASA Earthdata username * `password` (str, optional): NASA Earthdata password * `working_directory` (str, optional): Working directory for temporary files * `download_directory` (str, optional): Directory for downloaded tiles (default: `~/data/NASADEM`) * `persist_credentials` (bool, optional): Save credentials to `.netrc` (default: False) * `skip_auth` (bool, optional): Skip authentication (useful for testing, default: False) ``` -------------------------------- ### NASADEMGranule Properties Source: https://pypi.org/project/NASADEM/2.1.0 Properties representing a single NASADEM tile. ```APIDOC ## NASADEMGranule Represents a single NASADEM tile. ### Properties * `elevation_m`: Elevation raster in meters * `swb`: Surface water body mask * `geometry`: Raster geometry of the tile * `tile`: Tile identifier (e.g., "n34w118") ``` -------------------------------- ### Identify NASADEM Tiles Covering an Area Source: https://pypi.org/project/NASADEM/2.1.0 Determine which NASADEM data tiles are required to cover a specified geographic area. This helps in planning downloads. ```python from NASADEM import NASADEM # Get tiles covering an area tiles = NASADEM.tiles(geometry) print(f"Tiles needed: {tiles}") ``` -------------------------------- ### Extract Elevation at Multiple Points Source: https://pypi.org/project/NASADEM/2.1.0 Retrieve elevation values for multiple geographic points simultaneously. This is more efficient than querying each point individually. ```python from rasters import Point, MultiPoint from NASADEM import NASADEM # Multiple points points = MultiPoint([ Point(-118.0, 34.0), Point(-117.5, 33.8), Point(-118.2, 34.2) ]) elevations = NASADEM.elevation_m(points) print(f"Elevations: {elevations}") ``` -------------------------------- ### Extract Elevation at Specific Points Source: https://pypi.org/project/NASADEM Extract elevation data for single or multiple geographic points. This is useful for targeted data retrieval. ```python from rasters import Point, MultiPoint from NASADEM import NASADEM # Single point point = Point(-118.0, 34.0) elevation = NASADEM.elevation_m(point) print(f"Elevation at point: {elevation:.1f} m") # Multiple points points = MultiPoint([ Point(-118.0, 34.0), Point(-117.5, 33.8), Point(-118.2, 34.2) ]) elevations = NASADEM.elevation_m(points) print(f"Elevations: {elevations}") ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.