In [19]:
import matplotlib.image as mpimg
import matplotlib.pyplot as plt
import grass.script as grass
import grass.script.setup as gsetup
rundir = 'grassdata'
location = 'location'
In [9]:
gisbase = os.environ['GISBASE'] = '/usr/lib/grass74'
gisdbase = os.path.join(os.environ['HOME'], rundir)
sys.path.append(os.path.join(os.environ['GISBASE'], "etc", "python"))
gsetup.init(gisbase,gisdbase, location, 'PERMANENT')
grass.read_command('g.region',raster='image.tif@PERMANENT',flags='p')
Out[9]:
In [17]:
a=grass.read_command('d.histogram', map='image.tif@PERMANENT',style='bar')
In [15]:
os.environ['GRASS_RENDER_IMMEDIATE']='png'
os.environ['GRASS_RENDER_TRUECOLOR']='TRUE'
In [26]:
import os
img=mpimg.imread('map.png')
fig, ax = plt.subplots(figsize=(180, 20))
ax.imshow(img)
Out[26]:
In [13]:
gisdbase
Out[13]: