Address Lookup
Prerequisites
pip install geopyGeocoding service
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
Science World, Vancouver, BC

Palace of Fine Arts, San Francisco, CA

68 Bluenose Drive, Lunenburg, NS

Last updated