ajnisbet / opentopodata

Open alternative to the Google Elevation API!
https://www.opentopodata.org
MIT License
327 stars 71 forks source link

nodata_value not working properly #95

Closed guillemc23 closed 7 months ago

guillemc23 commented 7 months ago

I am trying to set up a nodata_value, which according to the docs should be used like this: https://api.opentopodata.org/v1/aster30m?locations=0,0&nodata_value=-9999

I'm using a dataset that does not have bathymetry data, so testing at 0,0 should return no data since it's in the middle of the Atlantic ocean. The result presents null in the elevation, but it should be replaced by the nodata_value:

{
  "results": [
    {
      "dataset": "aster30m",
      "elevation": null,
      "location": {
        "lat": 0,
        "lng": 0
      }
    }
  ],
  "status": "OK"
}
ajnisbet commented 7 months ago

Ah yes, this could be explained better in the documentation.

When querying a location outside the bounds of any dataset file, null is always returned. The ASTER dataset doesn't include a file that covers the location (0,0), resulting in a null result.

The nodata_value is only used when querying a point that is covered by a .tif file in the dataset, but the value at that location is NODATA. Because Aster uses a value of 0 for points covering the ocean, there are no NODATA pixels in the ASTER dataset, so the nodata_value setting will have no impact on this data source.

So this setting is only for datasets that have NODATA (aka blank) pixels in their files, commonly to designate water or the edge of the dataset bounds.


Does that make sense??

guillemc23 commented 7 months ago

Okay, yes, it makes sense. The ASTER dataset contains zeroes for values near the coast and null for points further away. It's nice to know to be able to handle it properly 😄

Thank you @ajnisbet!