Basic utility functions across ard-workflows.
import pandas as pd

Sedas

For NovaSAR and other Catapult-hosted datasets, me must download from Sedas.

sedas_client[source]

sedas_client()

Log into sedas Test api.

sedas_client()
<sedas_pyapi.sedas_api.SeDASAPI at 0x7fdf22b83890>

should inc. test for env vars...?

And we'll want to find datasets from different Collections, which sedas expects as groups.

sedas_get_collections[source]

sedas_get_collections()

sedas_get_collections()
'Available groups are: Cosmo-SkyMed, SPOT, Pleiades, S1, S2, AIRSAR'

sedas_find_datasets[source]

sedas_find_datasets(wkt, startDate, endDate, collection)

For example for a small area over Oxford we can find...

result = sedas_find_datasets("POLYGON((-1.91 51.81,-1.15 51.81,-1.15 51.50,-1.91 51.50,-1.91 51.81))", 
                             "2000-01-01T00:00:00Z", 
                             "2020-10-27T00:00:00Z",
                             "Pleiades"
                            )
pd.DataFrame(result['products']).head(2)
productId supplierId type satelliteName instrumentName modeName sensorType sensorResolution coordinatesWKT start ... area aoiCoveragePercent usefulAreaPercent cloudCoveragePercent productType latency ql thumbnail vendorSpecific downloadUrl
0 c0ec9a5f12356e87bc910ddbc49dbb76 Pleiades_UKSA396_SO18034616-96-01_DS_PHR1B_201... ARCHIVE Pleiades-1B MS/PAN 0.000 Optical 2.0 POLYGON((-1.654728 51.309517,-1.345414 51.3081... 2018-10-24T11:17:22Z ... 4.825125e+08 1.0 5.0 0.0 L3 Standard https://geobrowser.satapps.org/archiveql/aeweb... https://sedasdm.satapps.org/qls/qlmgr.php?scen... {'property': 'vendorSpecific', 'Filehash': 'cf... https://sedasdm.satapps.org/datamgr/datamgr.ph...
1 94cc7887414be0912de7ca44288f79da Pleiades_UKSA174_SO18034614-74-01_DS_PHR1A_201... ARCHIVE Pleiades-1A MS/PAN 0.000 Optical 2.0 POLYGON((-2.153852 51.603313,-1.841533 51.6033... 2018-09-29T11:10:08Z ... 1.565260e+08 2.0 22.0 0.0 L3 Standard https://geobrowser.satapps.org/archiveql/aeweb... https://sedasdm.satapps.org/qls/qlmgr.php?scen... {'property': 'vendorSpecific', 'Filehash': '4b... https://sedasdm.satapps.org/datamgr/datamgr.ph...

2 rows × 22 columns

sedas_download[source]

sedas_download(sedas_res_dicts, down_dir, sedas=None)

Use product dicts list to download into a dir.

 

sedas_extract[source]

sedas_extract(down_zip, scene_dir)

 

Cloud-Optimised Formatting

convert2cog[source]

convert2cog(img_path, cog_path, band)

Convert gdal raster into COG with default settings. Considering lzw compression. See https://www.cogeo.org/developers-guide.html.

mosaic2cog[source]

mosaic2cog(imgs, out_cog, band)

Mosaic imgs into cog. Usual vrt assumptions.

cogmosaicbands[source]

cogmosaicbands(img_paths, numbands, basename)

Convert bands from img_paths to cog, output basename_band#.tif. Mosaic if >1 img paths.

Object Storage

s3_create_client[source]

s3_create_client(s3_bucket)

Create and set up a connection to S3 :param s3_bucket: :return: the s3 client object.

s3_single_upload[source]

s3_single_upload(in_path, s3_path, s3_bucket)

put a file into S3 from the local file system. :param in_path: a path to a file on the local file system :param s3_path: where in S3 to put the file. :return: None

get_rel_dir_s3_paths[source]

get_rel_dir_s3_paths(local_dir, s3_dir)

returns local path, remote path pair list.

s3_upload_dir[source]

s3_upload_dir(in_dir, s3_bucket, s3_dir)

Upload all items in directory, inc. dir.

s3_list_objects_paths[source]

s3_list_objects_paths(s3_bucket, prefix)

List of paths only returned, not full object responses

s3_list_objects[source]

s3_list_objects(s3_bucket, prefix)

General

clean_up[source]

clean_up(work_dir)

setup_logging[source]

setup_logging()

SNAP

run_snap_command[source]

run_snap_command(command, timeout=2700)

Run a snap command. Internal use.

:param command: the list of arguments to pass to snap :return: None

Export