Source

Target

Commits (2)
Showing with 21 additions and 16 deletions
+21 -16
......@@ -9,7 +9,9 @@ import os
from shapely.geometry import Polygon
import urllib.request
def fetch(shp, output_fld, product='cop-dem-glo-30'):
def fetch(shp, output_fld, product='cop-dem-glo-30', auth=None):
if auth is not None:
os.environ['PC_SDK_SUBSCRIPTION_KEY'] = auth
bbox, i_bbox, shp_srs = get_query_bbox(shp, return_all=True)
api = Client.open('https://planetarycomputer.microsoft.com/api/stac/v1', modifier=PC.sign_inplace)
res = api.search(collections=product, bbox=bbox)
......
......@@ -8,8 +8,10 @@ from shapely.geometry import Polygon
import rasterio.mask
import os
def fetch(shp, dt, out_fld, band_list=None):
def fetch(shp, dt, out_fld, auth=None, band_list=None):
if auth is not None:
os.environ['PC_SDK_SUBSCRIPTION_KEY'] = auth
bbox, i_bbox, shp_srs = get_query_bbox(shp, return_all=True)
api = Client.open('https://planetarycomputer.microsoft.com/api/stac/v1', modifier=PC.sign_inplace)
res = api.search(collections="landsat-c2-l2", bbox=bbox, datetime=dt)
......
......@@ -8,10 +8,12 @@ from pyproj import Transformer as T
from shapely.geometry import Polygon
import tqdm
def fetch(shp, dt, output_fld, band_list=None):
def fetch(shp, dt, output_fld, auth=None, band_list=None):
bbox, i_bbox, shp_srs = get_query_bbox(shp, return_all=True)
if auth is not None:
os.environ['PC_SDK_SUBSCRIPTION_KEY'] = auth
api = Client.open('https://planetarycomputer.microsoft.com/api/stac/v1', modifier=PC.sign_inplace)
res = api.search(collections="sentinel-2-l2a", bbox=bbox, datetime=dt)
lst = ['B02','B03','B04','B05','B06','B07','B08','B8A','B11','B12','SCL']
......
......@@ -14,6 +14,7 @@ from osgeo import osr
import datetime
import uuid
import shutil
import errno
from Common.geotools import get_query_bbox, check_extent_overlap
from Common.geometry import get_displacements_to_ref, get_clearest_central_image
......@@ -282,18 +283,14 @@ class S2TheiaTilePipeline:
ftc = glob.glob(os.path.join(img, p))
ok = ok and len(ftc) > 0
if not ok:
try:
raise FileNotFoundError
except:
print('Found a missing file : {}'.format(ftc))
raise FileNotFoundError(errno.ENOENT, os.strerror(errno.ENOENT), os.path.join(img, p))
for p in self.PTRN_msk:
ftc = glob.glob(os.path.join(img, p))
ok = ok and len(ftc) > 0
if not ok:
try:
raise FileNotFoundError
except:
print('Found a missing file : {}'.format(ftc))
raise FileNotFoundError(errno.ENOENT, os.strerror(errno.ENOENT), os.path.join(img, p))
return ok
def get_file(self, img, ptrn):
......
import os.path
import OBIA.segmentation
import VHR.vhrbase
from TimeSeries import s2theia, s2planetary, s1base, s1planetary, planet_mosaics
from TimeSeries import s2theia, s2planetary, s1base, s1planetary, planet_mosaics, landsat_planetary
from Common import demtools
def run_segmentation(img, threshold, cw, sw , out_seg,
......@@ -84,7 +84,7 @@ def preprocess_s1(in_fld, roi, out_fld, dem_fld=None, geoid=None, direction=None
return s1.write_outputs(out_fld)
def fetch(imagery, shp, out_fld, dt=None, auth=None, only_tiles=None):
assert(imagery in ['s2theia', 's2planetary', 's1grd', 's1rtc', 'planetmosaics', 'cop-dem-glo-30', 'nasadem'])
assert(imagery in ['s2theia', 's2planetary', 's1grd', 's1rtc', 'planetmosaics', 'cop-dem-glo-30', 'nasadem', 'landsatplanetary'])
if imagery not in ['s2planetary', 'cop-dem-glo-30', 'nasadem'] and auth is None:
raise ValueError("Please provide authentication information.")
if imagery not in ['cop-dem-glo-30', 'nasadem'] and dt is None:
......@@ -93,7 +93,7 @@ def fetch(imagery, shp, out_fld, dt=None, auth=None, only_tiles=None):
#temporarily switch to eodag since theia_picker is unusable
s2theia.fetch_eodag(shp, dt, out_fld, auth, only_tiles.split(';'))
elif imagery == 's2planetary':
s2planetary.fetch(shp, dt, out_fld)
s2planetary.fetch(shp, dt, out_fld, auth)
elif imagery == 's1grd':
s1base.fetch(shp, dt, out_fld, auth)
elif imagery == 's1rtc':
......@@ -101,5 +101,7 @@ def fetch(imagery, shp, out_fld, dt=None, auth=None, only_tiles=None):
elif imagery == 'planetmosaics':
planet_mosaics.fetch(shp, dt, out_fld, auth)
elif imagery in ['cop-dem-glo-30', 'nasadem']:
demtools.fetch(shp, out_fld, product=imagery)
demtools.fetch(shp, out_fld, product=imagery, auth=auth)
elif imagery == 'landsatplanetary':
landsat_planetary.fetch(shp, dt, out_fld, auth)
return