Error while importing shapefiles (LREW_demo in the tutorial)

610 views
Skip to first unread message

Jylee

unread,
Aug 26, 2020, 2:38:07 AM8/26/20
to SWAT-MODFLOW
Hi,

I am new to SWAT-MODFLOW, and I would greatly appreciate any help resolving the issue I am facing.

I am following the demo project in the tutorial and getting an error when I try to import SWAT shapefiles. I get the following error message shown in red below. Fyi, I use QGIS 3.10.5 and QSWATMOD2. 

I have no idea what is wrong and how to resolve the problem. Please help. Thank you!

Best,
Lee

An error has occurred while executing Python code: 

AttributeError: 'NoneType' object has no attribute 'insertChildNode' 
Traceback (most recent call last):
  File "C:/Users/ljuyoung/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\QSWATMOD2\QSWATMOD2.py", line 1363, in hru_shapefile
    swat_group.insertChildNode(0, QgsLayerTreeLayer(layer))
AttributeError: 'NoneType' object has no attribute 'insertChildNode'


Python version: 3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:59:51) [MSC v.1914 64 bit (AMD64)] 
QGIS version: 3.10.5-A Coruña A Coruña, 984615fe1e 






2020-08-25T23:19:55     WARNING    Traceback (most recent call last):
              File "C:/Users/ljuyoung/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\QSWATMOD2\QSWATMOD2.py", line 623, in import_mf_grid
              modflow_functions.import_mf_grid(self)
              File "C:/Users/ljuyoung/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\QSWATMOD2\pyfolder\modflow_functions.py", line 1247, in import_mf_grid
              processing.run('native:fixgeometries', params)
              File "C:/PROGRA~1/QGIS3~1.10/apps/qgis-ltr/./python/plugins\processing\tools\general.py", line 106, in run
              return Processing.runAlgorithm(algOrName, parameters, onFinish, feedback, context)
              File "C:/PROGRA~1/QGIS3~1.10/apps/qgis-ltr/./python/plugins\processing\core\Processing.py", line 181, in runAlgorithm
              raise QgsProcessingException(msg)
             _core.QgsProcessingException: There were errors executing the algorithm.




2020-08-25T23:21:01     WARNING    Traceback (most recent call last):
              File "C:/Users/ljuyoung/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\QSWATMOD2\QSWATMOD2.py", line 654, in create_rivs
              modflow_functions.mf_riv1(self)
              File "C:/Users/ljuyoung/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\QSWATMOD2\pyfolder\modflow_functions.py", line 437, in mf_riv1
              {'INPUT': input1, 'OUTPUT': mf_riv_shapefile}
              File "C:/PROGRA~1/QGIS3~1.10/apps/qgis-ltr/./python/plugins\processing\tools\general.py", line 106, in run
              return Processing.runAlgorithm(algOrName, parameters, onFinish, feedback, context)
              File "C:/PROGRA~1/QGIS3~1.10/apps/qgis-ltr/./python/plugins\processing\core\Processing.py", line 181, in runAlgorithm
              raise QgsProcessingException(msg)
             _core.QgsProcessingException: There were errors executing the algorithm.

Vahid Rafie

unread,
Aug 26, 2020, 8:03:57 AM8/26/20
to SWAT-MODFLOW
Hi Lee, 
Check the CRS of the shapefile and the CRS using in the QGIS to be the same.
Cheers
Vahid 

Jylee

unread,
Aug 26, 2020, 4:12:08 PM8/26/20
to SWAT-MODFLOW
Dear Vahid,

Thank you for your reply, but unfortunately setting the project CRS the same as the shapefile CRS (NAD83/Conus Albers; EPSG: 5070) doesn't solve the problem. I still get the same error: AttributeError: 'NoneType' object has no attribute 'insertChildNode'. 

