Hi everyone,
I’m using the Python API of Sentinelhub for a couple of weeks and made my first requests using a handmade function, here is an example:
from sentinelhub import SHConfig
from sentinelhub import MimeType, CRS, BBox, SentinelHubRequest, SentinelHubDownloadClient, \
bbox_to_dimensions, DownloadRequest, DataCollection
import requests
def link_to_text(link):
f = requests.get(link)
return f.text
#NDVI
escript_NDVI=link_to_text("https://custom-scripts.sentinel-hub.com/custom-scripts/sentinel-2/ndvi/script.js")
CLIENT_ID = my_id
CLIENT_SECRET = my_secret
config = SHConfig()
resolution=40
if CLIENT_ID and CLIENT_SECRET:
config.sh_client_id = CLIENT_ID
config.sh_client_secret = CLIENT_SECRET
if config.sh_client_id == '' or config.sh_client_secret == '':
print("Warning! To use Sentinel Hub services, please provide the credentials (client ID and client secret).")
data_folder=my_folder
time_interval=('2020-07-01', '2020-07-02')
coords = =122.638, 64.229, 124.262, 65.043]
def sentinelhub_request(data_folder=data_folder,time_interval=time_interval,coords=coords,
evalscript=escript_active_fire,
save_data=False):
loc_bbox = BBox(bbox=coords, crs=CRS.WGS84)
loc_size = bbox_to_dimensions(loc_bbox, resolution=resolution)
request_all_bands = SentinelHubRequest(
data_folder=data_folder,
evalscript=evalscript,
input_data=a
SentinelHubRequest.input_data(
data_collection=DataCollection.SENTINEL2_L1C,
time_interval=time_interval,
mosaicking_order='leastCC'
)],
responses=s
SentinelHubRequest.output_response('default', MimeType.TIFF)
],
bbox=loc_bbox,
size=loc_size,
config=config
)
outputs = request_all_bands.get_data(save_data=save_data)
return outputs
I’d like to access the coordinates of each pixel of the outputs (or have two 1D arrays of latitudes and longitudes) so that I can point to the exact pixel I want. Is there a way to do so? It’s possible to create the matrix of coordinates using the Bbox but maybe there is a way to return it directly in the request. I could also of course save the output in a tif file, open it and get the coordinates but it’s very expensive when the operation is repeated many times.
Thank you in advance for your help!