Export Features to GPX files

492
0
02-03-2020 10:53 AM
KenGorton
Esri Contributor

I recently did a search for tools that will convert feature layers to GPX format. Not finding anything, I ended up writing one. I deployed it to an Azure portal as a severless compute function.

You can see the results in this storymap:

The 2020 BMW RA Rally 

The routes in this storymap were created using the Directions capability in the standard ArcGIS Online web map viewer. The resulting route feature collections were published as hosted feature layers and shared publicly. The URLs to those feature layers are configured as parameters in the links in each of the 'Download GPX file' buttons in the storymap.

If anyone is interested you can leverage a similar capability in your own storymaps or other applications using this function:

https://arcgis2gpx.azurewebsites.net/api/Layers2GPX

It takes GET or POST requests and accepts point or polyline feature layers. The features in point feature layers become GPX waypoints while the features in polyline feature layers become GPX tracks.

The minimum parameters required for GET requests is the url to a point or polyline feature layer. Thus you can create a URL for a hyperlink in a web page, storymap or other document as follows: 

https://arcgis2gpx.azurewebsites.net/api/Layers2GPX?url=https://services1.arcgis.com/EvDRLcHhbHG5Bnw...

or

https://arcgis2gpx.azurewebsites.net/api/Layers2GPX?url=https://services1.arcgis.com/fBc8EJBxQRMcHle... 

The minimum payload for a POST request is a json object with a title element (which will become the output GPX filename) and an array of feature layer urls. Thus you can combine multiple point and/or polyline feature layers into a single GPX file. Example:

{
"title":"Some Trails",
"returnFile":"true",
"layers":[
{
"url":"https://services1.arcgis.com/EvDRLcHhbHG5BnwT/arcgis/rest/services/Hiking_Routes/FeatureServer/0",
"name":"Name",
"desc":"Description",
"where":"AscentFT>3600"
},
{
"url":"https://services1.arcgis.com/fBc8EJBxQRMcHlei/arcgis/rest/services/Appalachian_National_Scenic_Trail/FeatureServer/0",
"name":"Name",
"desc":"Description",
"where":"Length_Ft>40000"
}
]
}

Additionally, both methods allow you to include optional parameters for each url to indicate wich fields from the source feature layers to utilize for the different GPX elements such as
name, desc, cmt, etc

Click the function URL above for a complete list of optional parameters.

I cannot guarantee how long the function will remain up. If you want the code let me know.

If you find an error in functinality or behavior, please also let me know.

Ken

Reply
0 Kudos
0 Replies