# 使用Rio Calc¶

## 表达¶

rio calc表达式看起来像

```(func|operator arg [*args])
```

## 拷贝一个文件¶

```\$ rio calc "(read 1)" tests/data/RGB.byte.tif out.tif
```

## 反转文件的带顺序¶

```\$ rio calc "(asarray (read 1 3) (read 1 2) (read 1 1))" tests/data/RGB.byte.tif out.tif
```

## 多个文件的堆叠带¶

```\$ rio calc "(asarray (read 1 1) (read 2 2) (read 3 3))" \
> tests/data/RGB.byte.tif tests/data/RGB.byte.tif tests/data/RGB.byte.tif \
> out.tif
```

## 命名数据集¶

```\$ rio calc "(asarray (take a 3) (take a 2) (take a 1))" \
> --name "a=tests/data/RGB.byte.tif" out.tif
```

```\$ rio calc "(asarray (take a 1) (take b 2) (take b 3))" \
> --name "a=tests/data/RGB.byte.tif" --name "b=tests/data/RGB.byte.tif" \
> --name "c=tests/data/RGB.byte.tif" out.tif
```

## 阅读和记录¶

```\$ rio calc "(take (read 1) 1)" tests/data/RGB.byte.tif out.tif
```

## 算术运算¶

```\$ rio calc "(+ 2 (* 0.95 (read 1)))" tests/data/RGB.byte.tif out.tif
```

```\$ rio calc "(asarray (+ 2 (* 0.95 (read 1 1))) (+ 3 (* 0.9 (read 1 2))) (+ 4 (* 0.85 (read 1 3))))" tests/data/RGB.byte.tif out.tif
```

## 逻辑运算¶

```\$ rio calc "(* (>= (read 1) 40) 255)" tests/data/RGB.byte.tif out.tif
```