How one can find the starting and end point of a line in a vector file or how one can connect two line end to end using C code

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

How one can find the starting and end point of a line in a vector file or how one can connect two line end to end using C code

SWAPAN GHOSH
Hello,
 
Any one can solve me the problem like-" How one can find the starting and end point of a line in a vector file or how one can connect two line end to end using C code". If there is any change needed in code like C or  Python Script please suggest me. How I can do it.
 
Regards,
 
Swapan

_______________________________________________
grass-user mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/grass-user
Reply | Threaded
Open this post in threaded view
|

Re: How one can find the starting and end point of a line in a vector file or how one can connect two line end to end using C code

ivan.marchesini
don't know if can help but v.to.db give you coordinates of starting and
ending points of vector lines

to connect them I use v.edit

this is my pythin code

    startc=grass.read_command("v.to.db", flags="p", map="myline",
type="line", option="start", units="meters" , quiet=True)
    startx=float(startc.split("|")[1])
    starty=float(startc.split("|")[2])
    startz=float(startc.split("|")[3])
    endc=grass.read_command("v.to.db", flags="p", map="myline",
type="line", option="end", units="meters")
    endx=float(endc.split("|")[1])
    endy=float(endc.split("|")[2])
    endz=float(endc.split("|")[3])

    tmpfile = grass.tempfile()
    pfile = open(tmpfile, 'w')
    print>> pfile, "L", "2", "1"
    print>> pfile, startx, starty, startz
    print>> pfile, endx, endy, endz
    print>> pfile, "1", i
    pfile.close()
    grass.run_command("v.edit", input=tmpfile, flags="n", tool="add",
map="mynewline", snap="node", thresh="1")


hope this help

Ivan


Il giorno sab, 03/03/2012 alle 11.24 +0530, SWAPAN GHOSH ha scritto:

> Hello,
>  
> Any one can solve me the problem like-" How one can find the starting
> and end point of a line in a vector file or how one can connect two
> line end to end using C code". If there is any change needed in code
> like C or  Python Script please suggest me. How I can do it.
>  
> Regards,
>  
> Swapan
> _______________________________________________
> grass-user mailing list
> [hidden email]
> http://lists.osgeo.org/mailman/listinfo/grass-user
--
Ti prego di cercare di non inviarmi files .dwg, .doc, .xls, .ppt.
Preferisco formati liberi.
Please try to avoid to send me .dwg, .doc, .xls, .ppt files.
I prefer free formats.
http://it.wikipedia.org/wiki/Formato_aperto
http://en.wikipedia.org/wiki/Open_format

Ivan Marchesini
Perugia (Italy)
Socio fondatore GFOSS "Geospatial Free and Open Source Software" http://www.gfoss.it
e-mail: [hidden email]
        [hidden email]
fax (mailfax): +39 1782092534
jabber: [hidden email]
skype: geoivan73

_______________________________________________
grass-user mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/grass-user

signature.asc (205 bytes) Download Attachment