On Sun, Aug 23, 2009 at 12:08 AM, Itzchak
Raiskin<itzchak.rais...@gmail.com> wrote:
> Hi
> I want to use SQLite in a GIS application where I create a database
> containing terrain data (coordinates, height).
> I would like to query this database with start and end points of a line and
> get a vector with all heights point along this line.
> I can, of course create a query for each point along the line, but this will
> be very time consuming as I have hundreds of lines with hundreds of points.
> Any suggestions?
>


The problem to solve is that you have a discontinuous surface
(discrete points) with height values. You want to do a line-on-poly
overlay and find the surface values that intersect with the line. Of
course, the line may or may not intersect with any of your stored
points, so you have to do some interpolation.

If you can "fill" all the coords on a surface, typically done by an
image where every pixel holds the height value, you can find all the
points that coincide with a line.

If a line is expressed by (y = ax + c), you need to find all x,y that
will satisfy that equation. So,

SELECT x, y, z
FROM terrain
WHERE a*x - y + c = 0

But you can make the search more efficient by only searching within
the bounding box of the line, so, assuming xmin, ymin, xmax, ymax are
the end points of the line

SELECT x, y, z
FROM terrain
WHERE a*x - y + c = 0
  AND x BETWEEN xmin AND xmax
  AND y BETWEEN ymin AND ymax


In other words, Kit gave you the answer already. I hope my explanation
helped flesh it out more. You can use your own line equation in the
SELECT statement above.


-- 
Puneet Kishor http://www.punkish.org
Carbon Model http://carbonmodel.org
Charter Member, Open Source Geospatial Foundation http://www.osgeo.org
Science Commons Fellow, http://sciencecommons.org/about/whoweare/kishor
Nelson Institute, UW-Madison http://www.nelson.wisc.edu
-----------------------------------------------------------------------
Assertions are politics; backing up assertions with evidence is science
=======================================================================
Sent from Madison, WI, United States
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to