- """coordonnées du premier sommet""" 
- debligne =grass.read_command("v.to.db", flags="p", map="testgrass", type="line", option="start", units="meters" , quiet=True) 
- debx=float(debligne.split("|")[1]) 
- deby=float(debligne.split("|")[2]) 
- debz=float(debligne.split("|")[3]) 
-   
- """coordonnées du deuxième sommet""" 
- finligne=grass.read_command("v.to.db", flags="p", map="testgrass",type="line", option="end", units="meters", quiet=True) 
- finx=float(finligne.split("|")[1]) 
- finy=float(finligne.split("|")[2]) 
- finz=float(finligne.split("|")[3]) 
-   
- """création d'une couche vide testpt""" 
- grass.read_command("v.edit",tool="create",map="testpt") 
-   
- """création d'un fichier temporaire au format standard: 
- P  1 1 
- 186139.12370417 53082.65419398 
- 1 1         
- P  1 1 
- 188199.1227985 53467.75855873 
- 1 2""" 
- fichtemp = grass.tempfile() 
- pfich = open(fichtemp, 'w') 
- print>> pfich, "P", "1", "1" 
- print>> pfich, debx, deby, debz 
- print>> pfich, "1", 1 
- print>> pfich, "P", "1", "1" 
- print>> pfich, finx, finy, finz 
- print>> pfich, "1", 2 
- pfich.close() 
-   
- """importation des points dans la couche testpt""" 
- grass.run_command("v.edit", input=fichtemp, flags="n", tool="add",map="testpt", snap="node", thresh="1")