Hi Micha,<br><br>I was not able to get your script to work, but maybe I did not understand the way the spatialite layer works. It looks like the script generates the vector lines: what I need is a way to use a couple polylines in a layer that are selected and generate a mean line between the two (attached image). So in essence is there a simpe way to compute the mean distance between two polylines and interpolate the a new median polyline?<br>
<br>From the way your script looks,it should be possible, but it looks somewhat convoluted.<br><br>I have tried to make a worflow to explain:<br><br>1. Load up shapefle containing polylines<br>2. Select two lines to compute<br>
<br><div class="gmail_quote">On 11 January 2013 15:22, Micha Silver <span dir="ltr"><<a href="mailto:micha@arava.co.il" target="_blank">micha@arava.co.il</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

  
    
    
  
  <div style="direction:ltr" bgcolor="#FFFFFF" text="#000000">
    Hi Lester:<br>
    I see I omitted the INTEGER type definition in the first CREATE
    TABLE statement. That certainly won't work, and probably was the
    cause of your problem.<br>
    Here's a (contrived) example that might help get you going. I copied
    the lines below from the spatialite-gui sql query window.<div class="im"><br>
    <br>
    On 01/11/2013 09:20 AM, Lester Anderson wrote:
    <blockquote type="cite">Hi Micha,<br>
      <br>
      Thanks for the information. I managed to generate a spatialite
      layer and copied the two test lines from my normal vector layer
      into it, that was all fine.<br>
      However, the script you showed did not work (did not like the auto
      increment, removed that bit and still no joy).<br>
      <br>
    </blockquote></div>
    # First I create a table for the lines, and make it a geometry table<br>
    CREATE TABLE lines (pk_uid INTEGER PRIMARY KEY AUTOINCREMENT,
    line_name text);<br>
    SELECT AddGeometryColumn('lines','geometry',4326,'LINESTRING',2);<br>
    <br>
    # Now I add two lines, named "line1" and "line2" . THis is beginning
    to sound like Dr. Seuss ;-)<br>
    # I use the GeomFromText() function to make two LINESTRING features<br>
    INSERT INTO lines (geometry, line_name) VALUES (<br>
        GeomFromText("LINESTRING(1 1,2 2,2 5,3 6)",4326),<br>
        "line1");<br>
    INSERT INTO lines (geometry, line_name) VALUES (<br>
    GeomFromText("LINESTRING(0 0,0 4,1 7)",4326),<br>
    "line2");<br>
    <br>
    # Next create the table for the medians, and make it also a geometry
    table:<br>
    CREATE TABLE median (pk_uid integer primary key autoincrement);<br>
    SELECT AddGeometryColumn('median','geometry',4326,'LINESTRING',2);<br>
    <br>
    # Now the INSERT INTO...SELECT FROM statement to create the median.<br>
    # Here I'm selecting two separate line features from the same layer,
    <br>
    # and creating a median between them by using a WHERE clause. <br>
    INSERT INTO median (geometry) SELECT<br>
    MakeLine(Line_Interpolate_Point(l1.geometry, 0.5), <br>
        Line_Interpolate_Point(l2.geometry, 0.5))<br>
    AS geometry<br>
    FROM lines AS l1, lines AS l2<br>
    WHERE l1.line_name="line1" AND l2.line_name="line2";<br>
    <br>
    Have a look at the result in the attached screenshot<br>
    <br>
    Cheers,<br>
    Micha<div class="im"><br>
     <br>
    <blockquote type="cite">Do you have a functional example you could send to see
      if I am doing anything wrong? The SQL and QGis crashes trying to
      do this.<br>
      <br>
    </blockquote>
    <br></div>
    That's no good!<div><div class="h5"><br>
    <br>
    <blockquote type="cite">Cheers<br>
      <br>
      Lester<br>
      <br>
      <div class="gmail_quote">On 10 January 2013 08:58, Micha Silver <span dir="ltr"><<a href="mailto:micha@arava.co.il" target="_blank">micha@arava.co.il</a>></span>
        wrote:<br>
        <blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
          <div style="direction:ltr" text="#660000" bgcolor="#FFFFFF">
            <div>
              <div>On 10/01/2013 09:21, Lester Anderson wrote:<br>
              </div>
              <blockquote type="cite"> Hello,<br>
                <br>
                Given say two digitised polylines, is it possible to
                create a new polyline between the two target lines that
                would be the exact median line? <br>
                <br>
              </blockquote>
              <br>
            </div>
            If you store your vectors in a spatialite database (or
            PostGIS) then it would be something like:<br>
            # Create the target line vector<br>
            CREATE TABLE median (pk_uid PRIMARY KEY AUTOINCREMENT);<br>
            SELECT AddGeometryColumn("median","LINESTRING",<your
            srid>,"geometry",2);<br>
            # make the median and insert into table<br>
            INSERT INTO median SELECT MakeLine(<br>
                ST_LineInterpolatePoint(line1.geometry, 0.5),
            ST_LineInterpolatePoint(line2, 0.5) )<br>
                AS geometry<br>
                FROM line1, line2<br>
            <br>
            Cheers,<br>
            Micha<br>
            <blockquote type="cite">Thanks<br>
              <br>
              Lester<br>
              <br>
              This mail was received via Mail-SeCure System.<br>
              <br>
              <fieldset></fieldset>
              <br>
              <pre>_______________________________________________
Qgis-user mailing list
<a href="mailto:Qgis-user@lists.osgeo.org" target="_blank">Qgis-user@lists.osgeo.org</a>
<a href="http://lists.osgeo.org/mailman/listinfo/qgis-user" target="_blank">http://lists.osgeo.org/mailman/listinfo/qgis-user</a>

This mail was received via Mail-SeCure System.


</pre>
              <span><font color="#888888"> </font></span></blockquote>
            <span><font color="#888888"> <br>
                <br>
                <pre cols="72">-- 
Micha Silver
GIS Consulting
052-3665918
<a href="http://www.surfaces.co.il" target="_blank">http://www.surfaces.co.il</a>
</pre>
              </font></span></div>
        </blockquote>
      </div>
      <br>
      <br>
      This mail was received via Mail-SeCure System.<br>
    </blockquote>
    <br>
    <br>
    </div></div><span class="HOEnZb"><font color="#888888"><pre cols="72">-- 
Micha Silver
GIS Consultant, Arava Development Co.
<a href="http://www.surfaces.co.il" target="_blank">http://www.surfaces.co.il</a></pre>
  </font></span></div>

</blockquote></div><br>