Design base Python class for communication with GRASS GIS.
class ErosionBase:
def __init__(self):
# 1. establish connection with GRASS
def import(self, [filepath1, filepath2]):
# call self._import in loop
def _import(self, filepath):
# 1. create new location (need to define srs) and mapset - only for first imported file
# 2. determine using GDAL file type (raster, vector, table - vector without geometry)
if raster:
# link using GRASS module r.external
elif vector:
# import using v.import (includes also transformation if srs differs) or v.in.ogr
else: # table
# import csv file using db.in.ogr
def export(self, dest_dir):
# export output data (rasters - r.out.gdal, vectors - v.out.ogr) to destination directory
Design base Python class for communication with GRASS GIS.