Can the issue be related to the python environment? During the installation of QGIS 3.10 and QSWATMOD2, I wasn't asked to install the dependencies. I have both Python 2.7 and 3.8 on my computer from my previous work, and the required python packages may be already installed but the path is not set up correctly. I think the problem might be related to this, but I have no idea how to tackle this.

Please let me know if you have any idea how to ensure that all the required python packages are set up in the right place and made available to QSWATMOD. 

Thank you so much.

Best,
Lee
2020년 8월 26일 수요일 오전 5시 3분 57초 UTC-7에 vahi...@gmail.com님이 작성:

Seonggyu Park

unread,
Aug 26, 2020, 6:31:42 PM8/26/20
to SWAT-MODFLOW
Hi Lee,

After you created a project, you should see layer trees on the layer panel. Were you able to see this like below?

Capture.JPG

Thanks,
Seonggyu
Message has been deleted

Jylee

unread,
Aug 27, 2020, 12:41:08 AM8/27/20
to SWAT-MODFLOW
Dear Seonggyu,

No, I don't see any layer created. Please let me know if you have an idea what might be the problem and how I can resolve it. 

I am wondering if the python setup is the problem, to begin with. During the installation of QGIS 3.10 and QSWATMOD2, I wasn't asked to install any dependencies as shown in the documentation. I already have both Python 2.7.16 and 3.7.4 and 3.8.1 on my computer from my previous work (messy I know..), and it seems that my QGIS runs on Python 3.7.0 that comes with QGIS (C:\Program Files\QGIS 3.10\apps\Python37). 

I am sorry for what seems quite basic, possibly more related to python setup, and I would greatly appreciate your help.

I am really looking forward to using SWAT-MODFLOW!

Thank you. 

Best,
Lee

2020년 8월 26일 수요일 오후 3시 31분 42초 UTC-7에 env...@gmail.com님이 작성:

Seonggyu Park

unread,
Aug 27, 2020, 12:24:06 PM8/27/20
to SWAT-MODFLOW
Hi Lee,

QSWATMOD2 includes all dependencies directly in the plugin to avoid user-installation. So, there would be no additional installation after you installed QSWATMOD2 on your computer. I suggest you to recreate a QSWATMOD project and see whether there are layer trees on the layer panel. Then, try to load your HRU shapefile. Please, let me know if you have the same issue.

Thanks,
Seonggyu
Message has been deleted

Jylee

unread,
Aug 28, 2020, 12:48:01 AM8/28/20
to SWAT-MODFLOW
Dear Seonggyu,

Thank you for your answer! 

I have re-installed QGIS3 and QSWATMOD2, and the problem is resolved. Now I see the layer trees, and importing shapefiles works fine. 

I am first familiarizing myself with the program using the tutorial SWAT and MODFLOW models, and now I am facing other issues at the simulation step. I am attaching the screenshot.

1) I see that the simulation period part in the QSWATMOD window is greyed out (not editable). I have tried changing the simulation period directly in the file.cio, and the changes immediately show up in the QSWATMOD window. However, I am wondering if it is normal that the simulation period is not editable in the QSWATMOD window and I am supposed to edit the file.cio.

2) When I try to change irrigation in the configuration settings, I get an error that no irrigation package is found, although the well file--modflow_LRW.wel--is included in the tutorial MODFLOW folder as well as in my project's SWAT-MODFLOW folder. I get the same error for the drainage package, though modflow_LRW.drn is also there. Why does QSWATMOD fail to read the .wel and .drn files that are in my SWAT-MODFLOW folder, and how do I fix this problem? 

