From bcfd5a5866e3980863a04864598bb92f1d6a5d25 Mon Sep 17 00:00:00 2001 From: "Ryan M. Carlson" Date: Mon, 4 Jan 2021 17:25:06 -0600 Subject: [PATCH 1/4] File to create list of granules intersecting a bounding box for Earthdata Search application --- gedi/gediFinder.py | 78 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 gedi/gediFinder.py diff --git a/gedi/gediFinder.py b/gedi/gediFinder.py new file mode 100644 index 0000000..913d8e8 --- /dev/null +++ b/gedi/gediFinder.py @@ -0,0 +1,78 @@ +# -*- coding: utf-8 -*- +"""gediFinder.ipynb + +Automatically generated by Colaboratory. + +Original file is located at + https://colab.research.google.com/drive/1PmKDBLkBxVhf1nrORDspAnqKCb7fkeMt + +# GEDI Finder script + +This script is meant to create a GediFinder URL and get the corresponding list of granules within a user-defined bounding box. This list can then be used in the Earthdata Search Tool to pull data from within a bounding box. +""" + +# Import necessary packages + +# Use requests package to retreive list of files from GEDI Finder URL +import requests + +"""## Define bounding box and other variables + +### Bounding box variables +""" + +# Pacific Northwest bbox +ul_lat = 44.75 +lr_lat = 44.25 +ul_lon = -122.25 +lr_lon = -122.75 + +"""### Constant values""" + +# Server url for LP DAAC which stores GEDI data +lpdaac = 'https://lpdaacsvc.cr.usgs.gov/services/gedifinder' + +# Different levels of GEDI data currently available to the public +productLevel1B = 'GEDI01_B' +productLevel2A = 'GEDI02_A' +productLevel2B = 'GEDI02_B' + +# Image verison number +version = '001' + +# Create bounding box string for url +bbox = ','.join(map(str, [ul_lat, ul_lon, lr_lat, lr_lon])) + +# Define output type of url call +output = 'json' + +"""## Join elements of GediFinder URL""" + +# Join together components of url +urlList = [ + 'product=%s' % (productLevel1B), + 'version=%s' % (version), + 'bbox=[%s]' % (bbox), + 'output=%s' % (output) +] + +url = '?'.join([lpdaac, '&'.join(urlList)]) + +"""## Get list of granules""" + +# Making a GET request +response = requests.get(url) + +# Verify a successful request call +if response: + print('Success!') + granulesList = response.json()['data'] # Pull data from response +else: + print('An error has occurred.') + +# Strip extra information away from granule file names +stripped_granulesList = [s[-49:] for s in granulesList] + +# Join list of granules and print list to copy and paste into Earthdata Search +# Use copy icon at end of output to quickly copy all granule names +','.join(stripped_granulesList) From 9335ee30128f642ab887d57abb040b3778e1026f Mon Sep 17 00:00:00 2001 From: Ryan Carlson <60898723+rcarlson89@users.noreply.github.com> Date: Fri, 22 Jan 2021 11:53:39 -0600 Subject: [PATCH 2/4] Update gedi/gediFinder.py Co-authored-by: Connor Richards <35785310+crich011@users.noreply.github.com> --- gedi/gediFinder.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gedi/gediFinder.py b/gedi/gediFinder.py index 913d8e8..15e571d 100644 --- a/gedi/gediFinder.py +++ b/gedi/gediFinder.py @@ -56,7 +56,7 @@ 'output=%s' % (output) ] -url = '?'.join([lpdaac, '&'.join(urlList)]) +url = lpdaac + "?" + '&'.join(urlList) """## Get list of granules""" From a0360e3deaf3f7aa18240357a0d5747932b1ccc1 Mon Sep 17 00:00:00 2001 From: Ryan Carlson <60898723+rcarlson89@users.noreply.github.com> Date: Fri, 22 Jan 2021 11:54:44 -0600 Subject: [PATCH 3/4] Update gedi/gediFinder.py Co-authored-by: Connor Richards <35785310+crich011@users.noreply.github.com> --- gedi/gediFinder.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/gedi/gediFinder.py b/gedi/gediFinder.py index 15e571d..ef2efa9 100644 --- a/gedi/gediFinder.py +++ b/gedi/gediFinder.py @@ -50,10 +50,10 @@ # Join together components of url urlList = [ - 'product=%s' % (productLevel1B), - 'version=%s' % (version), - 'bbox=[%s]' % (bbox), - 'output=%s' % (output) + f'product={productLevel1B}', + f'version={version}', + f'bbox={bbox}', + f'output={output}' ] url = lpdaac + "?" + '&'.join(urlList) From b3512e54fd187ad985fe0ea14a2a32d756e00a06 Mon Sep 17 00:00:00 2001 From: Ryan Carlson <60898723+rcarlson89@users.noreply.github.com> Date: Fri, 22 Jan 2021 11:57:49 -0600 Subject: [PATCH 4/4] Update gediFinder.py --- gedi/gediFinder.py | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/gedi/gediFinder.py b/gedi/gediFinder.py index ef2efa9..1c1813e 100644 --- a/gedi/gediFinder.py +++ b/gedi/gediFinder.py @@ -1,33 +1,24 @@ -# -*- coding: utf-8 -*- -"""gediFinder.ipynb - -Automatically generated by Colaboratory. - -Original file is located at - https://colab.research.google.com/drive/1PmKDBLkBxVhf1nrORDspAnqKCb7fkeMt - -# GEDI Finder script - -This script is meant to create a GediFinder URL and get the corresponding list of granules within a user-defined bounding box. This list can then be used in the Earthdata Search Tool to pull data from within a bounding box. +""" +This script is meant to create a GediFinder URL and get the corresponding list of granules within a +user-defined bounding box. This list can then be used in the Earthdata Search Tool to pull data from +within a bounding box. """ -# Import necessary packages +## Import necessary packages # Use requests package to retreive list of files from GEDI Finder URL import requests -"""## Define bounding box and other variables +## Define bounding box and other variables ### Bounding box variables -""" - # Pacific Northwest bbox ul_lat = 44.75 lr_lat = 44.25 ul_lon = -122.25 lr_lon = -122.75 -"""### Constant values""" +### Constant values # Server url for LP DAAC which stores GEDI data lpdaac = 'https://lpdaacsvc.cr.usgs.gov/services/gedifinder' @@ -46,7 +37,7 @@ # Define output type of url call output = 'json' -"""## Join elements of GediFinder URL""" +## Join elements of GediFinder URL # Join together components of url urlList = [ @@ -58,7 +49,7 @@ url = lpdaac + "?" + '&'.join(urlList) -"""## Get list of granules""" +## Get list of granules # Making a GET request response = requests.get(url)