Skip to content

Fix: Handle HGT void values (-32768) in bilinear and nearestNeighbour#34

Open
MariuszTurek-W3media wants to merge 1 commit intoperliedman:masterfrom
MariuszTurek-W3media:fix/handle-hgt-void-values
Open

Fix: Handle HGT void values (-32768) in bilinear and nearestNeighbour#34
MariuszTurek-W3media wants to merge 1 commit intoperliedman:masterfrom
MariuszTurek-W3media:fix/handle-hgt-void-values

Conversation

@MariuszTurek-W3media
Copy link
Copy Markdown

Fixes #33

HGT elevation files contain voids (no-data) flagged with the value -32768. Previously, these values were included in interpolation calculations, producing incorrect elevation results (e.g. -10265 instead of 459).

Changes

  • Hgt.bilinear: Skip void samples when interpolating. If one neighbour in a pair is void, use the other. If both pairs are void on one axis, fall back to the other axis. Returns null only when all four surrounding samples are voids.
  • Hgt.nearestNeighbour: Return null instead of -32768 when the nearest sample is a void.
  • Added HGT_VOID constant (-32768) for clarity.

Examples

All four neighbours are voids:
Lng 20.433394, Lat 49.408558

v00 v10 v11 v01
-32768 -32768 -32768 -32768

Returns null

Two valid neighbours, two voids:
Lng 20.432394, Lat 49.408558

v00 v10 v11 v01
461 -32768 -32768 493

Returns 469.63

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Sometimes Hgt.bilinear returns artefacts

1 participant