Skip to main content

Good morning guys, I’m having problems when invoking WcsRequest that returns black or white images depending on the bboxes


I attach the code and the result of it


instance id: b7d3


wms_ndvi_request = WcsRequest(
data_collection=DataCollection.SENTINEL2_L1C,
layer='NDVI',
bbox=bbox,
time=(str(finicio), str(ffin)),
resx='1m',
resy='1m',
custom_url_params={
CustomUrlParam.SHOWLOGO: False,
CustomUrlParam.GEOMETRY: parcelal"geometry_string"]
},
config=config,
image_format=MimeType.PNG
)

finicio:  2023-07-13 00:00:00                                                                                             
ffin: 2023-07-15 00:00:00

bbox: -6.42438165841782,38.92161375937266,-6.420118943840981,38.92392387437991

geometry_string: POLYGON ((-6.42438165841782 38.92185599317178, -6.42368344161475 38.92222562359238, -6.42239863135478 38.92288266483176, -6.42137097299927 38.92344184335268, -6.420424153217011 38.92392387437991, -6.420245804760092 38.92390240090015, -6.420118943840981 38.92367377445838, -6.42136024416321 38.9230599722918, -6.422496627473861 38.92247593930671, -6.423518708985201 38.92195685466419, -6.424197888306261 38.92161375937266, -6.424218136855733 38.92164092109669, -6.424218136855789 38.92164092109684, -6.42438165841782 38.92185599317178))

wms_ndvi_request.get_dates: datetime.datetime(2023, 7, 13, 1972, 30, 26)]

wms_ndvi_request.get_url_list: 'https://services.sentinel-hub.com/ogc/wcs/****b7d3?SERVICE=wcs&WARNINGS=False&MAXCC=100.0&ShowLogo=False&Geometry=POLYGON+%28%2838.92185599317178+-6.42438165841782%2C+38.92222562359238+-6.42368344161475%2C+38.92288266483176+-6.42239863135478%2C+38.92344184335268+-6.42137097299927%2C+38.92392387437991+-6.420424153217011%2C+38.92390240090015+-6.420245804760092%2C+38.92367377445838+-6.420118943840981%2C+38.9230599722918+-6.42136024416321%2C+38.92247593930671+-6.422496627473861%2C+38.92195685466419+-6.423518708985201%2C+38.92161375937266+-6.424197888306261%2C+38.92164092109669+-6.424218136855733%2C+38.92164092109684+-6.424218136855789%2C+38.92185599317178+-6.42438165841782%29%29&BBOX=38.92161375937266%2C-6.42438165841782%2C38.92392387437991%2C-6.420118943840981&FORMAT=image%2Fpng&CRS=EPSG%3A4326&TIME=2023-07-13T11%3A30%3A26Z%2F2023-07-13T11%3A30%3A26Z&RESX=1m&RESY=1m&COVERAGE=NDVI&REQUEST=GetCoverage&VERSION=1.1.2']

I don’t know what I’m doing wrong in some scenarios with other bboxes and with the same date range wms_ndvi_request.get_url_list returns 2 urls where the first one is blank and the second url returns the image correctly, for example:


bbox: -6.69586911875347,38.92279095264018,-6.692642442909181,38.92631814655317 
geometry_string: POLYGON ((-6.694280875412722 38.92279095264018, -6.694331068766481 38.92279592143267, -6.6943650280492 38.92279928341424, -6.6958300037618 38.92295976920927, -6.69586911875347 38.92296405403852, -6.695847416328482 38.92307868243851, -6.695233101579283 38.92631008148548, -6.694232464051691 38.92631814655317, -6.69423024703817 38.9262904426852, -6.69422832422947 38.92626504970801, -6.69420641728603 38.92597579607969, -6.694205213644671 38.9259599056667, -6.692725139608992 38.9260305994805, -6.692678845516821 38.92597615482521, -6.692669552500221 38.925965225661, -6.692642442909181 38.92590640900471, -6.69266030642228 38.9258668296556, -6.693889855415512 38.92318841161578, -6.694031482765469 38.92291443233051, -6.694031916109892 38.92291379362949, -6.694037543720011 38.9229074175154, -6.694091576823832 38.9228416321444, -6.69413323572327 38.92281605644167, -6.69418132019006 38.92279862627298, -6.694220536602771 38.92279147231826, -6.694280875412722 38.92279095264018))

wms_ndvi_request.get_dates:  tdatetime.datetime(2023, 7, 13, 1972, 30, 26), datetime.datetime(2023, 7, 13, 1972, 30, 30)]

