Nav Icon

Back Arrow Postholer.Com
Resource for Hikers

Login/Register
Log in or register for full access to site features & free downloads

Printed Maps & App
Stay found. Stay informead. Our premium printed topographic maps and matching app for a once in a lifetime adventure

OnLine Data Books
Free online data books for your favorite trail, distances, elevation, climate, way points, terrain & fauna

Interactive Maps
GPS aware interactive maps, your location, topo, hybrid, satellite, trail track, way points, road, weather/snow overlays

Active Fires & Smoke
Know before you go! Get the lastest active fire & smoke information for your favorite trail

Snow Conditions
Get the lastest snow conditions for your favorite trail. Quantity, coverage, SNODAS, MODIS, historical and multi-year comparisons

Trip Planners
Create an extensive hike plan easily configurable to your hiking style. Distances, days, resupply, access points, etc

Gear Builder
Create your own fully customizable gear list with weight, pricing and divisable by section.

Trail Animals
Exhaustive resource for species ranges along your favorite trail. Includes amphibians, birds, mammals and reptiles.

Complete Gear Lists
Hundreds of complete gear lists by those that walked the walk.

Elevations Profiles
The big picture. Single elevation profile of your favorite trail.

Journal Tools
Search for a journal, create a journal, add/edit an entry, configure your journal, EMail updates, integrated interactve trail map, PLB locations and more

Wall Maps
Print out your favorite trail to 6 feet high. Elevation chart and resupply locations.

Postholer Forum
Source for trail and site information or just talk about your favorite trail

About
Where it all begins.

Adding Elevations to PCTA centerline/mile markers data

(Just take me to the data)

The PCTA makes both centerline and milemarker data available in different geo-spatial formats. PCTA is an ESRI shop. In that spirit we'll be working with their ArcGIS GDB offering, "Full_PCT.gdb_-1.zip".

After downloading it, we'll need to fix the GDB layout and then we'll add elevation to both data sets. We'll be using strictly open source geo-spatial tools which are far more useful than any proprietary tools. Specifically, we'll use GDAL & PostgreSQL/PostGIS. All elevation data will be extracted from the latest, existing USGS 10 meter DEM rasters. Installing those is beyond the scope of this article.

The "Full_PCT.gdb_-1.zip" archive contains all the GDB data/index files, which should have been contained in a single directory. They were not, so let's fix it. Create new directory:

mkdir pcta-20240304.gdb
cp Full_PCT.gdb_-1.zip pcta-20240304.gdb
cd pcta-20240304.gdb
unzip Full_PCT.gdb_-1.zip
rm Full_PCT.gdb_-1.zip
cd ..

Now, we can work with the GDB properly.

ogrinfo pcta-20240304.gdb

# output

INFO: Open of `pcta-20240304.gdb/'
      using driver `OpenFileGDB' successful.
Layer: Full_PCT_Mile_Marker (Measured Point)
Layer: Full_PCT (Measured Multi Line String)

As you can see, it has 2 layers, mile markers and centerline. Both layers have a 'measure' or XYM, meaning each geometry has a longitude, latitude and measure. In this case the measure is decimal mile values. One difference, the centerline is a multilinestring geometry, mile markers is point geometry. Let's actually look at the data:

ogrinfo -al pcta-20240304.gdb Full_PCT_Mile_Marker | more

You'll see spatial info and data for all 5,324 points. Doing the same for the centerline:

ogrinfo -al pcta-20240304.gdb Full_PCT | more

In this case you'll see linestrings instead of points. Let's load this into our PostgreSQL/PostGIS database so we might do some heavy lifting. Well load the centerline as a table called ptrace and mile markers as pmm, transforming the projection to EPSG:4269 in the process. All our database data is EPSG:4269 to avoid doing transforms when working with different data. Let's load the centerline into the database:

ogr2ogr -overwrite -nln ptrace -t_srs EPSG:4269 PG:dbname=gis pcta-20240304.gdb Full_PCT

...and now the mile markers:

ogr2ogr -overwrite -nln pmm -t_srs EPSG:4269 PG:dbname=gis pcta-20240304.gdb Full_PCT_Mile_Marker

