Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong pixel value returned ? #10

Open
genaray opened this issue May 18, 2022 · 3 comments
Open

Wrong pixel value returned ? #10

genaray opened this issue May 18, 2022 · 3 comments
Labels
bug Something isn't working

Comments

@genaray
Copy link

genaray commented May 18, 2022

So i got it working, it works for the sample geotiff file.

However i wanna use it for my own files... its called "pnv_biome.type_biome00k_c_1km_s0..0cm_2000..2017_v0.1" and contains a value from 0 to 31 for each pixel. Basically natural vegetation and biomes.

When i run the program for my desired geocoordinate, it returns insanly high values. Wrong values. Furhermore, one single "GetElevationAtLAtLong" call generates about 500mb garbage.

Any help here ?

@fabric-io-rodrigues fabric-io-rodrigues added the bug Something isn't working label May 19, 2022
@fabric-io-rodrigues
Copy link
Owner

As I did not see the attached file, I searched and arrived at this base: (https://dataverse.harvard.edu/file.xhtml?persistentId=doi:10.7910/DVN/QQHCIK/W8MYQO&version=4.0), is this correct?

Assuming so, I verified that it is an 8-bit geotiff and I see in the code that this type of data was not handled:

case RasterSampleFormat.UNSIGNED_INTEGER:

case RasterSampleFormat.UNSIGNED_INTEGER:
	if (metadata.BitsPerSample == 32)
	{
		heightValue = BitConverter.ToUInt32(buffer, offset * metadata.BitsPerSample / 8);
	}
	else // metadata.BitsPerSample == 16
	{
		heightValue = BitConverter.ToUInt16(buffer, offset * metadata.BitsPerSample / 8);
	}
	heightValue = heightValue * metadata.Scale + metadata.Offset;
	break;

fabric-io-rodrigues added a commit that referenced this issue May 19, 2022
… pixels don't bring the correct value, needs review

related in #10
@fabric-io-rodrigues
Copy link
Owner

I made a small change, to return the byte value inside the "byteScanline" array.

As a test suppose the following coordinate: 51.0, 8.3 (lat,lon); Which corresponds to the pixel 22596, 4364 (x,y).

nearby at that location indicated on the map.
sample_biome00k_c_1km

The value (after commit) will return 9. However, it doesn't work well with some points that I took randomly, returning 255 (null value).

We need to review this part of the code to support 8bit geotiff well.

fabric-io-rodrigues added a commit that referenced this issue May 21, 2022
@fabric-io-rodrigues
Copy link
Owner

There is no mystery about 8bit support, in my example the points were very close to the border and the code that transforms coordinates into pixels needed an adjustment, which has now been resolved.

@genaray please confirm if this version solves your problem, if so we can close this ticket.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants