I'm new to PostGIS and looking to measure the distance of the Pacific Crest Trail which spans western North America from Canada to Mexico.

I have a data set containing the lat lon and dates from GPX data taken on the trail from a hiker. I also have a shapefile of the entire trail that's fairly high resolution. What I'd like to do is to extract the total mileage gained for each of the GPS locations from computing the length of the trail data and then intersecting the two.

I think the steps to doing this as are follows:

  1. process the GPS location data to get lat lon positions at weekly intervals with additional special events like summiting Mt Whitney, trail start, end, etc.(this part is finished)

  2. snap the lat lon GPS points to the nearest PCT shapefile nodes.

  3. split the PCT shapefile into segments based on an intersection with the GPS points.

  4. convert the total mileage from meters to miles.

  5. total the distance gained by each GPS point as the dates increase.

Some questions I have are:

What projection or method of measuring distance would be most accurate for such a large north - south distance? I'm thinking of transforming the data into a custom equidistant projection but am unsure about setting the parameters for yielding the most accurate distance measurement. Or does PostGIS have other functionality that would yield accurate distance measurements without having to transform the data?

Does this sound like a reasonable approach? Would you have any suggestions or tips that might help? Any advice you might have would be appreciated.

Thanks in advance

  • Because this is primarily a north-south trail that wanders no more than a few degrees from the 119.5 degree (west) meridian at any point, an excellent choice of projection would be to adapt a UTM coordinate system by choosing a central meridian near -119.5. Its maximum scale distortion would be about 0.5 parts per thousand. An equidistant projection would be a poor choice in comparison because it would introduce much greater distortions in the east-west distances. – whuber Aug 13 '14 at 15:56

For the how to project the data part of the question, you can avoid it by storing the data in a geography column, rather than using geometry. ST_Length will then return the distance in meters as calculated on the sphere or spheroid, your choice.

Here's a breakdown on when to use geography vs. geometry: http://postgis.net/workshops/postgis-intro/geography.html.

  • thanks, in the link you provided they state that "There are only a small number of native functions for the geography type" So would ST_Line_Interpolate_Point(line, measure) work using degrees as the measurement? I would need to do this step first to snap the GPS points to the nearest nodes of the line, correct? – clhenrick Jan 20 '14 at 20:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.