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

Issue with Very Large GeoTIFFs #6

Closed
djpetti opened this issue Aug 24, 2021 · 2 comments
Closed

Issue with Very Large GeoTIFFs #6

djpetti opened this issue Aug 24, 2021 · 2 comments

Comments

@djpetti
Copy link
Contributor

djpetti commented Aug 24, 2021

Describe the bug
I'm working with some really big GeoTIFFs in GRID (>500 MB). I can successfully load the file and define the AOI, but when I try to go to the next step, it crashes:

Traceback (most recent call last):
  File "/home/daniel/grid_venv/lib/python3.8/site-packages/grid/gridGUI.py", line 125, in <lambda>
    lambda: self.showKMeaner())
  File "/home/daniel/grid_venv/lib/python3.8/site-packages/grid/gridGUI.py", line 141, in showKMeaner
    self.updateMainPn(panel=Panels.KMEANER, isNew=isNew)
  File "/home/daniel/grid_venv/lib/python3.8/site-packages/grid/gridGUI.py", line 189, in updateMainPn
    self.pnMain.addWidget(panel.value[1](self.grid))
  File "/home/daniel/grid_venv/lib/python3.8/site-packages/grid/gui/kmeaner.py", line 107, in __init__
    self.initUI()
  File "/home/daniel/grid_venv/lib/python3.8/site-packages/grid/gui/kmeaner.py", line 225, in initUI
    self.change_k()  # initialize kmeans
  File "/home/daniel/grid_venv/lib/python3.8/site-packages/grid/gui/kmeaner.py", line 315, in change_k
    self.auto_cut()
  File "/home/daniel/grid_venv/lib/python3.8/site-packages/grid/gui/kmeaner.py", line 328, in auto_cut
    self.binarizeImgGUI()
  File "/home/daniel/grid_venv/lib/python3.8/site-packages/grid/gui/kmeaner.py", line 288, in binarizeImgGUI
    self.grid.binarizeImg(
  File "/home/daniel/grid_venv/lib/python3.8/site-packages/grid/grid.py", line 169, in binarizeImg
    self.cropImg()
  File "/home/daniel/grid_venv/lib/python3.8/site-packages/grid/grid.py", line 154, in cropImg
    self.imgs.crop(pts)
  File "/home/daniel/grid_venv/lib/python3.8/site-packages/grid/gimage.py", line 161, in crop
    imgCrop, M = cropImg(self.imgs['raw'], pts)
  File "/home/daniel/grid_venv/lib/python3.8/site-packages/grid/lib.py", line 161, in cropImg
    dst = cv2.warpPerspective(img, H, (shape[0], shape[1]))
cv2.error: OpenCV(4.5.3) /tmp/pip-req-build-f51eratu/opencv/modules/imgproc/src/imgwarp.cpp:1724: error: (-215:Assertion failed) dst.cols < SHRT_MAX && dst.rows < SHRT_MAX && src.cols < SHRT_MAX && src.rows < SHRT_MAX in function 'remap'
Aborted (core dumped)

I think this is an inherent limitation in OpenCV, where it can't warp images in which the row/column count doesn't fit in an int16. However, I was wondering if there was some way around it, maybe, for instance, using rasterio to warp? If not, do you have any recommendations for how to process these files? GRID seems like a great tool, but unfortunately, it's not very useful to us if it can't handle our data.

To Reproduce
Steps to reproduce the behavior:

  1. Load a very large TIFF file, one with more than 32767 rows or columns.
  2. Select the AOI
  3. Click "next"

Expected behavior
It should go to the next step.

Desktop (please complete the following information):

  • OS: Ubuntu 12.04
  • Browser: Firefox (not sure why this is relevant...)]
  • Version: 1.2.15
@Poissonfish
Copy link
Owner

Thanks for your report and suggestions. You are right about the inherent limitation in OpenCV, and the workaround I proposed was that GRID will now resize the image to less than 32767 rows/columns before proceeding to the next step, using cv.resize().

Please upgrade GRID to 1.2.16 and see if your issue is gone. Thank you.

James

@djpetti
Copy link
Contributor Author

djpetti commented Aug 26, 2021

Thanks, this seems to have fixed the problem.

@djpetti djpetti closed this as completed Aug 26, 2021
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

2 participants