Skip to main content

Hello,


I am using catalog API to search for S1 data over a period of a month for an area. I am using the date time returned from the search to form a request to process api with the same aoi. I noticed that catalog API returns dates-time for partial aoi coverage as well. Is there a way to ensure it gives me only acquisition dates when we have full area coverage? Here is part of my code:


def search_catalog(config_file_name, sh_config):
catalog = SentinelHubCatalog(config=sh_config)
aoi = read_geojson(aoi.geojson)
geom = Geometry(read_geojson(data['geojson_file']), crs=CRS.WGS84)
query = {'polarization': {'eq': 'DV'}}
return catalog.search(DataCollection.SENTINEL1_IW, geometry=geom,
time=(data['start_date'], data['end_date']),
query=query)

def request_data(start, end, aoi, config, storage_location, eval_script):
resolution = 20
bbox = BBox(bbox=aoi.geometry, crs=CRS.WGS84)
size = bbox_to_dimensions(bbox, resolution=resolution)

request_all_bands = SentinelHubRequest(
data_folder=storage_location,
evalscript=eval_script,
input_data=[
SentinelHubRequest.input_data(
data_collection=DataCollection.SENTINEL1_IW,
time_interval=(start, end),
mosaicking_order='mostRecent',
other_args={
"processing": {"orthorectify": True, "backCoeff": "GAMMA0_TERRAIN", "upsampling": "NEAREST"}}
)],
responses=[
SentinelHubRequest.output_response('default', MimeType.TIFF)
],
geometry=aoi,
size=size,
config=config
)
return request_all_bands

catalog_response = search_catalog(config_file_name, sh_config)

for a in catalog_response:
start_date = datetime.strptime(a['properties']['datetime'], '%Y-%m-%dT%H:%M:%SZ').date()
end_date = start_date + timedelta(days=1)
print(a['id'], a['properties']['sat:orbit_state'], a['properties']['datetime'])
# To ensure you are using the latest data for any given date
storage_location = 'data/' + str(data['location_id']) + '_' + data['location_name'] + '/' + \
datetime.strptime(a['properties']['datetime'], '%Y-%m-%dT%H:%M:%SZ').strftime('%Y%m%d_%H%M%S')

# If you want to save the data locally, this save_data flag in the input_config.json needs to be True
if data['save_data'] == 1:
print('Sending request for location {} and date {} and {}, the data will be stored at {}'.format(
data['location_name'], start_date, end_date, storage_location))
response = request_data(start_date, end_date, sh.Geometry(aoi, crs=sh.CRS.WGS84), sh_config,
storage_location=storage_location, eval_script=read_eval(data['eval_script']))
d = response.get_data(save_data=True)[0]
else:
print('Sending request for location {} and date {} and {}'.format(data['location_name'], start_date,
end_date))
response = request_data(start_date, end_date, sh.Geometry(aoi, crs=sh.CRS.WGS84), sh_config,
storage_location=storage_location, eval_script=read_eval(data['eval_script']))
d = response.get_data(save_data=False)[0]
d = 0

I want to make sure we only send requests when there is data for the entire AOI for that day. Even if that data is split across multiple tiles that is fine.


For example, catalog API tells me there is data available for 2021_05_20 and 2021_05_27. But the data on 2021-05-20 is partial as shown in the image
image


But the data for 2021-05-27 has the whole AOI

There is no feature like this built-in, but Catalogue results come with coverage polygon (in GeoJSON), so you can easily make an intersection to see if it is fully within or not.


Reply