def __init__( self, cache_image_expiration_time: int = 3600, **image_params, ): self._gbdx = gbdxtools.Interface() self._image_params = image_params self._catalog_image_cache = expiringdict.ExpiringDict( max_len=1000, max_age_seconds=cache_image_expiration_time, ) self._not_in_catalog_image_cache = set()
def test_init_host(monkeypatch): test_host = 'test.mydomain.com' def session(config_file): return None monkeypatch.setattr(gbdxtools.interface.gbdx_auth, 'get_session', session) gbdx = gbdxtools.Interface(host=test_host) assert isinstance(gbdx, gbdxtools.Interface) assert gbdx.root_url == 'https://%s' % test_host assert gbdx.catalog.base_url == 'https://%s/catalog/v1' % test_host assert gbdx.ordering.base_url == 'https://%s/orders/v2' % test_host assert gbdx.idaho.base_url == 'https://%s/catalog/v1' % test_host assert gbdx.s3.base_url == 'https://%s/s3creds/v1' % test_host assert gbdx.task_registry._base_url == 'https://%s/workflows/v1/tasks' % test_host assert gbdx.workflow.base_url == 'https://%s/workflows/v1' % test_host assert gbdx.workflow.workflows_url == 'https://%s/workflows/v1/workflows' % test_host
def __init__(self, satellites=GBDX_SATELLITES, types=None, max_cloud_cover=100, min_off_nadir_angle=0, max_off_nadir_angle=60, start_date=None, end_date=None, filters=None): self.satellites = satellites self.types = types self.max_cloud_cover = max_cloud_cover self.min_off_nadir_angle = min_off_nadir_angle self.max_off_nadir_angle = max_off_nadir_angle self.start_date = start_date self.end_date = end_date self.filters = filters or [] self.gbdx = gbdxtools.Interface()
def main(task_json): gbdx = gbdxtools.Interface() # register the task on gbdx # confirm it exists if os.path.exists(task_json): gbdx.task_registry.register(json_filename=task_json) else: raise Exception("File does not exist: {}".format(task_json)) # extract the task name from the json with open(task_json, 'r') as f: d = json.load(f) task_name = ':'.join([str(d['name']), str(d['version'])]) # confirm it got added print('waiting on task registration within gbdx') while task_name not in gbdx.task_registry.list(): print('.') print('task successfully registered')
def test_init(): gi = gbdxtools.Interface(gbdx_connection=mock_gbdx_session) assert isinstance(gi, gbdxtools.Interface)
import pandas as pd from pprint import pprint import pyproj import urllib.request from functools import partial import requests import shapely as sp from shapely import wkb from shapely.geometry import mapping, shape from shapely.geometry.polygon import LinearRing, Polygon from shapely.ops import transform, unary_union import time #Open a session using the Authentication files (~/.gbdx-config) gbdx_auth.get_session() gbdx = gbdxtools.Interface() def wkb_to_wkt(poly): """ Open data using shapely and take it from binary to a valid Python geometry. """ poly_sp = wkb.loads(poly, hex=True) unary_poly = unary_union(poly_sp) return unary_poly def url_geojson_to_wkt(url): """ Create a list of wkt geometries from a geojson stored in an specific URL. """
def __init__(self): self.gbdx_interface = gbdxtools.Interface()