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

Get incorrect value when the type of the tif is float32 #7

Open
IBAS0742 opened this issue Oct 19, 2021 · 0 comments
Open

Get incorrect value when the type of the tif is float32 #7

IBAS0742 opened this issue Oct 19, 2021 · 0 comments

Comments

@IBAS0742
Copy link

https://github.com/jblindsay/go-spatial/blob/master/geospatialfiles/raster/geotiff/geotiff.go#L851

I find a bug, when I try to read a tif and only import the paht of 'geospatialfiles/raster/geotiff".
The blockWidth's value is 128, and my tif files size is 15*12, so I get an error value from the 2nd row.

I change the code and get all correct value, I think the code of decode of float64 maybe wrong also.

case 32:
  for y := ymin; y < ymax; y++ {
	  for x := xmin; x < xmax; x++ {
		  if g.off <= len(g.buf) {
			  bits := g.ByteOrder.Uint32(g.buf[g.off : g.off+4])
			  float := math.Float32frombits(bits)
			  i := y*width + x
			  g.Data[i] = float64(float)
			  g.off += 4
		  }
	  }
	  if xmax * 4 < blockWidth {
		  g.off = g.off - xmax * 4 + blockWidth * 4
	  }
  }

My tif file can be found here

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

No branches or pull requests

1 participant