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

Not rendering with identity transform raster created with rasterio #45324

Closed
1 of 2 tasks
drStacky opened this issue Sep 29, 2021 · 5 comments
Closed
1 of 2 tasks

Not rendering with identity transform raster created with rasterio #45324

drStacky opened this issue Sep 29, 2021 · 5 comments
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! Feedback Waiting on the submitter for answers Rasters Related to general raster layer handling (not specific data formats) stale Uh oh! Seems this work is abandoned, and the PR is about to close.

Comments

@drStacky
Copy link

What is the bug or the crash?

When I create a geotiff using rasterio with the identity geotransform, the pixels do not render in QGIS. The identify features cursor acts like there are no pixels, however the histogram confirms there are non-zero pixels to display.

Steps to reproduce the issue

Create a geotiff using rasterio v1.2.8 in python 3.7:

from affine import Affine
import numpy as np
import rasterio as rio


img = np.random.randint(0, 255, size=(3,100,100), dtype='uint8')
profile = {
    'count': img.shape[0],
    'height': img.shape[1],
    'width': img.shape[2],
    'dtype': img.dtype,
    'transform': Affine.identity(),
}

with rio.open('invisible.tif', 'w', **profile) as dst:
    dst.write(img)

Results from gdalinfo on invisible.tif:

Driver: GTiff/GeoTIFF
Files: invisible.tif
Size is 100, 100
Coordinate System is `'
Origin = (0.000000000000000,0.000000000000000)
Pixel Size = (1.000000000000000,1.000000000000000)
Image Structure Metadata:
  INTERLEAVE=PIXEL
Corner Coordinates:
Upper Left  (   0.0000000,   0.0000000) 
Lower Left  (       0.000,     100.000) 
Upper Right ( 100.0000000,   0.0000000) 
Lower Right (     100.000,     100.000) 
Center      (  50.0000000,  50.0000000) 
Band 1 Block=100x27 Type=Byte, ColorInterp=Red
Band 2 Block=100x27 Type=Byte, ColorInterp=Green
Band 3 Block=100x27 Type=Byte, ColorInterp=Blue

On the other hand, changing the 'transform' to None above results in a geotiff that renders properly (albeit without a CRS) and the following gdalinfo print out:

Driver: GTiff/GeoTIFF
Files: visible.tif
Size is 100, 100
Coordinate System is `'
Image Structure Metadata:
  INTERLEAVE=PIXEL
Corner Coordinates:
Upper Left  (    0.0,    0.0)
Lower Left  (    0.0,  100.0)
Upper Right (  100.0,    0.0)
Lower Right (  100.0,  100.0)
Center      (   50.0,   50.0)
Band 1 Block=100x27 Type=Byte, ColorInterp=Red
Band 2 Block=100x27 Type=Byte, ColorInterp=Green
Band 3 Block=100x27 Type=Byte, ColorInterp=Blue

Versions

<style type="text/css"> p, li { white-space: pre-wrap; } </style>
QGIS version 3.4.4-Madeira QGIS code branch Release 3.4
Compiled against Qt 5.11.2 Running against Qt 5.11.2
Compiled against GDAL/OGR 2.3.3 Running against GDAL/OGR 2.3.3
Compiled against GEOS 3.7.1-CAPI-1.11.0 Running against GEOS 3.7.2-CAPI-1.11.2 b55d2125
PostgreSQL Client Version 9.6.10 SpatiaLite Version 4.4.0-RC1
QWT Version 6.1.3 QScintilla2 Version 2.10.8
PROJ.4 Version 493

Supported QGIS version

  • I'm running a supported QGIS version according to the roadmap.

New profile

  • I tried with a new QGIS profile

Additional context

No response

@drStacky drStacky added the Bug Either a bug report, or a bug fix. Let's hope for the latter! label Sep 29, 2021
@gioman
Copy link
Contributor

gioman commented Sep 29, 2021

When I create a geotiff using rasterio

@drStacky please attach a sample.

@gioman gioman added Feedback Waiting on the submitter for answers Rasters Related to general raster layer handling (not specific data formats) labels Sep 29, 2021
@drStacky
Copy link
Author

Here's my output from the code snippet I posted:
invisible.tif.zip
I'll be the first to admit this may be a rasterio issue, too, but the image renders with Affine(1, 0, 0, 0, -1, 0), Affine(5, 0, 0, 0, 5, 0), and None.

@gioman gioman changed the title Not rendering with identity transform Not rendering with identity transform raster created with rasterio Sep 29, 2021
@gioman gioman removed the Feedback Waiting on the submitter for answers label Sep 29, 2021
@elpaso
Copy link
Contributor

elpaso commented Sep 30, 2021

There is something wrong with the layer's extent:

In [3]: layer.extent()
Out[3]: <QgsRectangle: 0 100, 100 0>

In [4]: layer.extent().isEmpty()
Out[4]: True

@gioman gioman added the Feedback Waiting on the submitter for answers label Sep 30, 2021
@github-actions
Copy link

The QGIS project highly values your report and would love to see it addressed. However, this issue has been left in feedback mode for the last 14 days and is being automatically marked as "stale".
If you would like to continue with this issue, please provide any missing information or answer any open questions. If you could resolve the issue yourself meanwhile, please leave a note for future readers with the same problem and close the issue.
In case you should have any uncertainty, please leave a comment and we will be happy to help you proceed with this issue.
If there is no further activity on this issue, it will be closed in a week.

@github-actions github-actions bot added the stale Uh oh! Seems this work is abandoned, and the PR is about to close. label Oct 15, 2021
@github-actions
Copy link

While we hate to see this happen, this issue has been automatically closed because it has not had any activity in the last 42 days despite being marked as feedback. If this issue should be reconsidered, please follow the guidelines in the previous comment and reopen this issue.
Or, if you have any further questions, there are also further support channels that can help you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! Feedback Waiting on the submitter for answers Rasters Related to general raster layer handling (not specific data formats) stale Uh oh! Seems this work is abandoned, and the PR is about to close.
Projects
None yet
Development

No branches or pull requests

3 participants