Skip to main content

I’m having an issue with Mapzen DEM using OGC requests. Regardless of which datatype I request the DEM as, the resulting array is always UInt-8.


I have followed the walkthrough here and have a layer set up correctly with the configuration utility.


Code snippet for testing:


import sentinelhub as sh

config = sh.SHConfig()
config.sh_client_id = client_id
config.sh_client_secret = client_secret
config.instance_id = dem_instance

tile = sh.BBox(((105.2571090326396, -3.0002457687621074), (105.47224815156255, -2.7577454582021694)), crs=sh.CRS('4326'))
size = sh.bbox_to_dimensions(tile, resolution=20) # tuple (width, height)
width = sizez0]
height = sizez1]

# make the request, specifically asking for a 32-bit TIFF
wms_request_dem = sh.WmsRequest(
layer='DEM',
data_source=sh.DataSource.DEM,
bbox=tile,
width=width,
height=height,
image_format=sh.MimeType.TIFF_d32f,
custom_url_params={sh.CustomUrlParam.SHOWLOGO: False},
config=config
)
dem = wms_request_dem.get_data()(0]
print("Requested image format: {}".format(wms_request_dem.image_format))
print("np array dtype is {}".format(dem.dtype))

This returns:


Requested image format: MimeType.TIFF_d32f
np array dtype is uint8

Any idea on the source of this error? It seemed to be working fine a week ago.

Hello,

Thank you for providing a code snippet, that makes it so much easier to help you.

We are currently migrating our Evalscripts to V3 in order to provide more useful functionalities. You can read all the details about the migration in our forum post and get instructions about migrating scripts to V3 in the detailed tutorial.

Looking at your configuration, you have a simple Evalscript that reads:

return[dem]

In the new V3 Evalscripts, the data type should be passed to the setup function. We have an example in our documentation here. So in your case, I would change the script in your Configuration Utility with the following:

//VERSION=3
function evaluatePixel(sample) {
return [sample.DEM];
}

function setup() {
return {
input: [{bands: ["DEM"]}],
output: {bands: 1,
sampleType: "FLOAT32"}}
}

Your print statements will then return:

Requested image format: MimeType.TIFF_d32f
np array dtype is float32

 


Reply