-
Notifications
You must be signed in to change notification settings - Fork 3
/
helper.py
39 lines (27 loc) · 891 Bytes
/
helper.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!usr/bin/env python3
import os
import sys
import subprocess
import folium
import json
def initialize_GRASS_notebook(binary, grassdata, location, mapset):
# create GRASS GIS runtime environment
sys.path.append(
subprocess.check_output([binary, "--config", "python_path"], text=True).strip()
)
# do GRASS GIS imports
import grass.script as gs
import grass.jupyter as gj
# set GRASS GIS session data
return gj.init(grassdata, location, mapset)
def show(raster):
import grass.jupyter as gj
render_map = gj.Map()
render_map.d_rast(map=raster)
render_map.d_vect(map="counties", fill_color="none", width=2)
return render_map.show()
def show_interactively(raster, opacity=0.8):
import grass.jupyter as gj
render_map = gj.InteractiveMap()
render_map.add_raster(raster, opacity=opacity)
return render_map.show()