Weird line in GeoTIFF metadata parsing
galarlo opened this issue ยท 7 comments
Hello,
I've noticed something weird in GeoTiff.ParseMetadata
. I'm not sure whether it's a bug or if I missed something.
In the following line
double pixelSizeY = BitConverter.ToDouble(modelPixelScale, 8) * -1;
Why is the value multiplied by -1
?
Hi @galarlo.
Well imagine a GeoTIFF in lat/lon coordinates.
When X1>X2, you have Lon1>Lon2
But for Y : when Y1>Y2, then Lat1<Lat2, because latitude decreases when Y increases in that coord system.
And yes it's a bit hacky there, probaly needs to be read from GeoTiff tags (where ?) or set via parameters.
Huge thanks for the fast reply!! ๐
However, one thing still doesn't make sense for me - this line in GeoTiff.GetHeightMap()
:
double latitude = metadata.DataStartLat + (metadata.pixelSizeY * y);
Doesn't it mean that these latitudes will be smaller than DataStartLat
(i.e. outside the bounds of the tiff)?
(In fact, I'm pretty sure that's what I see when I run my code)
You may be right. Which GeoTiff file are you using ?
I had some hard time handling different registration modes (ie cell/grid, as explained here https://www.researchgate.net/figure/Differences-between-grid-registration-and-cell-registration-Grid-registered-grids-have_fig13_228077300)
I'll test again to see if everything is ok.
xfischer, excellent explanation.
A while ago, when I was looking for this one about GeoTiff, I found this blog that commented on Grid x Pixel, in the example the author exemplifies with -180, 90 pixel that corresponds to the coordinate -179.99166, 89.99166.
Source: http://build-failed.blogspot.com/2014/12/processing-geotiff-files-in-net-without.html
Credits to: @pmcxs
And I would like to thank you for your great work at DEM.Net!
Still, @galarlo, if you have an issue, please provide your GeoTIFF so that I can run some tests and confirm your hypothesis.
Please feel free to reopen the issue if needed