ajnisbet / opentopodata

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

Many `null` elevations returned #46

Closed 0xCoto closed 3 years ago

0xCoto commented 3 years ago

Certain queries to the API return a lot of null elevations, e.g.:

https://api.opentopodata.org/v1/eudem25m?locations=37.91004381769315,20.418209430289558|37.91004381769315,20.42820943028956|37.91004381769315,20.43820943028956|37.91004381769315,20.448209430289563|37.91004381769315,20.458209430289564|37.91004381769315,20.468209430289566|37.91004381769315,20.478209430289567|37.91004381769315,20.48820943028957|37.91004381769315,20.49820943028957|37.91004381769315,20.508209430289572|37.91004381769315,20.518209430289573|37.91004381769315,20.528209430289575|37.91004381769315,20.538209430289577|37.91004381769315,20.548209430289578|37.91004381769315,20.55820943028958|37.91004381769315,20.56820943028958|37.91004381769315,20.578209430289583|37.91004381769315,20.588209430289584|37.91004381769315,20.598209430289586|37.91004381769315,20.608209430289588|37.91004381769315,20.61820943028959|37.91004381769315,20.62820943028959|37.91004381769315,20.638209430289592|37.91004381769315,20.648209430289594|37.91004381769315,20.658209430289595|37.91004381769315,20.668209430289597|37.91004381769315,20.6782094302896|37.91004381769315,20.6882094302896|37.91004381769315,20.6982094302896|37.91004381769315,20.708209430289603|37.91004381769315,20.718209430289605|37.91004381769315,20.728209430289606|37.91004381769315,20.738209430289608|37.91004381769315,20.74820943028961|37.91004381769315,20.75820943028961|37.91004381769315,20.768209430289613|37.91004381769315,20.778209430289614|37.91004381769315,20.788209430289616|37.91004381769315,20.798209430289617|37.91004381769315,20.80820943028962|37.91004381769315,20.81820943028962|37.91004381769315,20.828209430289622|37.91004381769315,20.838209430289623|37.91004381769315,20.848209430289625|37.91004381769315,20.858209430289627|37.91004381769315,20.868209430289628|37.91004381769315,20.87820943028963|37.91004381769315,20.88820943028963|37.91004381769315,20.898209430289633|37.92004381769315,20.408209430289556|37.92004381769315,20.418209430289558|37.92004381769315,20.42820943028956|37.92004381769315,20.43820943028956|37.92004381769315,20.448209430289563|37.92004381769315,20.458209430289564|37.92004381769315,20.468209430289566|37.92004381769315,20.478209430289567|37.92004381769315,20.48820943028957|37.92004381769315,20.49820943028957|37.92004381769315,20.508209430289572|37.92004381769315,20.518209430289573|37.92004381769315,20.528209430289575|37.92004381769315,20.538209430289577|37.92004381769315,20.548209430289578|37.92004381769315,20.55820943028958|37.92004381769315,20.56820943028958|37.92004381769315,20.578209430289583|37.92004381769315,20.588209430289584|37.92004381769315,20.598209430289586|37.92004381769315,20.608209430289588|37.92004381769315,20.61820943028959|37.92004381769315,20.62820943028959|37.92004381769315,20.638209430289592|37.92004381769315,20.648209430289594|37.92004381769315,20.658209430289595|37.92004381769315,20.668209430289597|37.92004381769315,20.6782094302896|37.92004381769315,20.6882094302896|37.92004381769315,20.6982094302896|37.92004381769315,20.708209430289603|37.92004381769315,20.718209430289605|37.92004381769315,20.728209430289606|37.92004381769315,20.738209430289608|37.92004381769315,20.74820943028961|37.92004381769315,20.75820943028961|37.92004381769315,20.768209430289613|37.92004381769315,20.778209430289614|37.92004381769315,20.788209430289616|37.92004381769315,20.798209430289617|37.92004381769315,20.80820943028962|37.92004381769315,20.81820943028962|37.92004381769315,20.828209430289622|37.92004381769315,20.838209430289623|37.92004381769315,20.848209430289625|37.92004381769315,20.858209430289627|37.92004381769315,20.868209430289628|37.92004381769315,20.87820943028963|37.92004381769315,20.88820943028963|37.92004381769315,20.898209430289633|37.93004381769315,20.408209430289556

Why is that?

Thanks a lot in advance, really loving this API!

janusw commented 3 years ago

RTFM ;)

See https://www.opentopodata.org/datasets/eudem/ (section Coastline):

EU-DEM uses NODATA values for elevations over seas and oceans, where both ASTER and SRTM assign these areas an elevation of 0m

Your first location (37.91004381769315,20.418209430289558) is definitely an ocean point (did not check the others).

So, whenever you get a null value from EU-DEM, you can assume that it is an ocean point and assign an elevation of zero.

ajnisbet commented 3 years ago

Yeah that comes from the dataset.

Elevation datasets have a few different options for points in the water. Some (like EUDEM) have null values. Some (like Mapzen) include bathymetry (ocean depth). And some (like srtm) have a 0 elevation value for oceans.

If you would like non-null values over water you could just replace them with 0 in your application code. Or if you would like EU-DEM values for land and ocean depth for ocean you can stack datasets in Open Topo Data like this: https://api.opentopodata.org/v1/eudem25m,emod2018?locations=...

I'll close this issue as it's not a problem with the API, but let me know what you're looking to achieve and I can suggest some other options.

0xCoto commented 3 years ago

Thanks for the responses!

@janusw - I knew about the null results implying ocean points (and in fact I had already been handling this programmatically as @ajnisbet suggested), but I'm surprised I didn't check some of the null points myself on e.g. google maps to see where exactly they fall - sounds obvious now. :)

The problem ended up being with the way I generated my data points. I probably set too low resolution (wide angle steps), and it ended up hitting into ocean spots more often than I envisioned. Thanks for pointing this out!


@ajnisbet:

Or if you would like EU-DEM values for land and ocean depth for ocean you can stack datasets in Open Topo Data like this: https://api.opentopodata.org/v1/eudem25m,emod2018?locations=...

I didn't know about multi-dataset syntax. Is this described on the API docs somewhere? Although I'm not interested in ocean-depth data, it would be quite useful if the API could automatically return the elevation value depending on the coordinates, based on the highest-resolution dataset available for that position. Perhaps something like /auto?locations=lat,long could work? Not sure if there are any obvious problems with that, but I'm planning to implement this into my own application anyway.

ajnisbet commented 3 years ago

Multiple datasets are mentioned in the API docs, and there's more info here: https://www.opentopodata.org/notes/multiple-datasets/ but it's not super well publicised: I find it hard to keep a balance between keeping the docs simple and going into detail about everything!

Datasets are tried in order so if you order them from highest to lowest resolution that should do what you mentioned I think.