Python error when clipping land use rasters

6 views
Skip to first unread message

Mayu Mizutani

unread,
Oct 9, 2025, 8:23:36 AM (3 days ago) Oct 9
to SWAT-user
Hello, 
I am having trouble using my land use raster when creating the HRUs in qSWAT+.
It is the NLCD layer that I have obtained from the MRLC as a GeoTIFF and converted into a .sdat file. These are the messages I get:

2025-10-08T14:48:07     WARNING    Traceback (most recent call last):
              File "C:\Users/mayum/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\QSWATPlus\QSWATPlus\hrus.py", line 5975, in getLanduseFile
              QSWATUtils.openAndLoadFile(root, FileTypes._LANDUSES,
              File "C:\Users/mayum/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\QSWATPlus\QSWATPlus\QSWATUtils.py", line 879, in openAndLoadFile
              layer = QSWATUtils.getLayerByFilename(root.findLayers(), outFileName, ft,
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
              File "C:\Users/mayum/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\QSWATPlus\QSWATPlus\QSWATUtils.py", line 684, in getLayerByFilename
              layer = QSWATUtils.clipLayerToDEM(treeLayers, cast(QgsRasterLayer, layer), fileName, legend, gv)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
              File "C:\Users/mayum/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\QSWATPlus\QSWATPlus\QSWATUtils.py", line 587, in clipLayerToDEM
              assert os.path.exists(clipName), 'Failed to clip raster {0} to make {1}'.format(fileName, clipName)
              ^^^^^^^^^^^^^^^^^^^^^^^^
             AssertionError: Failed to clip raster C:/Users/mayum/Documents/working/qgis2/etowah\Watershed\Rasters\Landuse\nlcd_2024_saga.sdat to make C:/Users/mayum/Documents/working/qgis2/etowah\Watershed\Rasters\Landuse\nlcd_2024_saga_clip.tif
             

with this messages in Process window:

2025-10-08T14:48:07     INFO    gdal_translate -a_nodata 250.0 -of GTiff -srcwin 16073 5469 -8864 -7 C:/Users/mayum/Documents/working/qgis2/etowah\Watershed\Rasters\Landuse\nlcd_2024_saga.sdat C:/Users/mayum/Documents/working/qgis2/etowah\Watershed\Rasters\Landuse\nlcd_2024_saga_clip.tif

2025-10-08T14:48:07     INFO    GDAL command:

2025-10-08T14:48:07     INFO    gdal_translate -a_nodata 250.0 -of GTiff -srcwin 16073 5469 -8864 -7 C:/Users/mayum/Documents/working/qgis2/etowah\Watershed\Rasters\Landuse\nlcd_2024_saga.sdat C:/Users/mayum/Documents/working/qgis2/etowah\Watershed\Rasters\Landuse\nlcd_2024_saga_clip.tif

2025-10-08T14:48:07     INFO    GDAL command output:

2025-10-08T14:48:07     CRITICAL    Process returned error code 1

2025-10-08T14:48:07     INFO    Results: {'OUTPUT': 'C:/Users/mayum/Documents/working/qgis2/etowah\\Watershed\\Rasters\\Landuse\\nlcd_2024_saga_clip.tif'}

2025-10-08T14:48:07     CRITICAL    ERROR 1: Error: -srcwin 16073 5469 -8864 -7 has negative width and/or height.

2025-10-08T14:48:07     INFO    Input file size is 24888, 13703

Nancy B. Sammons

unread,
Oct 9, 2025, 9:08:42 AM (3 days ago) Oct 9
to Mayu Mizutani, SWAT-user

Mayu: 

You should post this on the SWAT+ and/or QSWAT+ Google group so the developer can review it.

Nancy

 

From: swat...@googlegroups.com <swat...@googlegroups.com> On Behalf Of Mayu Mizutani
Sent: Wednesday, October 8, 2025 1:55 PM
To: SWAT-user <swat...@googlegroups.com>
Subject: [SWAT-user:13268] Python error when clipping land use rasters

 

You don't often get email from mayumiz...@gmail.com. Learn why this is important

--
You received this message because you are subscribed to the Google Groups "SWAT-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to swatuser+u...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/swatuser/d3159cbf-7a9c-4f41-bb1d-2d4df514282cn%40googlegroups.com.

Chris George

unread,
Oct 9, 2025, 9:12:56 AM (3 days ago) Oct 9
to Mayu Mizutani, SWAT-user
It looks like you assigned your project's projection to your landuse
file instead of reprojecting it properly.

Try clicking on Zoom Full in QGIS and you will see your project separate.

You do not need to clip landuse or soil rasters: QSWAT will do that for
you if they are much bigger than the DEM.

Chris

On 10/8/2025 7:54 PM, Mayu Mizutani wrote:
> Hello,  I am having trouble using my land use raster when creating the
> HRUs in qSWAT+. It is the NLCD layer that I have obtained from the MRLC
> as a GeoTIFF and converted into a .sdat file. These are the messages I
> get: 2025-10-08T14: 48: 07
> ZjQcmQRYFpfptBannerStart
> This Message Is From an External Sender
> This message came from outside your organization.
> ZjQcmQRYFpfptBannerEnd
> etowah\Watershed\Rasters\Landuse\nlcd_2024_saga_clip.tif
>
> 2025-10-08T14:48:07     INFO GDAL command output:
>
> 2025-10-08T14:48:07     CRITICAL Process returned error code 1
>
> 2025-10-08T14:48:07     INFO Results: {'OUTPUT': 'C:/Users/mayum/
> Documents/working/qgis2/etowah\\Watershed\\Rasters\\Landuse\
> \nlcd_2024_saga_clip.tif'}
>
> 2025-10-08T14:48:07     CRITICAL ERROR 1: Error: -srcwin 16073 5469
> -8864 -7 has negative width and/or height.
>
> 2025-10-08T14:48:07     INFO Input file size is 24888, 13703
>
> --
> You received this message because you are subscribed to the Google
> Groups "SWAT-user" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to swatuser+u...@googlegroups.com
> <mailto:swatuser+u...@googlegroups.com>.
> To view this discussion visit https://groups.google.com/d/msgid/
> swatuser/d3159cbf-7a9c-4f41-bb1d-2d4df514282cn%40googlegroups.com
> <https://urldefense.com/v3/__https://groups.google.com/d/msgid/swatuser/
> d3159cbf-7a9c-4f41-bb1d-2d4df514282cn*40googlegroups.com?
> utm_medium=email&utm_source=footer__;JQ!!KwNVnqRv!
> FKfkPrDFcjvoSo01MetYVGLrMi3MS09Rr1B8QSmZr3_-
> qJPpMAXKktXCFXFxcCn_NXxE4W3g_nlwuSoYOUVXfy4s$>.

Reply all
Reply to author
Forward
0 new messages