uavsar-pytools

Python tools to download, convert, and visualize UAVSAR images.

https://github.com/snowex/uavsar_pytools

Science Score: 64.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
    Links to: zenodo.org
  • Committers with academic emails
    2 of 6 committers (33.3%) from academic institutions
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (14.3%) to scientific vocabulary
Last synced: 6 months ago · JSON representation ·

Repository

Python tools to download, convert, and visualize UAVSAR images.

Basic Info
  • Host: GitHub
  • Owner: SnowEx
  • Language: Python
  • Default Branch: main
  • Homepage:
  • Size: 12.6 MB
Statistics
  • Stars: 23
  • Watchers: 2
  • Forks: 10
  • Open Issues: 4
  • Releases: 6
Created about 4 years ago · Last pushed over 1 year ago
Metadata Files
Readme Citation

README.md

DOI version

uavsar_pytools

Python tools to download and convert binary Uavsar images from the Alaska Satellite Facility and Jet Propulsion Laboratory databases. Developed by Zachary Keskinen and Jack Tarricone with guidance from Dr. Hans Peter Marshall of Boise State University, Micah Johnson with m3works, and Micah Sandusky with m3works.

Installing

This package is installable with pip. In the terminal enter the following command:

console pip install uavsar_pytools

Authorization

You will need a .netrc file in your home directory. This is a special file that stores passwords and usernames to be accessed by programs. If you are already registered at either the alaska satellite facility or jet propulsion laboratory skip step 1. Otherwise:

  1. If you need a username and password register at link. Please ensure you have signed the end user agreement for Uavsar. You need to attempt to download a uavsar image from vertex to prompt the end user agreement.

  2. In a python terminal or notebook enter: python from uavsar_pytools.uavsar_tools import create_netrc create_netrc()

You will be asked to prompted to enter your username and password and a netrc file will be automatically generated for you. This file will be accessed during downloading and searching for Uavsar images. You will only need to generate this file once on your computer.

Usage

The fundamental class of uavsarpytools is the UavsarScene. This class is used for downloading, unzipping, and converting binary UAVSAR files into Geotiffs in WGS84. In order to use the class you will need to instantiate an instance of the class to hold your specific url and the image data. Please see the included tutorial and code snippet below. After instantiating the class you can call `scene.urlto_tiffs()to fully download and convert the Uavsar images into analysis ready tiffs. The two required inputs are a url to an ASF or JPL zip file (if looking to download a single image seeUavsarImage` in the included notebooks) and that has been ground referenced (must have a .grd or _grd in the name) along with a directory that you want to store the image files in.

```python from uavsar_pytools import UavsarScene

Example url. Use vertex to find other urls: https://search.asf.alaska.edu/

zipurl = 'https://datapool.asf.alaska.edu/INTERFEROMETRYGRD/UA/lowman0520821019-01921021-0070006ds01L09001int_grd.zip'

Change this variable to a directory you want to download files into

image_directory = '~/directory/to/store/images/'

Instantiating an instance of the UavsarScene class and downloading all images

scene = UavsarScene(url = zipurl, workdir= imagedirectory) scene.urlto_tiffs() ```

You will now have a folder of analysis ready tiff images in WGS84 from the provided url in your specificed work directory.

If you are interested in working with each image's numpy array the class has an scene.images property that contains the type, description, and numpy array for each image in the zip file. This is available after running scene.url_to_tiffs().

python scene.images['unw']['array'] # get the unwrapped phase numpy array for analysis scene.images['cor']['out_fp'] # get file path of saved tiff for coherence

For quick checks to visualize the data there is also a convenience method scene.show(i = 'cor') that allows you to quickly visualize the a specific type of image. This method is only available after converting binary images to array with scene.url_to_tiffs(). For insar the file types will be 'cor', 'unw', 'int' and for polsars it will be 'HHHH', 'HHHV', etc.

Downloading whole collections

