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

guessing wrong driver for certain values of ROI_PAC raster #4713

Closed
scottstanie opened this issue Oct 27, 2021 · 0 comments
Closed

guessing wrong driver for certain values of ROI_PAC raster #4713

scottstanie opened this issue Oct 27, 2021 · 0 comments
Assignees

Comments

@scottstanie
Copy link
Contributor

Expected behavior and actual behavior.

When saving a ".int" file for the ROI_PAC driver, the values of the raster seem to change gdal's ability to correctly guess the right driver. Large complex numbers fail, maybe by some heuristic that looks like the bytes of another driver. I'm not sure which it is guessing, since all it prints is ERROR 6: Unsupported compression

Steps to reproduce the problem.

$ ipython
Python 3.8.5 (default, Sep  4 2020, 07:30:14)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.18.1 -- An enhanced Interactive Python. Type '?' for help.

In [1]: import numpy as np
# Large complex numbers seem to fail:
In [23]: arr = np.array([2180.8286 +4175.303j , 1256.5812 +2132.886j ,244.31543+2708.4495j, 
 841.01587+2190.2144j,1936.9266 +4414.4624j, 1360.6066 +2391.4644j], dtype=np.complex64)

In [24]: arr.tofile("test_roipac.int")

In [25]: with open("test_roipac.int.rsc", "w") as f:
    ...:     f.write("WIDTH  3\nFILE_LENGTH  2\n")
    ...:

In [26]: !gdalinfo test_roipac.int
ERROR 6: Unsupported compression
gdalinfo failed - unable to open 'test_roipac.int'.

# But the same array, with scaled down numbers, will work
In [27]: (arr / 1000).tofile("test_roipac.int")

In [28]: !gdalinfo test_roipac.int
Driver: ROI_PAC/ROI_PAC raster
Files: test_roipac.int
       test_roipac.int.rsc
Size is 3, 2
Corner Coordinates:
Upper Left  (    0.0,    0.0)
Lower Left  (    0.0,    2.0)
Upper Right (    3.0,    0.0)
Lower Right (    3.0,    2.0)
Center      (    1.5,    1.0)
Band 1 Block=3x1 Type=CFloat32, ColorInterp=Undefined

Operating system

Centos 7

GDAL version and provenance

Installed through conda:

In [29]: !gdalinfo --version
GDAL 3.2.1, released 2020/12/29
@rouault rouault self-assigned this Oct 27, 2021
rouault added a commit that referenced this issue Oct 27, 2021
BMP: harden identify checks to avoid misidentification of other datasets (fixes #4713)
github-actions bot pushed a commit that referenced this issue Oct 27, 2021
BMP: harden identify checks to avoid misidentification of other datasets (fixes #4713)
rouault added a commit that referenced this issue Oct 28, 2021
[Backport release/3.4] BMP: harden identify checks to avoid misidentification of other datasets (fixes #4713)
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