...let's put the PCTA's sidetrails in the DB also so we can create trail junctions in our POI's:

ogr2ogr -overwrite -nln public.sidetrails -t_srs EPSG:4269 PG:dbname=gis GEOJSON:"https://services5.arcgis.com/ZldHa25efPFpMmfB/ArcGIS/rest/services/PCT_Side_Trails/FeatureServer/0/query?where=0%3D0&geometry=-123.2581728,32.58974115,-116.4124535,49.0003676&geometryType=esriGeometryEnvelope&inSR=4269&spatialRel=esriSpatialRelIntersects&f=pgeojson"

Our tables are loaded, spatially indexed and ready to go. As stated, our goal is to add elevation to these XYM geometries. Our new geometries will be XYZM, which is, longitude, latitude, elevation and measure. Since our measure is decimal miles (not geom SRS), we'll add the elevation as integer feet, not meters. Having feet and miles as ZM is not advisable. If you're doing any sort of calculations with this in EPSG:4326, et al, you'll want ZM of SRS and meters. Since it's not my data, we'll go with the flow and use feet as Z. You have been warned.

We already have a table of the latest USGS 10 meter resolution rasters for CONUS (lower 48 states) in our PostgreSQL/PostGIS database (out of db, actually). With that, we need to extract an elevation for every longitude/latitude value we have. We'll be using SQL to do this, so let's get started.

For our centerline we are going to deconstruct all the multilinestrings into individual point geometries, add the elevation (Z) to each point and rebuild the multilinestrings using the same groupings as our original data. This is done with an SQL statement that looks like this:

updateCenterline.sql:
select
   t.objectid
   ,t.section_name
   ,t.folderpath
   ,t.region
   ,t.shape_length
   ,st_multi(n.wkb_geometry) as wkb_geometry
from ptrace t, lateral (
   select
      st_makeline(
         st_makepoint(st_x(l.geom),st_y(l.geom),round(st_value(d.rast, l.geom)::numeric * 3.28084)::integer,st_m(l.geom)) order by st_m(l.geom) asc
      ) as wkb_geometry
   from (select (st_dumppoints(t.shape)).*) l
   join dem10 d on st_intersects(d.rast, l.geom)
) n

Next, let's create our SQL that will update our mile markers in a similar way.

updateMilemarkers.sql:
select
   t.objectid
   ,t.mile
   ,round(st_value(d.rast, t.shape)::numeric * 3.28084)::integer as elev_ft
   ,t.section_name
   ,t.folderpath
   ,t.region
   ,st_makepoint(st_x(t.shape),st_y(t.shape),round(st_value(d.rast, t.shape)::numeric * 3.28084)::integer,st_m(t.shape)) as wkb_geometry
from pmm t
join dem10 d on st_intersects(d.rast, t.shape)
order by t.mile asc

All is now in place. We can run our queries, update our data and save it for use. We'll save it in various formats for ease of use. That's it!

pcta-20240304.gpkg will be the source for all other formats. We only need to run queries for this data set. collectTrailFeatures.sql is not shown above as it has dependencies beyond scope:
ogr2ogr -overwrite -s_srs EPSG:4269 -t_srs EPSG:4326 -sql @updateMilemarkers.sql -nln milemarkers pcta-20240304.gpkg PG:dbname=gis
ogr2ogr -update -append -s_srs EPSG:4269 -t_srs EPSG:4326 -sql @updateCenterline.sql -nln centerline pcta-20240304.gpkg PG:dbname=gis
ogr2ogr -update -append -s_srs EPSG:4269 -t_srs EPSG:4326 -sql @collectTrailFeatures.sql -nln poi pcta-20240304.gpkg PG:dbname=gis

pcta-20240304.shp:
ogr2ogr -overwrite pcta-20240304.shp pcta-20240304.gpkg 

pcta-xyzm-20240304.gdb:
ogr2ogr -f OpenFileGDB -overwrite -nlt LINESTRINGZM pcta-xyzm-20240304.gdb pcta-20240304.gpkg centerline
ogr2ogr -f OpenFileGDB -update -append -nlt POINTZM pcta-xyzm-20240304.gdb pcta-20240304.gpkg milemarkers
ogr2ogr -f OpenFileGDB -update -append -nlt POINTZM pcta-xyzm-20240304.gdb pcta-20240304.gpkg poi

