Weird soil value

136 views
Skip to first unread message

Lara Lage Sanches

unread,
Mar 8, 2021, 12:50:38 PM3/8/21
to QSWAT
Hello, everyone, I've been having trouble with the HRUs reading step. I've posted on this group recently, when I was testing a sample of my area, and the insights were really helpful. Now, I am modeling my whole area and some errors are popping, which didn't happen before, or did happen but were fixed and now came back.

Firstly, there's this message:

"Unknown soil value -339999995214436424907732413799364296704"

I've checked the raster values and both the soil lookup table and usersoil table. There is no such value.

Then, another one:

"Could not write to table BASINSDATA2 in project database. Traceback (most recent call last):
File "C:/PROGRA~1/QGIS3~1.10/apps/qgis-ltr/./python/plugins\QSWAT3_64\QSWAT\DBUtils.py", line 948, in writeBasinsDataItem
curs.execute(sql2, index, basin, crop, soil, slope, hru, cd.cellCount, float(cd.area), float(cd.totalSlope))
OverflowError: int too big to convert"

Which also appears like this in the Python error message:

"OverflowError: argument 1 overflowed: value must be in the range -2147483648 to 2147483647
Traceback (most recent call last):
File "C:/PROGRA~1/QGIS3~1.10/apps/qgis-ltr/./python/plugins\QSWAT3_64\QSWAT\hrus.py", line 371, in readFiles
FileTypes.colourSoils(self.soilLayer, self._db)
File "C:/PROGRA~1/QGIS3~1.10/apps/qgis-ltr/./python/plugins\QSWAT3_64\QSWAT\QSWATUtils.py", line 1380, in colourSoils
item = QgsPalettedRasterRenderer.Class(int(i), colour, name)
OverflowError: argument 1 overflowed: value must be in the range -2147483648 to 2147483647"

I've configured my pc for period as decimal separator and comma as thousands separator. All my maps are projected and have the same crs. All the values, from all the maps, are present in their respective lookup tables. The soil parameters are derived from a macro which is attached below.

Maybe the messages are related but I ran out of options where to check for input errors. Does anyone have another ideia where this might be coming from?
usersoil_2012template_new3.xls

Chris George

unread,
Mar 8, 2021, 2:01:53 PM3/8/21
to Lara Lage Sanches, QSWAT
I think the problem you have is an extreme nodata value, and it can
cause QGIS and/or QSWAT to get confused. Try the following:



1. Load the soil map in QGIS. If you have your QSWAT project open the
soil map won't have much of a legend yet: load it is a separate raster
using the data source manager (top left symbol next to the layers panel)

2. If you see a sensible range of positive integers then QGIS has
recognised the nodata value and we proceed as follows:

Open the processing toolbox, type in nodata in the search box at the top
and you should be able to find Raster tools -> Fill nodata cells. Open
this, select the soil file as the raster input, leave band as 1, put in
a new nodata value, eg -999 (but remember what you type), leave output
as temporary, leave open file ticked, and click Run. If it runs OK
close the form.

There will be a new layer called Output raster. Right click on its
legend and select Export -> Save as

In the save as form, leave the format as GeoTIFF, select a directory and
file name for the result (use the button far right to find the directory
so you get a full path in the box), scroll to bottom, check no data
values, click the plus sign, type -999 in the From box, and it appears
in the To box. Click OK. It creates a new soil file for you to use.

There are probably other ways to change the nodata value of a raster,
but this is simple.

If QGIS is confused about the nodata value it's a bit harder. Send your
file to me and I'll see what I can do.

Chris


On 3/8/2021 5:21 PM, Lara Lage Sanches wrote:
> Hello, everyone, I've been having trouble with the HRUs reading step.
> I've posted on this group recently, when I was testing a sample of my
> area, and the insights were really helpful. Now, I am modeling my whole
> area and some errors are popping, which didn't happen before, or did
> happen but were fixed and now came back.
>
> Firstly, there's this message:
>
> "Unknown soil value -339999995214436424907732413799364296704"
>
> I've checked the raster values and both the soil lookup table and
> usersoil table. There is no such value.
>
> Then, another one:
>
> "Could not write to table BASINSDATA2 in project database. Traceback
> (most recent call last):
> File
> "C:/PROGRA~1/QGIS3~1.10/apps/qgis-ltr/./python/plugins\QSWAT3_64\QSWAT\DBUtils.py",
> line 948, in writeBasinsDataItem
> curs.execute(sql2, index, basin, crop, soil, slope, hru, cd.cellCount,
> float(cd.area), float(cd.totalSlope))
> OverflowError: int too big to convert"
>
> Which also appears like this in the Python error message:
> *
> *
> "*OverflowError: argument 1 overflowed: value must be in the range
> -2147483648 to 2147483647*
> Traceback (most recent call last):
> File
> "C:/PROGRA~1/QGIS3~1.10/apps/qgis-ltr/./python/plugins\QSWAT3_64\QSWAT\hrus.py",
> line 371, in readFiles
> FileTypes.colourSoils(self.soilLayer, self._db)
> File
> "C:/PROGRA~1/QGIS3~1.10/apps/qgis-ltr/./python/plugins\QSWAT3_64\QSWAT\QSWATUtils.py",
> line 1380, in colourSoils
> item = QgsPalettedRasterRenderer.Class(int(i), colour, name)
> OverflowError: argument 1 overflowed: value must be in the range
> -2147483648 to 2147483647"
>
> I've configured my pc for period as decimal separator and comma as
> thousands separator. All my maps are projected and have the same crs.
> All the values, from all the maps, are present in their respective
> lookup tables. The soil parameters are derived from a macro which is
> attached below.
>
> Maybe the messages are related but I ran out of options where to check
> for input errors. Does anyone have another ideia where this might be
> coming from?
>
> --
> You received this message because you are subscribed to the Google
> Groups "QSWAT" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to qswat+un...@googlegroups.com
> <mailto:qswat+un...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/qswat/4dd02721-683b-44f2-a4bb-2a8c03d943can%40googlegroups.com
> <https://groups.google.com/d/msgid/qswat/4dd02721-683b-44f2-a4bb-2a8c03d943can%40googlegroups.com?utm_medium=email&utm_source=footer>.
Reply all
Reply to author
Forward
0 new messages