Uavsar_pytools can now take a collection name and a start and end date and find, download, and process an entire collection of uavsar images. Collection names can be found at campaign list. Once you know your campaign name and the date range you can give the package a working directory along with the name and dates and it will do the rest. For example if you want to download all uavsar images for Grand Mesa, Colorado from November 2019 to April 2020 and wanted to save it to your documents folder you would use:

```python from uavsar_pytools import UavsarCollection

Collection name from the campaign list

col_name = 'Grand Mesa, CO'

Working directory to save files into

workd = '~/Documents/collectionex/'

Optional dates to check between

dates = ('2019-11-01','2020-04-01')

collection = UavsarCollection(collection = colname, workdir = work_d, dates = dates)

Optional keywords: to keep binary files use clean = False, to download incidence angles

with each image use inc = True, for only certain pols use pols = ['VV','HV'].

See docstring of class for full list.

collection.collectiontotiffs() ```

Each image pair found will be placed in its own directory with its Alaska Satellite Facility derived name as the directory name. Unlike for UavsarScene this functionality will automatically delete the downloaded binary and zip files after converting them to tiffs to save space.

UavsarCollection be default will search only for ground projected interferograms. To search for ground projected polsar images use img_type = 'PROJECTED' in the instantiation of the collection.

Finding URLs for your images

The provided jupyter notebook tutorial in the notebooks folder will walk you through generating a bounding box for your area of interest and finding urls through the asf_search api. However if you want a GUI you can also use the vertex website. After drawing a box and selecting UAVSAR from the platform selection pane (circled in red below) you will get a list of search results. Click on the ground projected image you want to download and right click on the download link (circled in orange below). Select copy link and you will have copied your relevant zip url.

Georeferencing SLC images to Ground Range

Note that this will require the extra packages (GDAL) specified in the setup.py. If you need this functionality please pip install using: pip install uavsar_pytools[extra].

Single look complex (SLC) uavsar images and other Uavsar images without a .grd extension may be in radar slant range. This means that in order to view the image in the image in it's correct location you will need to project it to a coordinate system. The geolocate_uavsar function takes an array of lat, long, and heights called a .llh file and projects a uavsar image from radar to ground range. The .llh file is provided with slant range images in both the asf and jpl websites.

from uavsar_pytools.georeference import geolocate_uavsar in_fp = '/change/to/path/to/slc/image.slc ann_fp = '/path/to/annotation/file.ann out_dir = '/directory/to/save/new/image llh_fp = '/path/to/scenename.llh out_fp = geolocate_uavsar(in_fp, ann_fp, out_dir, llh_fp):

The outfp will be the file path to the newly created .tif file in your `outdir`.

Using new DEM to Generate Incidence Angle

The incidence angle file provided with the uavsar images is generated using the SRTM dem. If you want to generate incidence angles using a high resolution dem use the calc_inc_angle function. This will require georeferencing the look vector file and exporting the x,y, and z components of this look vector.

from uavsar_pytools.incidence_angle import calc_inc_angle dem = numpy array or .tif file path of dem resampled to match uavsar. lkv_x = numpy array or .tif file path of x component of look vector file (.lkv) lkv_y = numpy array or .tif file path of y component of look vector file (.lkv) lkv_z = numpy array or .tif file path of z component of look vector file (.lkv) inc_array = calc_inc_angle(dem, lkv_x, lkv_y, lkv_z)

This will return an incidence angle array that you can then save out to disk or test.

Polarimetric Analysis

Polarimetric analysis of SAR images quantifies the scattering properties of objects in the scene using the phase differences between the various polarizations. A common analysis is to decompose these polarization differences into the mean alpha angle, entropy, and anisotropy. A great presentation on these terms and polarimetry is available from Carleton University here. Uavsar_pytools provides functionality to decompose the polsar uavsar images into the mean alpha, alpha 1 angle, entropy, and anisotropy.