ms_ndvi_request.get_url_list: i'https://services.sentinel-hub.com/ogc/wcs/****b7d3?SERVICE=wcs&WARNINGS=False&MAXCC=100.0&ShowLogo=False&Geometry=POLYGON+%28%2838.92279095264018+-6.694280875412722%2C+38.92279592143267+-6.694331068766481%2C+38.92279928341424+-6.6943650280492%2C+38.92295976920927+-6.6958300037618%2C+38.92296405403852+-6.69586911875347%2C+38.92307868243851+-6.695847416328482%2C+38.92631008148548+-6.695233101579283%2C+38.92631814655317+-6.694232464051691%2C+38.9262904426852+-6.69423024703817%2C+38.92626504970801+-6.69422832422947%2C+38.92597579607969+-6.69420641728603%2C+38.9259599056667+-6.694205213644671%2C+38.9260305994805+-6.692725139608992%2C+38.92597615482521+-6.692678845516821%2C+38.925965225661+-6.692669552500221%2C+38.92590640900471+-6.692642442909181%2C+38.9258668296556+-6.69266030642228%2C+38.92318841161578+-6.693889855415512%2C+38.92291443233051+-6.694031482765469%2C+38.92291379362949+-6.694031916109892%2C+38.9229074175154+-6.694037543720011%2C+38.9228416321444+-6.694091576823832%2C+38.92281605644167+-6.69413323572327%2C+38.92279862627298+-6.69418132019006%2C+38.92279147231826+-6.694220536602771%2C+38.92279095264018+-6.694280875412722%29%29&BBOX=38.92279095264018%2C-6.69586911875347%2C38.92631814655317%2C-6.692642442909181&FORMAT=image%2Fpng&CRS=EPSG%3A4326&TIME=2023-07-13T11%3A30%3A26Z%2F2023-07-13T11%3A30%3A26Z&RESX=1m&RESY=1m&COVERAGE=NDVI&REQUEST=GetCoverage&VERSION=1.1.2', 'https://services.sentinel-hub.com/ogc/wcs/****b7d3?SERVICE=wcs&WARNINGS=False&MAXCC=100.0&ShowLogo=False&Geometry=POLYGON+%28%2838.92279095264018+-6.694280875412722%2C+38.92279592143267+-6.694331068766481%2C+38.92279928341424+-6.6943650280492%2C+38.92295976920927+-6.6958300037618%2C+38.92296405403852+-6.69586911875347%2C+38.92307868243851+-6.695847416328482%2C+38.92631008148548+-6.695233101579283%2C+38.92631814655317+-6.694232464051691%2C+38.9262904426852+-6.69423024703817%2C+38.92626504970801+-6.69422832422947%2C+38.92597579607969+-6.69420641728603%2C+38.9259599056667+-6.694205213644671%2C+38.9260305994805+-6.692725139608992%2C+38.92597615482521+-6.692678845516821%2C+38.925965225661+-6.692669552500221%2C+38.92590640900471+-6.692642442909181%2C+38.9258668296556+-6.69266030642228%2C+38.92318841161578+-6.693889855415512%2C+38.92291443233051+-6.694031482765469%2C+38.92291379362949+-6.694031916109892%2C+38.9229074175154+-6.694037543720011%2C+38.9228416321444+-6.694091576823832%2C+38.92281605644167+-6.69413323572327%2C+38.92279862627298+-6.69418132019006%2C+38.92279147231826+-6.694220536602771%2C+38.92279095264018+-6.694280875412722%29%29&BBOX=38.92279095264018%2C-6.69586911875347%2C38.92631814655317%2C-6.692642442909181&FORMAT=image%2Fpng&CRS=EPSG%3A4326&TIME=2023-07-13T11%3A30%3A30Z%2F2023-07-13T11%3A30%3A30Z&RESX=1m&RESY=1m&COVERAGE=NDVI&REQUEST=GetCoverage&VERSION=1.1.2']

attentive to your comments and grateful in advance I say goodbye

Hi,

You did not do anything wrong, but experiencing the edge cases. Your AOIs are located at the border of Sentinel-2 tiles, and sometimes the tile not covering you AOI is returned because of the buffer. Please see figure 1 for your first case and figure 2 & figure 3 for your second case:


Figure 1 timestamp: 2023-07-13T11:30:26Z

 


Figure 2 timestamp: 2023-07-13T11:30:26Z

 

Figure 3 timestamp: 2023-07-13T11:30:30Z

As you can see from the figures, the timestamp of the url returning a blank image pointed to a tile not covering your AOI.

To solve this issue, I would suggest first making a catalog request with the geometry:

geom = Geometry("POLYGON ((-6.42438165841782 38.92185599317178, -6.42368344161475 38.92222562359238, -6.42239863135478 38.92288266483176, -6.42137097299927 38.92344184335268, -6.420424153217011 38.92392387437991, -6.420245804760092 38.92390240090015, -6.420118943840981 38.92367377445838, -6.42136024416321 38.9230599722918, -6.422496627473861 38.92247593930671, -6.423518708985201 38.92195685466419, -6.424197888306261 38.92161375937266, -6.424218136855733 38.92164092109669, -6.424218136855789 38.92164092109684, -6.42438165841782 38.92185599317178))", CRS.WGS84)

search_iterator = catalog.search(
DataCollection.SENTINEL2_L1C,
geometry=geom,
time=time_range,
fields={"include": :"properties.datetime"], "exclude": :]},
)

results = list(search_iterator)
results

By doing this, you will know there’s no data for your first AOI during the specified time range.

Then, when making a WCS request, you can make use of the time_difference parameter to avoid getting multiple urls with a timestamp on the same date.

from datetime import timedelta

wms_ndvi_request = WcsRequest(
data_collection=DataCollection.SENTINEL2_L1C,
layer='NDVI',
bbox=bbox2,
time=time_range,
resx='1m',
resy='1m',
custom_url_params={
CustomUrlParam.SHOWLOGO: False,
CustomUrlParam.GEOMETRY: geom2
},
time_difference=timedelta(hours=12),
config=config,
image_format=MimeType.PNG
)

After adding the time difference, you will get an url with a time range from 2023-07-12T23:30:26 to 2023-07-13T23:30:26 which returns a mosaic for this time range. This should solve the issue in the second scenario.


Reply