---
# System prepended metadata

title: Note for testing `catchment-generator`
tags: [h2beaver]

---

###### tags: `h2beaver`
# Note for testing `catchment-generator` 


## Can't open `grass`
:::danger
GLib-GObject-WARNING **: cannot register existing type 'GtkIMContext'

GLib-CRITICAL **: g_once_init_leave: assertion 'result != 0' failed

GLib-GObject-CRITICAL **: g_type_register_dynamic: assertion 'parent_type > 0' failed

GLib-GObject-CRITICAL **: g_object_new_with_properties: assertion 'G_TYPE_IS_OBJECT (object_type)' failed

:::
### The 1st try: check the version of python2
```
Python 2.7.15rc1 (default, Nov 12 2018, 14:31:15) 
[GCC 7.3.0] on linux2
```
Check some pages in https://grass.osgeo.org/download/software/linux/
Not sure.


### The 2nd try: 
- google by
```
(gis_set.py:32374): GLib-GObject-WARNING **: 00:16:29.694: cannot register existing type 'GtkIMContext'
```

- I got
https://www.ptt.cc/bbs/Linux/M.1540316842.A.0E8.html
https://www.ptt.cc/bbs/Linux/M.1520137230.A.0E8.html
Implying the problem is cause by input method `hime`



- I change
`Region & Language` >> 
`Manage Installed Languages` >> 
`Keyboard input method system` >> 
choose `iBus` to replace the previous `hime`
- Add `English (US)` to `Input Sources`
- Also chang
`Input Method` >> 
`OK` >> 
`Yes` >> 
select `default`
- Reboot

### Success!!!
`$ grass` works!!!


## Run script via python2
### Find your GRASS GIS Application directory
`GRASS7BIN_LIN = '/usr/lib/grass76'
`

### Install python dependency
`pip install -r requirements.txt`
:::danger
Could not open requirements file: [Errno 2] No such file or directory: 'requirements.txt'
:::
### Run `App.py`
```
python App.py -d 97LanYang(5mDEM)(ArcGis)_(dig).asc -c channel_lanyang.shp -p h2 -h 30 -w 200 -b "2711707;2704385;295588;285588"
```
:::danger
bash: syntax error near unexpected token \`(\'
:::

:::success
We should use " " for non-canonical file path.
:::


```
python App.py -d 97LanYang(5mDEM)(ArcGis)_(dig).asc -c channel_lanyang.shp -p h2 -h 30 -w 200 -s c2560_tw97.shp
```
:::danger
bash: syntax error near unexpected token \`(\'
:::
:::success
We should use " " for non-canonical file path.
:::
```
python App.py --help
```
:::success
Usage:
App.py
 -d <dem_file_name>
 -c <channel_shapefile_name>
 
Optional:
 -p <prefix name of ouput file, defaut is h2_>
 -t <threshold for catchment (default is 30000)>
 -m <max slope length of catchment (default is 1000)>
 -h <depth for channel (default is 20)>
 -w <width for channel in meter (default is 300)>
 -b <boundary coordinates for computation. Foramt should be "N;S;E;W">
 -s <boundary shp for computation>

:::
