locationtech / locationtech/geotrellis

Int32 cells interpreted as float32 cells

Open
#3,377 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement question
Dominant language
Scala
Stars
1.4k
Forks
360
Avg merge
6h 57m
Merged PRs (30d)
12

Description

Describe the bug

When trying to read geotiffs saved as Uint32 using GdalRasterSource, the tile is interpreted as float32 and all data come back as no data.

To Reproduce

Provide as able:

  • Steps to reproduce the behavior
    Open UInt32 raster using GDALRasterSource and read pixel valiue

  • Inputs

Presigned link to input file (expires April 15, happy to update link if required).
This file is saved using datatype=UInt32 and nbits=17

https://gfw-data-lake.s3.amazonaws.com/idn_forest_area/v201709/raster/epsg-4326/10/40000/type/gdal-geotiff/10N_110E.tif?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAV3FRM4Z6FWH7NCUZ/20210408/us-east-1/s3/aws4_request&X-Amz-Date=20210408T202851Z&X-Amz-Expires=604800&X-Amz-SignedHeaders=host&X-Amz-Signature=e5dfee2ab0a845b833a0411c4062d3a2c06f7c50095241d2595d9289940ba2c4

Same file but using datatype=UInt32 and nbits=32 (same result)

https://gfw-data-lake.s3.amazonaws.com/idn_forest_area/v201709/raster/epsg-4326/10/40000/type/geotiff/10N_110E.tif?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAV3FRM4Z6FWH7NCUZ/20210408/us-east-1/s3/aws4_request&X-Amz-Date=20210408T203058Z&X-Amz-Expires=604800&X-Amz-SignedHeaders=host&X-Amz-Signature=763389297b6cf4574f86610a86903a379cf6a3cc186413f425eb720a81857908

  • Actual output
    Float32 tile, all pixel values are no-data (see screenshot)

  • Expected output

Uint32 tile with correct pixel values

Expected behavior

Return Uint32 tile with correct pixel values

Screenshots

Annotated screenshot for relevant code section with debugger on.
https://wri-users.s3.amazonaws.com/tmaschler/geotrellis/screenshots/uint32_debug.png

Environment

  • Scala version: 1.12
  • GeoTrellis version: 3.5.1
  • GDAL 3.1.2

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the GdalRasterSource entry point and reproduce the issue with the provided UInt32 GeoTIFF inputs. Trace how the raster datatype becomes Float32, then verify completion when reading the files returns a UInt32 tile with the correct pixel values rather than no-data values.

Written by the indexing model from the issue text.

Assessment

Tech stack
scala
Domain
data
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.