Converts GPX files into features.
This tool converts the point information inside a GPX file into features. The output features will include the geometry (including elevation or Z-value) as well as attribute fields for Name, Description, Type, DateTimeS (string type), Elevation, and DateTime (date type - if possible). Shapefiles do not support Date-Time fields, they only support Date fields. Output shapefiles will only have a DateTime field of type string created. All other output format types will attempt to create a real DateTime field as long as the date format complies to the XML Time standard. Most GPX files follow the XML Time standard.
GPX files collect points in two ways: waypoints and tracks. Waypoints are generally single, unrelated points while tracks make up a route or collection of related points with a start and end point. The type of point collected is specified in the output feature class by the code WPT (waypoint) or TRKPT (track point) within the Type attribute field. Waypoints can have a name and description for each individual point. Tracks have a name and description associated with the track itself, not for each individual point.
You can use the Points To Line tool to create polylines for each track.
- Use the Select Layer By Attribute tool to select track points with the expression: TYPE = "TRKPT".
- Use the selected features as input to the Points To Line tool. In the Line Field parameter of Points To Line tool, choose the Name field to create unique tracks.
The Python code below shows how this workflow is accomplished using a script.
Output will be generated in the WGS84 coordinate system. The output features can be reprojected to another coordinate system, if desired, using the Project tool.
Both the 1.0 and 1.1 Topografix GPX schemas are supported. Files that do not conform to one of these schemas will not translate.
GPXToFeatures_conversion (Input_GPX_File, Output_Feature_class)
The GPX file to convert.
The feature class to create.
GPXToFeatures Example 1 (Python Window)
The following Python snippet converts a GPX file into features from the Python window.
import arcpy arcpy.GPXtoFeatures_conversion('c:\\GPX_Files\\Hike.gpx', 'c:\\gisData\\Hike.shp')
GPXToFeatures Example 2 (stand-alone script)
The following Python snippet converts a GPX file into features and then selects the tracks and creates a polyline feature class of those unique tracks.
# Name: ConvertMultiTracks.py # Description: Converts multiple tracks within a single GPX file into # individual line segments # Import system models import arcpy # Convert the GPX file into in_memory features arcpy.GPXtoFeatures_conversion('c:\\GPX_Files\\MultiHike.gpx', 'in_memory\hikes') # Select only the track points arcpy.SelectLayerByAttribute_management('in_memory\hikes', 'NEW_SELECTION', "\"Type\" = 'TRKPT'") # Convert the tracks into lines. The 'Name' field creates unique tracks. arcpy.PointsToLine_management('in_memory\hikes', 'c:\\output\HikeTracks.shp', 'Name', '#', 'NO_CLOSE')
- ArcGIS for Desktop Basic: Yes
- ArcGIS for Desktop Standard: Yes
- ArcGIS for Desktop Advanced: Yes