Skip to main content

OSM Search Plus

A Python package for searching OpenStreetMap data with advanced features and filtering. Find abandoned places, ruins, bunkers, and other interesting locations using OpenStreetMap data.

Installation

pip install autobex

Basic Usage

from autobex import OSMSearchPlus

# Initialize searcher
searcher = OSMSearchPlus()

# List all available search tags
print("Available search tags:")
for tag in searcher.list_tags():
    print(f"  - {tag}")

# Search with coordinates and radius
results = searcher.search(
    lat=42.3601,  # Latitude in decimal degrees
    lon=-71.0589, # Longitude in decimal degrees
    radius=5.0    # Search radius in miles
)

# Print results
for group in results:
    print(f"Group: {group.name}")  # Descriptive group name
    for location in group:
        print(f"  - {location}")

Search Options

Tag Configuration

You can control which tags to search for in several ways:

  1. List available tags:
# See what tags are available for searching
for tag in searcher.list_tags():
    print(tag)
  1. Default tags from tags.txt:
# Use only default tags (default behavior)
results = searcher.search(lat, lon, radius)

# Disable default tags
results = searcher.search(lat, lon, radius, use_default_tags=False)
  1. Custom tags:
# Use custom tags only
results = searcher.search(
    lat, lon, radius,
    use_default_tags=False,
    custom_tags=["building=ruins", "abandoned"]
)

# Use both default and custom tags
results = searcher.search(
    lat, lon, radius,
    custom_tags=["building=ruins"]  # Will combine with default tags
)

Search Area

Search by radius:

results = searcher.search(lat=42.3601, lon=-71.0589, radius=5.0)  # 5 mile radius

Search in polygon:

polygon = [
    (42.3601, -71.0589),
    (42.3702, -71.0690),
    (42.3803, -71.0791)
]
results = searcher.search(polygon_coords=polygon)

Coordinate Formats

Supports both decimal degrees and DMS format:

# Decimal degrees
results = searcher.search(lat=42.3601, lon=-71.0589, radius=5.0)

# DMS format
results = searcher.search(
    lat='41°28\'50.4"N',
    lon='71°23\'35.5"W',
    radius=5.0
)

Logging and Debug Information

Enable detailed logging to see search progress:

results = searcher.search(lat, lon, radius, show_logs=True)

This will show:

  • Tags being searched
  • Number of elements found
  • Processing progress
  • Number of locations added per tag
  • Total unique locations found
  • Grouping information

Location Results

Each location contains:

Core Properties (not from OSM)

  • location.name: Generated from OSM name or reverse geocoding
  • location.latitude, location.longitude: Coordinates
  • location.distance: Direct distance from search center in meters
  • location.road_distance: Distance to nearest road in meters
  • location.elevation: Elevation in meters
  • location.google_maps_url: Link to Google Maps (maximum zoom)
  • location.bing_maps_url: Link to Bing Maps (aerial view)
  • location.osm_url: Link to OpenStreetMap

OSM-specific Data

  • location.osm_id: OpenStreetMap ID
  • location.type: Type of element (node or way)
  • location.tags: Dictionary of all OpenStreetMap tags

Accessing Tag Information

# Check if a tag exists
if "abandoned" in location.tags:
    print("This is an abandoned location")

# Get tag value with fallback
building_type = location.tags.get("building", "unknown")

# Print all tags
print(location.all_tags())

Location Groups

Results are automatically grouped by proximity (within 100 meters). Each group has an intelligent naming system that combines:

  1. Status (if common across group):

    • Abandoned
    • Ruins
    • Disused
    • Demolished
  2. Type (from most specific to least specific):

    • Amenity
    • Military
    • Building
    • Historic
    • Landuse
  3. Location:

    • City name (when available)
    • State/Region
    • Fallback to shortest location name if geocoding fails
  4. Group size:

    • Number of locations in the group

Example group names:

  • "Abandoned Factory - Boston, Massachusetts (3 locations)"
  • "Military Bunker - Portland, Maine"
  • "Ruins - Historic Site - Burlington, Vermont (2 locations)"
for group in results:
    # Access the intelligent group name
    print(f"\nGroup: {group.name}")
    
    # Get group statistics
    print(f"Center: {group.center()}")
    print(f"Distance span: {group.distance_span()} miles")
    
    # Filter group by tag
    ruins = group.filter_by_tag("building", "ruins")
    abandoned = group.filter_by_tag("abandoned")

Error Handling

The package includes automatic retry logic for API timeouts and rate limits. It will:

  • Retry failed queries up to 3 times
  • Use progressive backoff delays
  • Handle rate limiting gracefully
  • Provide detailed error messages

Configuration Files

tags.txt

Contains tags to search for by default. Each line should be either:

  • A simple tag (e.g., abandoned)
  • A key=value pair (e.g., building=ruins)
  • A name pattern (e.g., name~Factory)

You can view all configured tags using searcher.list_tags().

excluded_tags.txt

Contains tags that will exclude locations from results. Same format as tags.txt. If not found, default exclusions are used (e.g., demolished=yes, highway=bus_stop, etc.).

Features

  • List and inspect available search tags
  • Intelligent group naming based on common properties
  • Search by radius or polygon area
  • Support for both decimal and DMS coordinates
  • Automatic grouping of nearby locations (100m radius)
  • Distance calculations (direct and to nearest road)
  • Elevation data and reverse geocoding
  • Direct links to OpenStreetMap, Google Maps, and Bing Maps
  • Tag-based filtering and exclusions
  • Increased timeout values for slower connections
  • Comprehensive testing tools included

Testing Tools

The package includes two testing tools to help you explore and verify functionality:

1. Test Query Tool (test_query.py)

A simple tool to test searches and view formatted results:

python test_query.py