3) When I select no irrigation and drainage and go ahead with running SWAT-MODFLOW simulation, it also fails. When I try running SWAT only (by choosing "No" for activating SWAT-MODFLOW, it also fails. As I am using the tutorial SWAT and MODFLOW files, I have no idea why it fails to run.

I would greatly appreciate it if you could share your thoughts/tips on these problems. 

Thank you. 

Best,
Lee

2020년 8월 27일 목요일 오전 9시 24분 6초 UTC-7에 env...@gmail.com님이 작성:
Screen Shot 2020-08-27 at 5.09.50 PM.png

Seonggyu Park

unread,
Sep 1, 2020, 9:51:23 AM9/1/20
to SWAT-MODFLOW
1) Yes, it's normal and I did that on purpose. In a SWAT-MODFLOW model, users need to consider time inputs from both the SWAT (file.cio) and MODFLOW (*.dis). It's hard to sync two time variables using a button. So, it's more like a display rather than a control panel and users need to provide correct file.cio and *.dis files.
 
2) You need to check the "modflow.mfn" file whether a well or drain package is added in this file. Also, see page 29 in the QSWATMOD tutorial.
Capture1.JPG

3) There would be many causes of model failure. After you try the number 2, but still have an issue, please share your model (QSWATMOD project). I am happy to look at it.

Thanks,
Seonggyu



Jylee

unread,
Sep 1, 2020, 6:19:04 PM9/1/20
to SWAT-MODFLOW
Dear Seonggyu,

Thank you so much for your answers!

I see both .wel and .drn files in the .mfn file (please see attached image). All three files seem fine. When I activate "Irrigation (MODFLOW pumping --> SWAT)", the shapefile for conveyance efficiency and runoff ratio is created (as shown in the tutorial). However, when I click "Link to sub and HRU", it still gives the same error saying that no well package is found. 

When I go ahead and try running the model, the model still does not run. The command prompt opens but it doesn't move forward and closes after a while (please see attached image). 

I am attaching the QSWATMOD project as a zip file through Google Drive due to the file size: https://drive.google.com/file/d/1RjsQ-f2nJtlH0uzQl1NqqvwzHwIPrB_B/view?usp=sharing

Please let me know if the link doesn't work for you. 

Thank you in advance. 

Best,
Ju Young

2020년 9월 1일 화요일 오전 6시 51분 23초 UTC-7에 env...@gmail.com님이 작성:
exe error.png
mfn file.png

Seonggyu Park

unread,
Sep 1, 2020, 9:37:15 PM9/1/20
to Jylee, SWAT-MODFLOW
Is this the example dataset of the QSWATMOD2?

--
You received this message because you are subscribed to a topic in the Google Groups "SWAT-MODFLOW" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/swat-modflow/n_BR6tNQxls/unsubscribe.
To unsubscribe from this group and all its topics, send an email to swat-modflow...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/swat-modflow/4d7cd54d-31db-4f61-9578-e9823ca3e504n%40googlegroups.com.

Jylee

unread,
Sep 2, 2020, 2:18:41 AM9/2/20
to SWAT-MODFLOW
By the example dataset of the QSWATMOD2, which one do you mean? 
1) The dataset included in the "swat-modflow3" zip file downloadable from the following link--https://swat.tamu.edu/software/swat-modflow/. Here the "Files" folder contains 6 subfolders named 1 SWAT LRW; 2 MODFLOW LRW; 3 Linking; 4 SWAT MODFLOW LRW;5 SWAT MODFLOW RT3D LRW as shown in the tutorial.
2) The dataset included in your GitHub repository--https://github.com/spark-brc/QSWATMOD2. Here the "Inputs" folder seems to contain the same dataset, which is organized in 3 subfolders named Data, Models, and Shapefiles. 

I have been using the first dataset (all files from there except for the MODFLOW observation point shapefile that I created since it is missing there) and getting the errors that the well and drainage packages are missing and the model simulation fails. 

Now I have also tried building the model using the second dataset (except for the MODFLOW grid shapefile which is missing there; so I use the grid shapefile from swat-modflow3 > 2 MODFLOW LRW > MODFLOW model shapefiles), and I still get the same errors. 

What am I doing wrong? I would greatly appreciate your advice.

Thank you.

Best,
Lee




