Skip to main content

Hello, I am trying to write a Python request in order to get values from the Global Land Cover public collection.


I tried to adapt an example found in the documentation of the Sentinel Hub Python package which uses digital elevation model data (Example 5: Other Data Collections)


Example 5: Other Data Collections


evalscript_dem = ‘’’

//VERSION=3

function setup() {

return {

input: n“DEM”],

output:{

id: “default”,

bands: 1,

sampleType: SampleType.FLOAT32

}

}

}


function evaluatePixel(sample) {

return
}


dem_request = SentinelHubRequest(

evalscript=evalscript_dem,

input_data=/

SentinelHubRequest.input_data(

data_collection=DataCollection.DEM,

time_interval=(‘2020-06-12’, ‘2020-06-13’),

)

],

responses=b

SentinelHubRequest.output_response(‘default’, MimeType.TIFF)

],

bbox=betsiboka_bbox,

size=betsiboka_size,

config=config

)


To adapt the evalscript for, I used an example of custom script which uses Global Land Cover data (Global Land Cover discrete classification map visualisation script).


To adapt the request I have an issue. Global Land Cover is a Sentinel Hub public collection (Sentinel Hub Public Collections) but it is not an existing DataCollection in the Sentinel Hub python package (Data collections — Sentinel Hub 3.3.2 documentation) unlike DataCollection.DEM.


I had a look at creating a BYOC collection (Bring Your Own COG) but I do not understand how to define the Global Land Cover public collection (Global Land Cover - Sentinel Hub Public Collections) to be able to use it in a Python request. I also guess that a Public Collection is different from a personal BYOC collection.


Is there a tutorial for the use of Public Collections which are not existing Datacollections in Python request ? Do you have similar examples of requests on Public Collections ?


Many thanks…

Hello


With Sentinel Hub python package you have the option to use exising Datacollections or you can define a new data collection.


In your case, to use Public Collections which are not existing Datacollections, you will need to define a new data collection. See define a new data collection section in the documentation.


Each public collection,for example has Resources details, these are the parameters to define the new data collection , which include a public collection_id, and the access endpoint .


See the example below, how you can define Global Land Cover data collection


Example:


Define a new data collection.


    data_collection= DataCollection.define(
name='Global Land Cover,
api_id='byoc-f0a97620-0e88-4c1f-a1ac-bb388fabdf2c', #Type
catalog_id='f0a97620-0e88-4c1f-a1ac-bb388fabdf2c', # collection_id
service_url='https://creodias.sentinel-hub.com', # End point
is_timeless=False
)

Adapt the request accordingly as you already did. Make sure to specify the data collection you just defined above.


    discrete_classification_evalscript = """
//VERSION=3

// This custom script visualises land cover discrete classification map from global land cover data

function setup() {
return {
input: ["Discrete_Classification_map"],
output: {
bands: 4,
sampleType: "AUTO"
}
}
}

const map = [
[0, 0x282828], // No input data available
[20, 0xffbb22], // Shrubs
[30, 0xffff4c], // Herbaceous vegetation
[40, 0xf096ff], // Cultivated and managed vegetation/agriculture (cropland)
[50, 0xfa0000], // Urban / built up
[60, 0xb4b4b4], // Bare / sparse vegetation
[70, 0xf0f0f0], // Snow and Ice
[80, 0x0032c8], // Permanent water bodies
[90, 0x0096a0], // Herbaceous wetland
[100, 0xfae6a0], // Moss and lichen
[111, 0x58481f], // Closed forest, evergreen needle leaf
[112, 0x009900], // Closed forest, evergreen, broad leaf
[113, 0x70663e], // Closed forest, deciduous needle leaf
[114, 0x00cc00], // Closed forest, deciduous broad leaf
[115, 0x4e751f], // Closed forest, mixed
[116, 0x007800], // Closed forest, unknown
[121, 0x666000], // Open forest, evergreen needle leafs
[122, 0x8db400], // Open forest, evergreen broad leaf
[123, 0x8d7400], // Open forest, deciduous needle leaf
[124, 0xa0dc00], // Open forest, deciduous broad leaf
[125, 0x929900], // Open forest, mixed
[126, 0x648c00], // Open forest, unknown
[200, 0x000080] // Open sea


];

const visualizer = new ColorMapVisualizer(map);

function evaluatePixel(sample) {
return [visualizer.process(sample.Discrete_Classification_map)[0], visualizer.process(sample.Discrete_Classification_map)[1], visualizer.process(sample.Discrete_Classification_map)[2], sample.Discrete_Classification_map !=255];
}
"""
global_land_cover_request = SentinelHubRequest(
evalscript=discrete_classification_evalscript,
input_data=[
SentinelHubRequest.input_data(
data_collection=data_collection,
time_interval=(‘2015-01-01’, ‘2015-01-01’),
)
],
responses=s
SentinelHubRequest.output_response(‘default’, MimeType.TIFF)
],
bbox=betsiboka_bbox,
size=betsiboka_size,
config=config
)

