Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Simple combine script with rasterio
tmiddelkoop committed Dec 9, 2021
1 parent 31cf78a commit fd38405
Showing 3 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -6,3 +6,4 @@ config*
token*
local*
data/
output/
7 changes: 7 additions & 0 deletions landsat/ReadMe.md
@@ -36,3 +36,10 @@ cd CLASS-Examples/landsat/
bash get-index.sh
cat data/index.csv | python3 search.py | bash download.sh
```

## Analysis
```
sudo apt-get install python3-rasterio
install -dv output/
python3 combine.py
```
17 changes: 17 additions & 0 deletions landsat/combine.py
@@ -0,0 +1,17 @@
#!/usr/bin/python3
import os
import rasterio

# Open the first directory, could walk entire tree
for dirname, dirs, files in os.walk('data'):
source = dirs[0]
break

with rasterio.open("data/%s/%s_B2.TIF" % (source, source)) as band2:
meta = band2.meta

meta.update(count = 3, driver='PNG')
with rasterio.open('output/result.png', 'w+', **meta) as output:
for i in range(1, 4):
print(i)
output.write_band(i,rasterio.open("data/%s/%s_B%d.TIF" % (source, source, i+3)).read(1)) # Red

0 comments on commit fd38405

Please sign in to comment.