[postgis-users] Elevation Profiles

Carl Anderson carl.anderson at vadose.org
Mon Nov 29 22:13:32 PST 2004


On 11/24/2004 01:46:31 PM, ANDREW WOOLEY wrote:
> Folks,
> 
> I have been working on this idea for some time and have been trying  
> to
> implement elevation profiles and have yet to get it working like I
> want.
>  I am hoping that someone has some good ideas for me.
> 
> Here is my problem. I have a series of lines in a table.  I also have
> a
> table with elevations as polygons. I overlay them using this query:
> select e.gridcode as elevation from mtntrails_elevation as e, route  
> as
> r where e.the_geom && r.the_geom;
> (route has one trail with 3 or 4 segments.)(mtntrails_elevation has  
> ~7
> million rows.)
>

When working with path profiles I usually plot them up on a cartesian  
grid as a path distance vs an elevation.  The problem becomes how to  
degenerate a path into a set of evenly spaced samples.

the two attached plpgsql functions can help.  an example of a SQL  
statement calling the scripts is included.  Use them as you will.

the outer function linestring_samples "walks" a specific path using the  
inner function to compute the position of each sample.  In the  
path_profile script only one path can be sampled at a time or you'll  
get an error.  you may also need to wrap a setsrid around.  ie setsrid 
(geometry(linestring_samples[2]),mySRID).

the result is an array, but you could script the samples into a  
destination table as well.  the sampling function needs to return a  
setof two values. one for sampling one for ordering.

Re: speed of relational operators on polygons.  The speed of  
computation of the relation is related to the number of vertices in the  
polygon.  Consider breaking the polygons into smaller "gridded"  
elements.


C.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: linestring_samples.sql
Type: text/x-sql
Size: 1327 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20041130/25211b00/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: path_profile.sql
Type: text/x-sql
Size: 539 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20041130/25211b00/attachment-0001.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: line_event_distance.sql
Type: text/x-sql
Size: 2653 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20041130/25211b00/attachment-0002.bin>


More information about the postgis-users mailing list