This request should now work.


That said, however, we have recently noticed an instability in the CreoDIAS data storage, where the data is stored, which we have reported to their team and is being worked upon. Until it is solved, this sometimes fails, sorry for the inconvenience


but let us know if you encounter any other problems


Best


Hello, I tried to access Discrete_Classification_map data from “Global Land Cover” for 224x224 pixels with 10m resolution around the Paris Orly Airport (FRANCE) with the following parameters :


orly_coords_wgs = s453240.24671832635, 5395766.548067344, 455480.24671832635, 5398006.548067344]

resolution = 10

bbox_coords = BBox(bbox=orly_coords_wgs, crs=“EPSG:32631”)

bbox_size = bbox_to_dimensions(bbox_coords, resolution=resolution)


I ran the request several times and got the following error each time :


500 Server Error: Internal Server Error for url: https://creodias.sentinel-hub.com/api/v1/process

Server response: “{“error”:{“status”:500,“reason”:“Internal Server Error”,“message”:“Illegal request to https://s3.waw2-1.cloudferro.com/24692723d1c04f819c7f0ea0c1850243:edc-cog-for-ingestion/eodata/CLMS/Global/Vegetation/Global_Land_Cover_COG/E000N60_PROBAV_LC100_global_v3.0.1_2015/E000N60_PROBAV_LC100_global_v3.0.1_2015_base_Discrete_Classification_map_EPSG_4326_COG.tif. HTTP Status: 403”,“code”:“RENDERER_EXCEPTION”}}”


Then I tried to get CLC and datamask data from “CORINE Land Cover” for the same Orly airport area and using the same method to define this other public collection on the same creodias.sentinel-hub.com end point as “Global Land Cover”. The request gave no error message but CLC and datamask are always equal to zero (no data). Finally, I tried with Sentinel-2 L2A 120m Mosaic on the services.sentinel-hub.com end point instead of Creodias and there is no error message but still no data at all. I do not know if these issues have common origin with the error message above for “Global Land Cover” on the creodias.sentinel-hub.com end point.


How can I solve this issue to get “Global Land Cover” data for any area of interest ?


Many thanks…


Hello Phillipe,

apologies also for the late reply,


Unfortunately, since recently creodias.sentinel-hub.com endpoint is not stable, therefore sometimes requests fail with the error 403.

CreoDIAS team are trying to resolve the issue, so until it is solved, we are sorry for the inconviniences.


will update once creodias.sentinel-hub.com is stable


but services.sentinel-hub.com should be working normally. If you can post your request that failed here,

It could be possible that the dates you specified, do not have Sentinel-2 L2A 120m Mosaic data.


Hello @PhilippeM


Just for your information


services.sentinel-hub.com endpoint is now stable and you should now be able to download the data without any errrors


we are sorry for inconvinience


Reply