Features:

  • Formatted output with distances in both metric and imperial
  • Direct links to maps
  • Organized tag display
  • Elevation in meters and feet
  • Group information

Sample output:

Found 1 location in 1 group

========================================
Group 1 (1 locations)
========================================

Location 1:
----------------------------------------
Name: Northeastern University Marine Science Center
Type: way
OSM ID: 123456789
Distance: 0.04 miles
Elevation: 15.2m (49.9ft)

Map Links:
  Google Maps: https://www.google.com/maps?q=42.4185,-70.9056&z=21
  Bing Maps: https://www.bing.com/maps?cp=42.4185~-70.9056&style=h&lvl=20

Tags:
  • building = yes
  • historic = ruins
  • name = Northeastern University Marine Science Center
  • abandoned = yes

2. Feature Test Suite (test_features.py)

A comprehensive test suite that verifies all major features:

python test_features.py

Tests include:

  • Radius search
  • Polygon search
  • Large area search
  • Location grouping
  • Error handling
  • Coordinate parsing
  • Tag filtering
  • Distance calculations

Use this to:

  • Verify package functionality
  • Test custom configurations
  • Debug search issues
  • Explore feature behavior

Dependencies

  • Python 3.7+
  • geopy (≥2.3.0) - For geocoding and distance calculations
  • requests (≥2.25.0) - For API communication
  • numpy - For mathematical operations

Performance Tips

  1. Use appropriate search radius (smaller = faster)
  2. Use limit parameter when possible
  3. Keep tag files focused and minimal
  4. Use excluded_tags.txt to filter noise
  5. Enable show_logs=True to monitor progress
  6. Start with test tools to verify setup

Tag Matching System

The system supports three types of tag matching:

  1. Exact matches (with =):

    building=ruins    -> matches exactly building=ruins
    
  2. Simple tags (without =):

    abandoned        -> matches:
                       - abandoned=* (any value)
                       - building=abandoned
                       - historic=abandoned
    
  3. Name patterns (with ~):

    name~Factory    -> matches locations with "Factory" in their name
    

Support and Resources

License

MIT License - see LICENSE file for details.

Acknowledgments

  • OpenStreetMap contributors
  • Open-Elevation API
  • All package contributors

Metadata

Release files for autobex 0.1.162

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for autobex 0.1.162
File Size Uploaded
autobex-0.1.162.tar.gz 22.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for autobex 0.1.162
File Interpreter ABI Platform
autobex-0.1.162-py3-none-any.whl Python 3 none any Details

Total release size: 41.4 kB

Release files / autobex-0.1.162.tar.gz

Download URL autobex-0.1.162.tar.gz
Size 22.6 kB
Tags Source
SHA-256 checksum
How to use checksums
371039d7e20b477d9f7e8dae57fa0eb343bf30f925874615f499841154518cb1
BLAKE2b-256 checksum
How to use checksums
b1ce9cdc8869f8225a024b262b9aafc6e9f9121d40f2e0fdbf72064980f9afb2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.9

Release files / autobex-0.1.162-py3-none-any.whl

Download URL autobex-0.1.162-py3-none-any.whl
Size 18.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
46b8e1f5bc5fac9a6ee7e77b5277d2e4e5506ff8db52a95fa47e568dcdeea327
BLAKE2b-256 checksum
How to use checksums
e27df884f536705fc594115253eb3e8e456a78b0e81da97cff068ce109600708
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.9

Release history Release notifications | RSS feed

This release

0.1.162 This release

2 release files

0.1.134

1 release file

0.1.121

1 release file

0.1.99

2 release files

0.1.98

2 release files

0.1.97

2 release files

0.1.96

2 release files

0.1.95

2 release files

0.1.94

2 release files

0.1.93

2 release files

0.1.91

2 release files

0.1.90

2 release files

0.1.89

2 release files

0.1.88

2 release files

0.1.87

2 release files

0.1.86

2 release files

0.1.85

2 release files

0.1.84

2 release files

0.1.83

2 release files

0.1.82

2 release files

0.1.81

2 release files

0.1.80

2 release files

0.1.79

2 release files

0.1.78

2 release files

0.1.77

2 release files

0.1.76

2 release files

0.1.75

2 release files

0.1.74

2 release files

0.1.73

2 release files

0.1.72

2 release files

0.1.71

2 release files

0.1.70

2 release files

0.1.69

2 release files

0.1.68

2 release files

0.1.67

2 release files

0.1.66

2 release files

0.1.65

2 release files

0.1.64

2 release files

0.1.63

2 release files

0.1.62

2 release files

0.1.61

2 release files

0.1.60

2 release files

0.1.59

2 release files

0.1.58

2 release files

0.1.57

2 release files

0.1.56

2 release files

0.1.55

2 release files

0.1.54

2 release files

0.1.53

2 release files

0.1.52

2 release files

0.1.51

2 release files

0.1.50

2 release files

0.1.49

2 release files

0.1.48

2 release files

0.1.47

2 release files

0.1.46

2 release files

0.1.43

2 release files

0.1.42

2 release files

0.1.41

2 release files

0.1.40

2 release files

0.1.39

2 release files

0.1.38

2 release files

0.1.37

2 release files

0.1.36

2 release files

0.1.35

2 release files

0.1.34

2 release files

0.1.33

2 release files

0.1.32

2 release files

0.1.31

2 release files

0.1.30

2 release files

0.1.29

2 release files

0.1.28

2 release files

0.1.27

2 release files

0.1.26

2 release files

0.1.25

2 release files

0.1.24

2 release files

0.1.23

2 release files

0.1.22

2 release files

0.1.21

2 release files

0.1.19

2 release files

0.1.17

2 release files

0.1.15

2 release files

0.1.13

2 release files

0.1.12

2 release files

0.1.10

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page