``` from uavsar.polsar import HAalpha_decomp

This should point to the directory with all 6 polarization

(VVVV, HVHV, HVVV, HHHV, HHVV, HHHH) and the correct .ann file

or the directory should have tiffs of all 6 polarizations.

in_dir = '/path/to/directory/full/of/polsar.tiff

Will output 4 files to this directory of H, A, alpha1, and mean alpha.

outdir = '/path/to/directory/to/output/HAAlphaentropy HAalphadecomp(indir, out_dir) # use parralel = True to use dask parralelization. ```

Note that this function involves thousands of eigenvalue calculations and may be quite slow (~4 hours on a i7 @ 2.50 GHz for any image with ~74 million valid pixels). Considering putting the above into a python script instead of calling this from a jupyter notebook. This is also a memory intensive operation and has been parralelized on dask. Use parralel = True keyword to use dask.

Need more help?

The notebook folder in this repository has example notebooks for how to utilize this repository or reach out with questions, features, bugs, or anything else.

Owner

  • Name: SnowEx
  • Login: SnowEx
  • Kind: organization

Citation (CITATION.cff)

cff-version: 1.0.0
message: "If you use this software, please cite it as below."
authors:
  - family-names: "Hoppinen"
    given-names: "Zachary"
    orcid: "https://orcid.org/0000-0003-0916-7774"
  - family-names: "Tarricone"
    given-names: "Jack"
title: "uavsar_pytools"
version: 0.7.0
doi: 10.5281/zenodo.6789624
date-released: 2022-05-01
url: "https://github.com/SnowEx/uavsar_pytools"

GitHub Events

Total
  • Watch event: 6
  • Push event: 1
  • Pull request event: 1
  • Fork event: 1
  • Create event: 1
Last Year
  • Watch event: 6
  • Push event: 1
  • Pull request event: 1
  • Fork event: 1
  • Create event: 1

Committers

Last synced: almost 3 years ago

All Time
  • Total Commits: 213
  • Total Committers: 6
  • Avg Commits per committer: 35.5
  • Development Distribution Score (DDS): 0.432
Top Committers
Name Email Commits
Zach Keskinen z****n@g****m 121
Zachary Keskinen 5****n@u****m 58
jacktarricone 5****e@u****m 26
Jack Tarricone j****e@n****u 3
surfix a****m@g****m 3
HP Marshall h****l@b****u 2
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 7 months ago

All Time
  • Total issues: 7
  • Total pull requests: 37
  • Average time to close issues: 16 days
  • Average time to close pull requests: 1 day
  • Total issue authors: 3
  • Total pull request authors: 4
  • Average comments per issue: 1.29
  • Average comments per pull request: 0.08
  • Merged pull requests: 33
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 0
  • Pull requests: 1
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 0
  • Pull request authors: 1
  • Average comments per issue: 0
  • Average comments per pull request: 0.0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • ZachKeskinen (5)
  • jacktarricone (1)
  • Surfix (1)
Pull Request Authors
  • ZachKeskinen (27)
  • jacktarricone (6)
  • ZachHoppinen (3)
  • Surfix (2)
Top Labels
Issue Labels
enhancement (3) bug (2)
Pull Request Labels

Packages

  • Total packages: 1
  • Total downloads:
    • pypi 30 last-month
  • Total dependent packages: 0
  • Total dependent repositories: 1
  • Total versions: 34
  • Total maintainers: 1
pypi.org: uavsar-pytools

Tools to download and convert ground projected UAVSAR images.

  • Versions: 34
  • Dependent Packages: 0
  • Dependent Repositories: 1
  • Downloads: 30 Last month
Rankings
Dependent packages count: 10.1%
Forks count: 11.9%
Average: 15.8%
Stargazers count: 16.6%
Downloads: 18.8%
Dependent repos count: 21.6%
Maintainers (1)
Last synced: 7 months ago

Dependencies

setup.py pypi
environment.yml conda
  • asf_search
  • folium
  • geopandas
  • ipykernel
  • ipywidgets
  • jupyter
  • matplotlib
  • nb_conda_kernels
  • numpy
  • pip
  • progressbar
  • python
  • rasterio
  • requests
  • tqdm