A powerful Python script for filtering waypoints from GPX files based on multiple criteria including text matching, timestamps, and geographic boundaries.
- Text-based filtering: Search waypoint names, symbols, and timestamps
- Geographic filtering: Filter by latitude/longitude bounding boxes
- Flexible logic: Combine criteria with AND/OR operations
- Fuzzy matching: Find partial text matches
- Duplicate removal: Automatically removes duplicate waypoints
- Preserves data: Maintains all original waypoint attributes
- Python 3.6 or higher
- gpxpy library
# Install the required dependency
pip install gpxpy
# Make the script executable (optional)
chmod +x gpx_waypoint_filter.pypython gpx_waypoint_filter.py input.gpx output.gpx [OPTIONS]input_file: Path to the input GPX fileoutput_file: Path where filtered waypoints will be saved
Filter waypoints where the name contains any of the specified strings.
--name trout salmon "golden pond"Filter waypoints where the symbol field contains any of the specified strings.
--sym fish camping "picnic area"Filter waypoints where the timestamp contains any of the specified strings.
--time 2024 "2024-07" "August"Minimum latitude boundary (inclusive).
--lat-min 37.5Maximum latitude boundary (inclusive).
--lat-max 38.0Minimum longitude boundary (inclusive).
--lon-min -119.5Maximum longitude boundary (inclusive).
--lon-max -118.5Controls how different criteria groups are combined. Default: or
or: Match ANY criteria (default)and: Match ALL specified criteriabounds-or: Geographic bounds AND with each other, then OR with text criteriabounds-and: Geographic bounds AND with each other, then AND with text criteria
--logic bounds-orControls how latitude and longitude bounds are combined. Default: and
and: Waypoint must be within both lat AND lon boundsor: Waypoint must be within lat OR lon bounds
--bounds-logic orEnable case-sensitive text matching (default is case-insensitive).
--case-sensitiveDisplay detailed filtering information during processing.
--verboseFind all waypoints with "fish" in the symbol field:
python gpx_waypoint_filter.py input.gpx output.gpx --sym fishFind waypoints containing any fishing-related terms in the name:
python gpx_waypoint_filter.py input.gpx output.gpx \
--name trout salmon bass pike "golden pond" brookGet all waypoints within a specific region:
python gpx_waypoint_filter.py input.gpx output.gpx \
--lat-min 37.0 --lat-max 38.0 \
--lon-min -119.5 --lon-max -118.5Find camping spots within a specific region:
python gpx_waypoint_filter.py input.gpx output.gpx \
--lat-min 37.0 --lat-max 38.0 \
--lon-min -119.5 --lon-max -118.5 \
--sym camping \
--logic bounds-andGet waypoints either in the region OR with fishing-related content:
python gpx_waypoint_filter.py input.gpx output.gpx \
--lat-min 37.0 --lat-max 38.0 \
--lon-min -119.5 --lon-max -118.5 \
--sym fish --name trout \
--logic bounds-orFind all waypoints from 2024:
python gpx_waypoint_filter.py input.gpx output.gpx --time 2024Waypoints must be in region AND have "camp" in name AND be from 2024:
python gpx_waypoint_filter.py input.gpx output.gpx \
--lat-min 37.0 --lat-max 38.0 \
--lon-min -119.5 --lon-max -118.5 \
--name camp \
--time 2024 \
--logic andGet all waypoints between certain latitudes (any longitude):
python gpx_waypoint_filter.py input.gpx output.gpx \
--lat-min 35.0 --lat-max 40.0Find waypoints with exact case match:
python gpx_waypoint_filter.py input.gpx output.gpx \
--name "Eagle Lake" "Bear Creek" \
--case-sensitiveFind waypoints with various outdoor activity symbols:
python gpx_waypoint_filter.py input.gpx output.gpx \
--sym camping fishing hiking "scenic viewpoint" swimmingFind fishing locations in either of two regions:
python gpx_waypoint_filter.py input.gpx output.gpx \
--lat-min 37.0 --lat-max 37.5 \
--lon-min -119.5 --lon-max -119.0 \
--sym fish \
--logic bounds-and \
--bounds-logic orFind lakes above a certain latitude with specific names:
python gpx_waypoint_filter.py input.gpx output.gpx \
--lat-min 37.5 \
--name lake pond reservoir "alpine lake" \
--logic andWaypoints from 2023-2024 within bounds:
python gpx_waypoint_filter.py input.gpx output.gpx \
--lat-min 36.5 --lat-max 38.5 \
--lon-min -120.0 --lon-max -118.0 \
--time 2023 2024 \
--logic bounds-andAny single criteria matches:
# Matches if: has "camp" OR has "fish" OR in bounds
python gpx_waypoint_filter.py input.gpx output.gpx \
--name camp --sym fish \
--lat-min 37.0 --lat-max 38.0All specified criteria must match:
# Matches if: has "camp" AND has "fish" AND in bounds
python gpx_waypoint_filter.py input.gpx output.gpx \
--name camp --sym fish \
--lat-min 37.0 --lat-max 38.0 \
--logic andBounds are evaluated together, then OR'd with text:
# Matches if: (in lat bounds AND in lon bounds) OR has "camp" OR has "fish"
python gpx_waypoint_filter.py input.gpx output.gpx \
--lat-min 37.0 --lat-max 38.0 \
--lon-min -119.0 --lon-max -118.0 \
--name camp --sym fish \
--logic bounds-orBounds are evaluated together, then AND'd with text:
# Matches if: (in lat bounds AND in lon bounds) AND (has "camp" OR has "fish")
python gpx_waypoint_filter.py input.gpx output.gpx \
--lat-min 37.0 --lat-max 38.0 \
--lon-min -119.0 --lon-max -118.0 \
--name camp --sym fish \
--logic bounds-and- Start broad, then narrow: Test with lenient criteria first, then add restrictions
- Use verbose mode: Add
-vto see what's being filtered - Partial matches work: Searching for "camp" will match "camping", "campground", "basecamp"
- Combine criteria thoughtfully: Understanding the logic modes helps create precise filters
- Check your bounds: Latitude increases going north, longitude increases going east
- Remember decimal degrees:
- Latitude: -90 to +90 (negative = south)
- Longitude: -180 to +180 (negative = west)
- Check if criteria are too restrictive
- Use
--verboseto see filtering details - Try broader search terms or larger geographic bounds
- Verify logic mode is appropriate for your query
- Add more specific criteria
- Switch from
--logic orto--logic and - Use exact phrases with
--case-sensitive - Narrow geographic bounds
- Ensure input file exists and is valid GPX format
- Check that gpxpy is installed:
pip install gpxpy - Verify Python version is 3.6 or higher:
python --version
Filtering a large GPX file for a fishing trip:
# Step 1: See all fishing-related waypoints
python gpx_waypoint_filter.py all_waypoints.gpx fishing_spots.gpx \
--sym fish --name trout bass salmon -v
# Step 2: Narrow to specific region
python gpx_waypoint_filter.py all_waypoints.gpx regional_fishing.gpx \
--sym fish --name trout bass salmon \
--lat-min 37.2 --lat-max 37.8 \
--lon-min -119.3 --lon-max -118.7 \
--logic bounds-and
# Step 3: Filter for recent visits only
python gpx_waypoint_filter.py regional_fishing.gpx recent_fishing.gpx \
--time 2024
# Step 4: Find specific type with exact name
python gpx_waypoint_filter.py all_waypoints.gpx exact_spots.gpx \
--name "Golden Trout Lake" --case-sensitiveThis script is provided as-is for personal and commercial use.
Feel free to suggest improvements or report issues with the script.