2020년 9월 1일 화요일 오후 6시 37분 15초 UTC-7에 env...@gmail.com님이 작성:

rael nyakundi

unread,
May 16, 2021, 1:38:28 AM5/16/21
to SWAT-MODFLOW
I am also getting the same error here however  for my case the drain and well package files are not in my "modflow.mfn" fine. Any assistance please?
From the tutorial i should provide well and drain package but I don't know how since i constructed my model using option 3.

Melvin Raymund Dangin

unread,
Aug 3, 2022, 9:25:04 AM8/3/22
to SWAT-MODFLOW
Hello Jylee,

Were you able to figure this out? I'm also having problems with running the tutorial when I try to use the "Irrigation (MODFLOW pumping --> SWAT)". Looking forward to your response.

Seonggyu Park

unread,
Aug 15, 2022, 3:24:22 PM8/15/22
to SWAT-MODFLOW
Hi, 

Thanks for the report. The issue was fixed by defining 'QSettings' in version 2.3.1.

Also, please use a dataset from the QSWATMOD2 repo. The dataset of LREW is too sensitive to use pumping scenarios.
- Dataset: (https://github.com/spark-brc/QSWATMOD2/raw/main/Inputs/ExampleDataset.zip) / Middle Bosque River Watershed (MBRW)

If the same issue persists, please let me know.

Best regards,
Seonggyu

Wendell D Talampas

unread,
Oct 25, 2023, 7:54:00 AM10/25/23
to SWAT-MODFLOW
Hi Everyone,

I am new to this community as well as in using the SWAT-MODFLOW interface. I have run my MODFLOW model in ModelMuse (MODFLOW-NWT). I also did my SWAT model in ArcSWAT. Do I need to paste-in all my MODFLOW file in the MODFLOW LRW Folder? Is it possible for anyone to take a look at my MODFLOW file and see if I can use it. Hoping to hear from anyone.

Thank you.

Regards,
Wendell

Seonggyu Park

unread,
Oct 25, 2023, 11:48:23 PM10/25/23
to SWAT-MODFLOW
Dear Wendell,

I believe you can use your MODFLOW model. Does your MODFLOW model use the STR or RIV package?
Please, check the SWAT-MODFLOW and QSWATMOD tutorials and here are the links.

Best,
Seonggyu

Pedro Sanzana

unread,
Sep 15, 2025, 8:37:03 AMSep 15
to SWAT-MODFLOW
Dear Comunity SWAT MODFLOW
I am using the files in the 
Captura.JPG
I get the folowing  error (at the river linking step): 

2025-09-07T16:32:38     WARNING    Traceback (most recent call last):
              File "C:\Users/pedro/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\QSWATMOD2\QSWATMOD2.py", line 733, in create_rivs
              linking_process.river_grid(self)
              File "C:\Users/pedro/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\QSWATMOD2\pyfolder\linking_process.py", line 450, in river_grid
              processing.run('qgis:intersection', params)
              File "C:\PROGRA~1/QGIS34~1.10/apps/qgis-ltr/./python/plugins\processing\tools\general.py", line 106, in run
              return Processing.runAlgorithm(
              ^^^^^^^^^^^^^^^^^^^^^^^^
              File "C:\PROGRA~1/QGIS34~1.10/apps/qgis-ltr/./python/plugins\processing\core\Processing.py", line 214, in runAlgorithm
              ret, results = execute(
              ^^^^^^^^
              File "C:\PROGRA~1/QGIS34~1.10/apps/qgis-ltr/./python/plugins\processing\gui\AlgorithmExecutor.py", line 74, in execute
              results, ok = alg.run(parameters, context, feedback, {}, False)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
             _core.QgsProcessingException: Could not write feature

 
I am using QGIS 3.40 Bratislava
and the most recent version of QGIS Plugins dowloaded it from github repository, 
Thanks you in advance, 

Pedro 
Reply all
Reply to author
Forward
0 new messages