qgis / QGIS

QGIS is a free, open source, cross platform (lin/win/mac) geographical information system (GIS)
https://qgis.org
GNU General Public License v2.0
10.59k stars 3k forks source link

Clip Raster by Extent: Wrong calculation of the clipping extent by layer #55447

Open Jaeggi99 opened 11 months ago

Jaeggi99 commented 11 months ago

What is the bug or the crash?

Hello

Today I wanted to clip a large orthophoto to the extent of a smaller DEM with the in QGIS built in tool. I used for the input "Clipping extent" the option "calculate from layer" but the upper left x,y and lower right x,y coordinates are calculated wrong, so that the extent is too small.

For example: The extent I want is [ulx, lrx, lry, uly] = [576101.0, 583101.0, 5407926.0, 5411426.0] but the "calculate from layer" calculates [ulx, lrx, lry, uly] = [576784.9375, 581844.3125, 5408803.0, 5410447.0].

This illustrated in the image below:

BugReport_ClipRaster

Steps to reproduce the issue

  1. Load two raster datasets with different extent
  2. Go to 'Raster'
  3. Go to 'Extraction'
  4. Click on 'Clip Raster by Extent' In the dialog:
  5. Select as 'Input Layer' the larger raster
  6. Clock for 'Clipping extent' on the right on the small arrow, hover over 'Calculate from Raster' and select the smaller raster -> Now the calculated extent appears, which is in my case smaller than it should be
  7. Run the tool. The clipped raster will be smaller than the set extent.

Versions

QGIS version 3.28.8-Firenze QGIS code revision 5ac45272b5 Qt version 5.15.3 Python version 3.9.5 GDAL/OGR version 3.7.0 PROJ version 9.2.1 EPSG Registry database version v10.088 (2023-05-13) GEOS version 3.11.2-CAPI-1.17.2 SQLite version 3.41.1 PDAL version 2.5.3 PostgreSQL client version unknown SpatiaLite version 5.0.1 QWT version 6.1.6 QScintilla2 version 2.13.1 OS version Windows 10 Version 2009

Active Python plugins db_manager 0.1.20 grassprovider 2.12.99 MetaSearch 0.3.6 processing 2.12.99 sagaprovider 2.12.99

Supported QGIS version

New profile

Additional context

No response

agiudiceandrea commented 11 months ago

@Jaeggi99, thanks for reporting. It would be useful if you may provide a project and layer with which the issue occurs, so that a developer can replicate the issue and try to fix it.