[Manifold-l] Need some help with lines and slopes

JBurn_GIS jburn_gis at cogeco.ca
Mon Oct 9 21:27:09 CDT 2006


>>snip>>>
I assume that this will enable me to use the same
table for multiple line segments, which means I will need to create another
field to keep track of each distinct line segment.
<<<snip<<<
Yes, while not necessary (there are ways of doing the spatial overlays etc.), this would be easiest.
Your approach sounds good.  To be honest, I always just use saved selections and spatial overlays as opposed to scripting.  Mainly due to my poor scripting ability;-)

Cheers.
---------------
James Burn BSc, GIS(pg), AScT
  ----- Original Message ----- 
  From: Lenny Kong 
  To: manifold-l at lists.directionsmag.com 
  Sent: Saturday, October 07, 2006 4:31 PM
  Subject: [Manifold-l] Need some help with lines and slopes


  Thank you for your quick responses, I apologize for my slow response.

  Dimitri:  Definitely a technically superior approach to what I had in mind.
  Perhaps a overkill.

  Jim:  Your approach suits me better.   I was really only interested in
  getting the slope and length between two points.  While your solution works
  (I haven't tried it yet), it requires that I define the points in sequential
  order, which is reasonable, but also requires that I assign an id based on
  that sequential order.  I assume that this will enable me to use the same
  table for multiple line segments, which means I will need to create another
  field to keep track of each distinct line segment.

  Is it possible to trap the insert point event?  If it is possible, then can
  I populate a table with the from - to information?  My plan would be to
  write a script that would:
  1.  Activate a new sequence flag and enter into a loop that would
  2.  capture each insert point, the first one would deactivate the new
  sequence flag and identify a previous point id.
  3.  insert into a table a new row consisting of From, To, perhaps horizontal
  distance between them.
  4.  return from the capture ready to capture the next event.
  5.  Eventually, I would need a way to drop out of the loop.

  Once I know that I have a workable approach, I can confidently pursue
  implementation.  Although I haven't worked with Manifold before, I didn't
  see anything in the documentation at sounded like capturing events.

  Lenny



  ----------------------------------------------------------------------

  Message: 1
  Date: Tue, 3 Oct 2006 16:41:38 -0700
  From: "Dimitri Rotow" <dar at manifold.net>
  Subject: RE: [Manifold-l] Need some help with lines and slopes
  To: "'Manifold List Server'" <manifold-l at lists.directionsmag.com>
  Message-ID: <200610032341.k93NfUZ2029019 at web2.directionsmag.com>
  Content-Type: text/plain; charset="us-ascii"


  > I have a map with two drawings, a surface where I can run my 
  > mouse cursor over and it will report a z-value, and an empty 
  > drawing.  I would like to draw a segmented line on the empty 
  > drawing layer and get back the length and slope of the line 
  > based on the underlying z-values.  I can seem to figure out 
  > if this is a spatial or topology overlay problem.  The 
  > transfer heights transform only returns the height (sum, 
  > average, ... ) of the centroid of the line.  Any suggestions 
  > on how to approach this problem would be appreciated.

  You'll have to script either of these.  The two tasks are related as they
  are both riffs on computing elementary values of a right triangle.

  First, though, let's consider the "slope" of the line.  A line traversing an
  irregular surface will have no single slope value.  Consider, for example, a
  road that goes up a hill and then down a hill.  There's no one "slope" to
  that road. There may be a slope for any one straight line segment, and you
  might compute an "average" slope by an arithmetic aggregation of slopes for
  individual line segments that comprise the polyline, but if you want to
  attach just one "slope" number to the line you are going to have to decide
  what sort of approximation or aggregation you want that number to be.

  To get the 3D length of a line you first decompose it into individual line
  segments.  You know the height of both ends of each segment, so you know the
  difference in height between the segments.  You know the length of the line
  segment.  Using the Pythagorean formula you can find the length of the
  hypoteneuse given the length of the base of a right-angle triangle (the
  length of the line segment) and the height of the triangle (the difference
  in z of the end points).  Add the hypoteneuse lengths of all the line
  segments for the line to get the length of the line.

  You could use a similar process to compute the slope of each segment.  You
  know the length of the segment and the difference in heights and even (from
  the above) the length of the hypotenuse.  It's therefore a simple
  calculation to get the value of the acute angle between the base and the
  hypoteneuse.  Once you have the slope for each line segment you can decide
  how you want to aggregate them to get some sort of average or combined slope
  for the line.

  You could simplify the script by doing some manual work.  For example,
  create points at each coordinate of a line and then transfer heights from
  the surface to each point. This and suitable "flag" attributes used wisely
  will simplify the scripts. 

  Cheers,

  Dimitri



  ------------------------------

  Message: 2
  Date: Tue, 3 Oct 2006 23:20:32 -0400
  From: "JBurn_GIS" <jburn_gis at cogeco.ca>
  Subject: Re: [Manifold-l] Need some help with lines and slopes
  To: <lkong at engenious.com>, "Manifold List Server"
  <manifold-l at lists.directionsmag.com>
  Message-ID: <000801c6e764$0d415890$6700a8c0 at Chimera>
  Content-Type: text/plain; charset="iso-8859-1"

  A couple of thoughts come to mind involving spatial SQL.

  First, the set up:
  Don't bother with the actual line at this time, just draw your the
  individual inflection points in the order of how your line direction will
  move.  So you should have a surface and a point drawing, with the points in
  a "from-to" order.  Now transfer your heights to those points.  You should
  now have points in a proper order that have Z values.  Please note that the
  KEY to this method is that your points are in a good logical order.

  Now, assign an ID number in a sequential order to your points.  Now for the
  spatial SQL part.  The following is an example of some SQL that I used to
  perform a similar task:

  select
       [point drawing].[Geom (I)],
       [point drawing].[ID] as [from],
       [point drawing].[Z value] as [from z], 
       [Copy].[ID] as [to], 
       [Copy].[Z value] as [to z], 
       (([Copy].[Z value] - [point drawing].[Z value])/(Distance([point
  drawing].[ID], [Copy].[ID]))) as slope, 
       ([Copy].[Z value] - [point drawing].[Z value]) as [Difference]
  into [new table]
  from [point drawing], [point drawing] as [Copy]
  where ([point drawing].[ID] + 1) = [Copy].[ID]

  Ok, running though it.  Note that I have used only one table, but selected
  it twice calling it "copy" the second time.  Sort of a "virtual table" if
  you will.  I'm linking the table and its "virtual" self with ID and ID+1.
  This causes the equasions to happen between a point and the next point in
  order (hence the importance of getting them ordered correctly at the start).
  Then I start doing some basic math and SQL selections in terms of selecting
  the Geom (so I can re-make my points later), my ID, Z value, slope (rise
  over run), and note that it is using the actual distance between the points.
  In the end, you should end up with a new table (with a geom field) that
  contains the "from" ID and Z value, the "to" ID and Z value which is
  gathered from the next point in the sequence, the difference between the
  two, and the slope as solved by z"-z'/distance.  The results of the above
  query look something like this in CSV format:

  Geom (I), from, from z, to, to z, slope, Difference
  <geom, point>, 733419, 754.29, 733420, 754.29, 0.00, 0.00
  <geom, point>, 733420, 754.29, 733421, 754.26, -0.00, -0.03
  <geom, point>, 733421, 754.26, 733422, 754.18, -0.01, -0.08
  <geom, point>, 733422, 754.18, 733423, 754.13, -0.01, -0.05

  Since we carried the Geom(I) field, you can now easily conver this to a
  point drawing where each point will have the slope and difference between
  "it" and the next point, which could in turn be pushed on to a corresponding
  line segment via spatial overlay.

  Hope that helps a little, or at least gives you some ideas.
  Cheers.


  ---------------
  James Burn BSc, GIS(pg), AScT
    ----- Original Message ----- 
    From: lkong at engenious.com 
    To: Manifold List Server 
    Sent: Monday, October 02, 2006 9:30 PM
    Subject: [Manifold-l] Need some help with lines and slopes


    Hi:

    I have a map with two drawings, a surface where I can run my mouse cursor
    over and it will report a z-value, and an empty drawing.  I would like to
    draw a segmented line on the empty drawing layer and get back the length
    and slope of the line based on the underlying z-values.  I can seem to
    figure out if this is a spatial or topology overlay problem.  The transfer
    heights transform only returns the height (sum, average, ... ) of the
    centroid of the line.  Any suggestions on how to approach this problem
    would be appreciated.

    Thanks
    Lenny



    _______________________________________________

  Message: 3
  Date: Tue, 3 Oct 2006 23:26:06 -0400
  From: "JBurn_GIS" <jburn_gis at cogeco.ca>
  Subject: Re: [Manifold-l] Need some help with lines and slopes
  To: "Dimitri Rotow" <dar at manifold.net>, "'Manifold List Server'"
  <manifold-l at lists.directionsmag.com>
  Message-ID: <000f01c6e764$d44511c0$6700a8c0 at Chimera>
  Content-Type: text/plain; charset="iso-8859-1"

  Dimitri makes a good point (as usual;-) in that the method I described give
  the slope between points, and not necessarily of the surface.  Sort of a
  slope "how the worm digs" so to speak.  Technically, if you added more
  points, so you have "lots" of points traversing the length of the line,
  these could then be combined or looked at separately.

  For one job, for example, I have a bunch of points that all line up for
  about 200 meters.  Looking at the slope values though, one can see that the
  slope actually goes from a 5% grade, to a 10% grade to a 7% grade over the
  200m distance.  For that particular task, I grouped the points by rounded
  grade, and created the line segments appropriately, so instead of one 200m
  line at an averaged (ok, average isn't the right word) grade, I had three at
  their individual slopes.

  Cheers.

  ---------------
  James Burn BSc, GIS(pg), AScT
    ----- Original Message ----- 
    From: Dimitri Rotow 
    To: 'Manifold List Server' 
    Sent: Tuesday, October 03, 2006 7:41 PM
    Subject: RE: [Manifold-l] Need some help with lines and slopes



    > I have a map with two drawings, a surface where I can run my 
    > mouse cursor over and it will report a z-value, and an empty 
    > drawing.  I would like to draw a segmented line on the empty 
    > drawing layer and get back the length and slope of the line 
    > based on the underlying z-values.  I can seem to figure out 
    > if this is a spatial or topology overlay problem.  The 
    > transfer heights transform only returns the height (sum, 
    > average, ... ) of the centroid of the line.  Any suggestions 
    > on how to approach this problem would be appreciated.

    You'll have to script either of these.  The two tasks are related as they
    are both riffs on computing elementary values of a right triangle.

    First, though, let's consider the "slope" of the line.  A line traversing
  an
    irregular surface will have no single slope value.  Consider, for example,
  a
    road that goes up a hill and then down a hill.  There's no one "slope" to
    that road. There may be a slope for any one straight line segment, and you
    might compute an "average" slope by an arithmetic aggregation of slopes
  for
    individual line segments that comprise the polyline, but if you want to
    attach just one "slope" number to the line you are going to have to decide
    what sort of approximation or aggregation you want that number to be.

    To get the 3D length of a line you first decompose it into individual line
    segments.  You know the height of both ends of each segment, so you know
  the
    difference in height between the segments.  You know the length of the
  line
    segment.  Using the Pythagorean formula you can find the length of the
    hypoteneuse given the length of the base of a right-angle triangle (the
    length of the line segment) and the height of the triangle (the difference
    in z of the end points).  Add the hypoteneuse lengths of all the line
    segments for the line to get the length of the line.

    You could use a similar process to compute the slope of each segment.  You
    know the length of the segment and the difference in heights and even
  (from
    the above) the length of the hypotenuse.  It's therefore a simple
    calculation to get the value of the acute angle between the base and the
    hypoteneuse.  Once you have the slope for each line segment you can decide
    how you want to aggregate them to get some sort of average or combined
  slope
    for the line.

    You could simplify the script by doing some manual work.  For example,
    create points at each coordinate of a line and then transfer heights from
    the surface to each point. This and suitable "flag" attributes used wisely
    will simplify the scripts. 

    Cheers,

    Dimitri

    _______________________________________________
    Manifold-l mailing list
    Manifold-l at lists.directionsmag.com
    http://www.directionsmag.com/mailman/listinfo/manifold-l
  -------------- next part --------------

  _______________________________________________
  Manifold-l mailing list
  Manifold-l at lists.directionsmag.com
  http://www.directionsmag.com/mailman/listinfo/manifold-l
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.directionsmag.com/pipermail/manifold-l/attachments/20061009/6e476b4f/attachment-0001.htm


More information about the Manifold-l mailing list