pcta-mileMarkers-20240304.csv:
ogr2ogr -overwrite pcta-mileMarkers-20240304.csv pcta-20240304.gpkg milemarkers

pcta-mileMarkers-20240304.gpx:
ogr2ogr -nlt POINT -dsco GPX_USE_EXTENSIONS=YES -dsco METADATA_DESCRIPTION="PCTA mile markers March 4, 2024. Updated by postholer.com to add elevation in feet from USGS 10 meter DEM's." -skipfailures pcta-mileMarkers-20240304.gpx pcta-20240304.gpkg milemarkers

pcta-centerline-20240304.gpx:
ogr2ogr -nlt LINESTRING -dsco GPX_USE_EXTENSIONS=YES -dsco METADATA_DESCRIPTION="PCTA centerline March 4, 2024. Updated by postholer.com to add elevation in feet from USGS 10 meter DEM's." -skipfailures pcta-centerline-20240304.gpx pcta-20240304.gpkg centerline

pcta-mileMarkers-20240304.geojson, GeoJSON drops the geometry measure (M), but not the elevation (Z). Column 'mile' is a rounded, 1 decimal place, value for M:
ogr2ogr pcta-mileMarkers-20240304.geojson pcta-20240304.gpkg milemarkers

pcta-centerline-20240304.geojson:
ogr2ogr pcta-centerline-20240304.geojson pcta-20240304.gpkg centerline

pcta-xyzm-20240304.kmz:
ogr2ogr pcta-xyzm-20240304.kml pcta-20240304.gpkg
zip pcta-xyzm-20240304.kmz pcta-xyzm-20240304.kml

4,425 Points of Interest

Using the PCTA centerline & sidetrails data, we've collected 4425 Points of Interest (POI) within 1/2 mile of the PCT. Again, this is created with the PCTA's latitude, longitude and mileage. Elevations are from process above. All these points are extracted from the USGS Geographic Names Information System, National Hydrography Data, Protected Areas Database 3.0 (PAD3) and U.S. Census Tiger/Line roads and administrative boundaries.

pcta-poi-20240304.gpkg, pcta-poi-20240304.gpx:
   type        : denotes the POI type
   seq         : sequence number used for ordering, ie order by mile and seq, "order by st_m(geom) asc, seq asc"
   name        : name of point
   mile        : trail mile nearest to the point, 2 decimal places
   trail_elev  : trail elev at trail mile
   feature_elev: POI elevation. POI may be up to 1/2 mile off trail
   dft         : POI distance from trail, in feet, in straight line
   azimuth     : azimuth from nearest point on trail, to POI. NOT necessarily best approach to POI. '-' if on trail.
   featurept   : Well Known Text (WKT) 3D point of POI
   geom        : Well Known Binary (WKB) 3D measured trail point

'type' is one of the following:
Airport,Area,Bar,Bend,Bridge,Building,Cape,Census,Civil,Cliff,County,Crater,Dam,Drainage,Falls,Flat,Forest,Gap,Glacier,Island,Lava,Locale,Military,Mine,PAD3_BLM,PAD3_CITY,PAD3_CNTY,PAD3_DOD,PAD3_NGO,PAD3_NPS,PAD3_OTHS,PAD3_PVT,PAD3_REG,PAD3_SDC,PAD3_SDNR,PAD3_SDOL,PAD3_SFW,PAD3_SPR,PAD3_TRIB,PAD3_USACE,PAD3_USBR,PAD3_USFS,Park,Pillar,Plain,Populated Place,Post Office,Range,Rapids,Rd_County,Rd_Interstate,Rd_Other,Rd_PriSec,Rd_StateHwy,Rd_USHwy,Rd_Unknown,Reserve,Reservoir,Ridge,School,SideTrail,Spring,State,Summit,Swamp,Tower,Trail,Tunnel,Valley,Waterbody

Postholer.Com © 2005-2024 - Sitemap - W3C - @postholer - GIS Portfolio