# Parallelization Example

# Create 100 random points and add X and Y coords to table
grass.run_command("v.random",
		overwrite = True,
		output="randpoints",
		n=3)
grass.run_command("v.db.addtable",
		map = "randpoints",
		columns="X DOUBLE, Y DOUBLE")
grass.run_command("v.to.db",
		map = "randpoints",
		option = "coor",
		columns ="X,Y")

# Extract X,Y coords to "pointcoords"
pointcoords = grass.read_command("v.db.select",
		flags = "c",
		fs ="|",
		map = "randpoints",
		columns = "cat,X,Y")

# Version 1 : Loop over the points
for line in pointcoords.split():
	cat,X,Y = line.split('|')
	coordinate = str(X)+","+str(Y)

	grass.run_command("r.cost",
		input="geology@PERMANENT",
		output="costarea"+str(cat),
		coordinate=coordinate,
		max_cost=100)

# Version 2: Pseudo parallelization??

