[Qgis-user] Creating spatially derived vectors
Lester Anderson
arctica1963 at gmail.com
Sat Jan 12 14:34:22 PST 2013
Hi Micha,
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?
>From the way your script looks,it should be possible, but it looks somewhat
convoluted.
I have tried to make a worflow to explain:
1. Load up shapefle containing polylines
2. Select two lines to compute
On 11 January 2013 15:22, Micha Silver <micha at arava.co.il> wrote:
> Hi Lester:
> 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.
> Here's a (contrived) example that might help get you going. I copied the
> lines below from the spatialite-gui sql query window.
>
>
> On 01/11/2013 09:20 AM, Lester Anderson wrote:
>
> Hi Micha,
>
> 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.
> However, the script you showed did not work (did not like the auto
> increment, removed that bit and still no joy).
>
> # First I create a table for the lines, and make it a geometry table
> CREATE TABLE lines (pk_uid INTEGER PRIMARY KEY AUTOINCREMENT, line_name
> text);
> SELECT AddGeometryColumn('lines','geometry',4326,'LINESTRING',2);
>
> # Now I add two lines, named "line1" and "line2" . THis is beginning to
> sound like Dr. Seuss ;-)
> # I use the GeomFromText() function to make two LINESTRING features
> INSERT INTO lines (geometry, line_name) VALUES (
> GeomFromText("LINESTRING(1 1,2 2,2 5,3 6)",4326),
> "line1");
> INSERT INTO lines (geometry, line_name) VALUES (
> GeomFromText("LINESTRING(0 0,0 4,1 7)",4326),
> "line2");
>
> # Next create the table for the medians, and make it also a geometry table:
> CREATE TABLE median (pk_uid integer primary key autoincrement);
> SELECT AddGeometryColumn('median','geometry',4326,'LINESTRING',2);
>
> # Now the INSERT INTO...SELECT FROM statement to create the median.
> # Here I'm selecting two separate line features from the same layer,
> # and creating a median between them by using a WHERE clause.
> INSERT INTO median (geometry) SELECT
> MakeLine(Line_Interpolate_Point(l1.geometry, 0.5),
> Line_Interpolate_Point(l2.geometry, 0.5))
> AS geometry
> FROM lines AS l1, lines AS l2
> WHERE l1.line_name="line1" AND l2.line_name="line2";
>
> Have a look at the result in the attached screenshot
>
> Cheers,
> Micha
>
>
>
> 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.
>
>
> That's no good!
>
>
> Cheers
>
> Lester
>
> On 10 January 2013 08:58, Micha Silver <micha at arava.co.il> wrote:
>
>> On 10/01/2013 09:21, Lester Anderson wrote:
>>
>> Hello,
>>
>> 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?
>>
>>
>> If you store your vectors in a spatialite database (or PostGIS) then it
>> would be something like:
>> # Create the target line vector
>> CREATE TABLE median (pk_uid PRIMARY KEY AUTOINCREMENT);
>> SELECT AddGeometryColumn("median","LINESTRING",<your srid>,"geometry",2);
>> # make the median and insert into table
>> INSERT INTO median SELECT MakeLine(
>> ST_LineInterpolatePoint(line1.geometry, 0.5),
>> ST_LineInterpolatePoint(line2, 0.5) )
>> AS geometry
>> FROM line1, line2
>>
>> Cheers,
>> Micha
>>
>> Thanks
>>
>> Lester
>>
>> This mail was received via Mail-SeCure System.
>>
>>
>> _______________________________________________
>> Qgis-user mailing listQgis-user at lists.osgeo.orghttp://lists.osgeo.org/mailman/listinfo/qgis-user
>>
>> This mail was received via Mail-SeCure System.
>>
>>
>>
>>
>>
>> --
>> Micha Silver
>> GIS Consulting
>> 052-3665918http://www.surfaces.co.il
>>
>>
>
> This mail was received via Mail-SeCure System.
>
>
>
> --
> Micha Silver
> GIS Consultant, Arava Development Co.http://www.surfaces.co.il
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20130112/76e3df2d/attachment.html>
More information about the Qgis-user
mailing list