[GRASS-user] loop import+merge
Patrick_schirmer
patrick_GIS at gmx.ch
Tue Dec 14 09:19:55 EST 2010
Manfred, Martin,
Thanks. That was what I was searching for so urgent!
This one works even it might not be the nicest one:
(flag-comment of Martin not included yet)
#!/usr/bin/env python
#will import through loop
import os
import sys
import grass.script as grass
def main():
i=1
n=1
i=str(i)
#first "loop" no merge, but creates first template
grass.run_command(
'v.in.ogr', flags="o", dsn="PG:dbname=schirpat",
layer="sc.av_liegensch", output="GR_av_liegensch_poly_temp",
type="boundary,centroid", where="bfs="+i)
while n<5:
n=n+1
i=int(i)
i=i+1
i=str(i)
grass.run_command(
'v.in.ogr', flags="o", dsn="PG:dbname=schirpat",
layer="sc.av_liegensch", output="GR_av_liegensch_poly"+i,
type="boundary,centroid", where="bfs="+i)
grass.run_command(
'v.patch',flags="-o",
input="GR_av_liegensch_poly"+i+",GR_av_liegensch_poly_temp",
output="GR_av_liegensch_poly")
grass.run_command(
'g.remove', vect="GR_av_liegensch_poly_temp")
grass.run_command(
'g.rename',
vect="GR_av_liegensch_poly,GR_av_liegensch_poly_temp")
grass.run_command(
'g.rename', vect="GR_av_liegensch_poly_temp,GR_av_liegensch_poly")
More information about the grass-user
mailing list