ArcSWAT Bug – Index was outside the bounds of the array.: IN, mWriteInputFiles.sol

Description

  • ArcSWAT 2012.10.15
  • SSURGO Soil Database is used
  • Following error message is given when running Create Tables

Reason

When generation sol table, ArcSWAT would do following work.

  1. Get all unique soil IDs from hrus table in project database.
  2. Create a new table (tbSoilList) in SSURGO database (which is usually located in C:\Swat\ArcSWAT\Databases\SWAT_US_SSURGO_Soils.mdb) and copy all soil IDs into this table.
  3. Find soil parameter for each soil ID from table SSURGO_Soils.
  4. Write the soil parameter into sol table.

The error message comes from Step 4. ArcSWAT doesn’t check the case when the soil ID couldn’t be found in SSURGO_Soils table. In that case, the returned soil parameter will be an empty array. When trying to read the first element of this array, it would give an error message shown above.

Solution

Check soil shapefile/grid to make sure all soil IDs have been defined in SSURGO_Soils table. And redo the Land Use/Soil/Slope Definition.

Note: This should also work for other soil options (user soil lookup table or STATSGO) and other ArcSWAT version.

68 Replies to “ArcSWAT Bug – Index was outside the bounds of the array.: IN, mWriteInputFiles.sol”

    1. Hi Lemma,

      Good question. I believe you could solve that with either of following options.

      1. Add rows in SSURGO_Soils table for those soil IDs. You may need to decide the values for each of the soil parameter. You could also use same parameter values from similar soils.

      2. Change the soil IDs to IDs of similar soils.

      I know it would be difficult to find the similar soils. That would depend on the your research area.

      Good luck!

      Cheers
      Michael

      1. zhiqiangyu, thank you very much. Your answer helped me a lot and finally I solved my problem

  1. Hi Zhiqiangyu

    i have the same problem, i could not find the solution, how can i do, i had tried many times as per your step, but it does not give the t alsways says index was outside the bounds of array.

    1. Hi bankim,

      Please give more details to facilitate the problem solving, like the soil database you choose and the soil polygon you use. If possible, contact me through email directly. We could go from there.

      Regards
      Michael

      1. Thanks Zhiqiangyu,

        I have downloaded the soil data from Indian metereological department (soil Map), and clipped into my watershed boundary, i have successfully created HRU and input all weather data like rainfall, temeprature, humidity. solar radiation and wind velocity. now creating sil table it says that the index was out of bounds array.in, minputfile.sol. detail analysis of the problem finds that the file creating in the database tbsoillist in SWAT_US_SSURGO_Soils remains empty.

        Thanks and Regards
        Bankim Joshi

      2. Hi Bankim,

        I’m not sure why you are using SSURGO option when you are not using the soil data in US. Should you use the user soil option? If you could share the soil layer after clip, it would help answer this question.

        Thanks
        Michael

      3. Hallo, Zhiqiangyu,

        Yes, you are right, probably it is my mistake i should not enter ssurgo data and i have clipped my data from soil map, though i had given user table, it does not work. either my format is wrong or something else. Pl. tell me how to my data as right format.

        Thanks and Regards

        Bankim Joshi
        +919998961211

      4. Hi Bankim,

        I’m not able to help you without the soil map and lookup table. You may want to make sure all soil ids in the map could be found in the lookup table.

        Regards
        Michael

  2. Hello Zhiqiangyu,

    I had this problem while I was working with ArcSWAT. Then, I tallied the soil ids in the attribute table to the MUID in the SSURGO_Soils database. I found that lots of soil ids were missing in the SSURGO_Soils database. Then I copied and paste the values (for all the fields of the missing soil ids) from the nearest soil id that is available in the SSURGO_Soils database. But the main problem was that there were 85 consecutive MUID missing in the SSURGO_Soils database. And what I did was that I copied the values from the nearest MUID and paste in these missing 85 MUID. All the values for these 85 missing MUID were same except for Object ID. I am not sure whether this is the right way to do. So, I am seeking for your advice regarding this.

    Regards
    Surendra Shrestha

    1. Hi Surendra,

      I think that depends on if the missing soils are similar to these soil you are using. I would recommend you do some research on these missing soils and try to get the parameters. If it’s not possible, seek advise from a soil scientist around you. Some soils can be very different even their IDs are close.

      Regards
      Zhqiang

      1. Dear Dr. Zhiqiangyu,

        Thank you so very much for your previous help. Now, I am having a problem with run SWAT check. After all the input data have been fed into the ArcSWAT (Land use, soil, slope, temperature, rainfall), I wrote the input table successfully. I set up the SWAT run for 25 years starting from 1990 allowing for 5 years of warm up and successfully ran the SWAT. In the read SWAT output option, I saved the simulation and clicked on run SWAT check but there occured an error saying “Unable to load DLL ‘shell32.dll’: Not enough storage is available to process this command. (Exception from HRESULT: 0x80070008)”. Is this error because of limited space in my PC processor or due to some other mistakes in the SWAT model setup? I have attached a copy of screenshot of that particular error with this email. I hope you will go through this and help me out. I will be waiting for your prompt response.

        Sincerely,

        Surendra Shrestha

      2. Hi Surendra,

        I didn’t see the screenshot. But I don’t think it’s a problem about your storage. I would suggest you run the swat check directly rather than running it in ArcSWAT. Or you could try to restart your computer and see.

        Hope it helps.

        Zhiqiang

    2. hi zhiqiangyu,

      here is screenshot of my error, i have prepared soil map as per watershed poligon by adding usersoil data, it always create same error that the field is too small to accept the amount of data you are trying to attempt. Try pasting or inserting less data. my HRU no 29 and watershed poligon is 169. i have added each poligan with soil data..

      how can i resolve my error.

      thanks Bankim Joshi 09998961211

  3. Hallo, Zhiqiangyu

    i can not resolve my problem till date. i tried it with making .txt file of soil name, in land use soil report all the soil data comes but in hru report only 1st name of soil occurs in all hru report generated by software. some times it says that index was outside bound of array and some times it says the field is too small to accept the amount of data you attempted to add. try inserting or pastinng less data.

    1. Hi bankim,

      Not sure if you are asking my suggestions. It seems strange though. Same error should be given on same input data. Please send me email if you want to talk further.

      Regards
      Zhiqiang

  4. Hello This is Mamoon. I am facing two problems with the HRU analysis. First, when I load the landuse grid, after I use the user Lookup table and load it I get this message (The land cover; Developed open space is not found in the crop or urban database. Please fix and try again). The second error is when I load the soil SSURGO grid and again when I load the user table this message shows (The soil ‘Bashaw’ does not exist in the usersoils database. Correct problem and try again).

    Thank you,
    Mamoon

    1. Hi Mamoon,

      You need to add information about Developed open space into crop or urban table to define all the parameters. And for soil you need to add Bashaw into usersoil table. Then you should be able to do HRU analysis successfully.

      Thanks
      Zhiqiang

  5. It is already in the look up table but it still comes. I have the Bashaw in the lookup table and yet the message shows.

    Thanks,
    Mamoon

  6. I think I have solved the Look up table for the land cover, the problem was that SWAT needs the form of the look up table in the form of the database ( 4 letters only) for example Developed open space as (URLD), I think so, is that right ?. I have not solved the soil look up table problem and I don’t know what is the solution ?.

    Thanks,
    Mamoon

    1. Hi Mamoon,

      It’s not just the problem of the lookup table. You need to look into the parameter table. For landuse it’s crop or urban. For soil, it’s usersoil. You need to make sure their parameter is there.

      Send me your files if problems persist.

      Regards
      Zhiqiang

  7. Hi Zhiqiang,

    I’m getting the same error message as you described above. I’m using QGIS 2.6.1. and 2.8.3.. I edited to look up table so that I could replace 14 missing values with the closest possible values. My study area is in India, so I’m using FAO global soils and for the soil map I have tried different ones from waterbase.org and the one from the SWAT site (http://swat.tamu.edu/software/links/india-dataset/). I clipped it to my study area and that’s pretty much all the steps I followed so far. My land cover map is based on Landsat 8 images and I created a separate look up table for it. I’m happy to share my files with you trough e-mail.

    Thanks in advance for you help,
    Olivier

    1. Hi Olivier,

      Are you using usersoil table if you are using user defined soil data? And are you using SWAT for QGIS? I’m not familiar with that.

      I would suggest you check your corresponding soil parameter table. And you’re welcome to send me any your file through email.

      Regards
      Zhiqiang

  8. Hello Zhiqiang,
    I think I just solved it, the problem with soil SSURGO as were saying, the names were missing in the SWAT2012.mdb database and it is solved now. I am trying to run the SWAT model but again a new error is showing (the field is too small to accept the amount of data you attempted to add swat. Try inserting or pasting less data). Thank you.

    Mamoon

  9. I solved this one also. The problem was that the ending date of the simulation where I specify the date, it was containing 1/8/2015 11:59 pm and I just erased 11:59 pm and it worked.
    I am now running the whole watershed, again I am facing another errors. First, whenever I delineate the watershed and I calculate the parameters a message shows ( No DEM value is found) and I have my DEM file and after the message comes I just press OK it works normally, but I wonder if that is fine. My second error comes when I run the SWAT model an error shows in the screen (running screen) (forrtl: error output conversion error, unit 34) but still my simulation is running and it works.

    Thank you,
    Mamoon

  10. Hello zhiqiangyu,
    I wonder if you have any idea why I am getting this error (No DEM value is found) when I calculate the sub-basin parameters.

      1. Hello Zhiqiangyu

        I am facing a problem during hru defination, i have copied my land use data and soil data in arcgis database as well as database of project folder (usersoil and crop ) swat2012. landuse and soil classification and slope map generated after i am facing this error.

  11. Hello Zhiqiangyu,
    I have a question regarding running SWAT, I have data of weather from January 1, 1990 until December 31, 2014 and I want to run my model for this period, but once I go to running windows where you specify the beginning and ending time of the running, it starts with 1st of January 1990 and ends on 18th of November 2014 instead of 31st of December 2014, any ideas .

    Best,
    Mamoom

    1. Hi Mamoom,

      I would suggest you look into all the weather files you imported, including precipitation, temperature and others. The ending day may be inconsistent.

      Hope it helps.
      Zhiqiang

  12. I looked at that option, but it seems they are fine. Do you think SWAT consider February as 30 days or normal as 28 days.

    Best,
    Mamoon

  13. Hello Zhiqiangyu,

    I got problem in running SWAT. I have checked all data input and something is wrong with the user soil input and I couldnt fix it. I also has changed MUID, SEQN, SNAME, SSID, CMPPT, but my ArcSWAT didnt work succesfully. And there is no unfilled data. Any Idea?. Thanks in advance.

    Best
    yaskinul

  14. Hi zhiqiangyu,

    I got a problem in running ArcSWAT. I have checked my input data and something went wrong in usersoil data. I have changed MUID, SEQN, SNAME, SSID, CMPPTand checked unfilled value. But ArcSWAT was still running error. Any Idea? Thanks

    best
    yaskinul

  15. Hello zhiqiangyu,

    This is Mamoon again. I have run my model and I am trying to calibrate. As I can observe my ET is very low and my lateral flow is very high. I wonder if you have any idea. I can send you my spreadsheet.

    Best,
    Mamoon

  16. Hello zhiqiangyu,

    I have sent you the file through the email almost 10 days ago, but it seems it didn’t make it to you. I have another question regarding USDA crop data layer. I have downloaded the data and I am trying to build up a lookup table for it, but I have no idea where I can find the 4 letter codes for the USDA crop data layer. I wonder if you can help me with that.

    Best,
    Mamoon

  17. Hello Zhiqiang,

    This is Mamoon again. I used SWAT 2012 to run my model and it worked and I am now trying to run my model using SWAT 2009, but I am getting an error when I load my weather stations and data stating “error in precipitation gage data. monitoring point features for not coincide with precipitation station table” . I am using the same text files for the weather as I used for SWAT 2012. I wonder if you can help me with that.

    Best,
    Mamoon

    1. Hi Mamoon,

      Are you using ArcSWAT2009 to recreate the model or just run SWAT2009 against existing SWAT2012 model? In which step do you get this error?

      Thanks
      Zhiqiang

      1. Hello Zhiqiang,

        I am not running the same model. I am building a new model using the same data. The error shows when I import my weather data; precipitation and temperature. Thank you.

        Best,
        Mamoon

      2. Dear Mamoon,

        You may need to check if SWAT2009 requires different file format for those files. I don’t have SWAT 2009 so can’t check that.

        Thanks
        Zhiqiang

      3. I think you are right. most probably the format is different. Thank you for your help.

        Best,
        Mamoon

  18. Dear Zhiqiang,

    I am trying to write input files, but I keep getting several different errors for the usersoil input depending on which columns I add or substract. (mWriteInputFiles.sol). The error is either saying I miss a column (-1) or that data is missing -while all columns are filled.

    If for example soil layer 7 does not exist for a particular row I filled in “0”.

    I tried using the same order of columns as in the SWAT 2012 Access table of the EXAMPLE I swat practice file. The difference is that I leave the MUID and S5ID columns empty – I filled in “0” for the columns SEQN and CMMPT and I filled in “dummy” in the TEXTURE column.

    I also tried using the same order as described in the SWAT-IO-DOCUMENTATION 2012.This unfortunately also did not work.

    The values in the document are based on the KENSOTER and SOTERSA maps of the FAO and calculated with pedotransferfunctions where needed. I hope I have provided enough information.
    I could send you the document I use personally to check for errors if needed.

    All help is appreciated. Best,

    Timo

    1. Hi Timo,

      I may need to see the soil you have to identify the problem. An screenshot would also help as it would give the error message.

      Best
      Zhiqiang

      1. Dear Zhiqiang, Thanks for the quick reply!The name of the error is No value given for one or more input parameters.: IN, mwriteinputfiles.solHowever there are no blanks or -99 values in my Accesstable. I checked whether all values are correct by using the edit swat input–>databases–> user soils”. It appears that my SOL_ZMX and ANION_EXCL are switched & TEXTURE and SOL_CRK are also switched. All other columns are correct. The strange thing is that if I switch these columns in the SWAT2012 Access file nothing changes in the ArcSWAT interface, but if I change the value within the SWAT2012 Access column the change is also processed in ArcSWAT2012. Therefore I think that SWAT recognizes the columns by name and not by order.. correct?Could this switch be a bug in my version of SWAT? I use the version 2012.10_2.18 released 9/9/15 and ArcMap 10.2.2.I copied my Access soil table to an excel file and added is as attachment here. Best, Timo Date: Tue, 5 Jul 2016 13:14:11 +0000 To: timo.ajax.c1@hotmail.com

      2. Dear Zhiqiang,

        Thanks for the quick reply!
        How can I add a document or post a screenshot here?
        The name of the error is “No value given for one or more input parameters.: IN, mwriteinputfiles.sol”
        However there are no blanks or -99 values in my Accesstable. I checked whether all values are correct by using the “edit swat input–>databases–> soil”. It appears that my SOL_ZMX and ANION_EXCL are switched & TEXTURE and SOL_CRK are also switched. All other columns are correct.

        The strange thing is that if I switch these columns in the SWAT2012 Access file nothing changes in the ArcSWAT interface, but if I change the value within the SWAT2012 Access column the change is also processed in ArcSWAT2012. Therefore I think that SWAT recognizes the columns by name and not by order.. correct?
        Could this switch be a bug in my version of SWAT? I use the version 2012.10_2.18 released 9/9/15 and ArcMap 10.2.2.

        Best,

        Timo

      3. Dear Zhiqiang,

        I solved the switched columns. I am new to Access so I only changed the order of columns in the Datasheet View in stead of the Design View. So the“No value given for one or more input parameters.: IN, mwriteinputfiles.sol” error is solved. But I still get another error “Syntax error in INSERT INTO statement.: IN, mwriteInputFiles.sol.” I guess I have somehow an inappropriate value somewhere, but I can’t figure out where..

        Best,

        Timo

      4. Hi Timo,

        It seems you can post any file or screenshot here. Please send them to my email at (hawklorry@gmail.com).

        For the error, I may need to see the soil file you use. It seems that happens when writing information to sol table.

        Best
        Zhiqiang

  19. Hi zhiqiangyu
    My name Tesfahun and im from Ethiopia. Im using ArcSWAT/SWAT 2009. and i had problem with Weather generator input file. Actually i prepared the format that SWat requires. But it shows the “No value given for one or more parameters. IN,mWriteinputefile.Ggn.”

  20. Helo dear

    I am wondering if you can help me in this problem

    (“syntax error in insert into statement.: in, mwriteinputfiles.sol”)

    I probably guess the error is related to my soil data, my user soil has two sources which are merged together. You can also look at my user soil (see attachment).
    Kind regards

    Mekuanent M.

    Ethiopia

  21. IN, mWriteInputFiles.sol error occurs, i had checked project data as well as programme data, in both folder i have entered soil data in usersoil (ms access file), i am facing same problem

  22. Hi zhiqiangyu
    I am Tamiru G, working MSc Research using ArcSWAT version 10.4 that I faced error message during HRU Analysis: the land use portion has no problem but the soil data portion has problems of error message saying “The soil ‘ ‘ does not exist in the usersoils database. Correct problem and try again”. I used soil map of Ethiopia by clipping my study area and prepared lookup table accordingly. when I tried calling each soil one by one by double clicking on the soil table spaces, all my soil data i stored in usersoil database appeared and overlaid. Through that process I completed the HRU portion and when I start Write Input Tables portion it finished the Weather Stations portion properly but not work the Write SWAT Input Tables portion. I don’t know what is my error and I wonder if you tell me any solution. Thank you.

  23. hi, I´m having problems when I try to update data of temperature, it says: index is outside of the array: in reading line 0, what can I do???

  24. Dear zhiqiangyu,

    please Suggest me how to fix this problem. this is the error message
    “conversion from type ‘dbnull’ to type ‘string’ is not valid..in,mwriteinputfiles.mgt” I was trying many times but no change at all.

Leave a Reply to thengineeringconstructionplc Cancel reply