Address Lookup
The Spexi Standard Images API uses geographic coordinates (latitude/longitude) for spatial queries rather than street addresses. To work with addresses, you'll need to convert them to coordinates first using a geocoding service.
Prerequisites
Before running the geocoding example, install the required Python library:
pip install geopyGeocoding service
While many geocoding services are available (Google Maps, Mapbox, HERE, etc.), we'll use Nominatim - OpenStreetMap's free geocoding service that requires no API key. Nominatim has usage limits (1 request/second) and may be less accurate than commercial services, but it's ideal for demos and moderate usage.
from geopy.geocoders import Nominatim
# Initialize the geocoder
geolocator = Nominatim(user_agent="your_app_name")
# Spexi API configuration
BASE_URL = "https://api-world.spexi.com/api/ogc/v1"
COLLECTION_ID = "your_collection_id" # Replace with actual collection ID
# Sample addresses to geocode
addresses = [
"Science World, Vancouver, BC",
"Palace of Fine Arts, San Francisco, CA",
"68 Bluenose Drive, Lunenburg, NS"
]
# Geocode each address
locations = []
for address in addresses:
location = geolocator.geocode(address)
if location:
locations.append({
"address": address,
"latitude": location.latitude,
"longitude": location.longitude
})
print(f"✓ {address}")
print(f" → {location.latitude:.6f}, {location.longitude:.6f}")
print(f" → {BASE_URL}/collections/{COLLECTION_ID}/items?p={location.longitude},{location.latitude},20&focused=focused")
else:
print(f"✗ Could not geocode: {address}")Output
The generated URLs can be used directly to query the items endpoint and retrieve aerial imagery for each location:
Science World, Vancouver, BC

Palace of Fine Arts, San Francisco, CA

68 Bluenose Drive, Lunenburg, NS

Last updated