Geocoding with Python using Nominatim: A beginner’s guide

Geopostcodes - nominatim geocoding
Updated: April 1, 2026
Table of Contents

Nominatim is an open-source geocoding engine built on OpenStreetMap data. It converts addresses into geographic coordinates (forward geocoding) and coordinates into readable addresses (reverse geocoding). Used widely for prototyping and non-commercial applications, but entirely dependent on OpenStreetMap contributions.


Key takeaways

  • Nominatim is an open-source geocoding engine built on OpenStreetMap, supporting forward (address → coordinates) and reverse (coordinates → address) geocoding through its /search and /reverse API endpoints, which can be accessed easily in Python.
  • It generates synthetic addresses from OpenStreetMap data, meaning results depend on community-contributed geographic information rather than official postal authority records.
  • Nominatim is suitable for prototypes, research, and low-volume applications, but public API rate limits and regional data variability make it less predictable for high-volume production environments.
  • Organizations that require scalable, standardized geocoding with consistent latitude and longitude reference data may need curated postal and boundary datasets to reduce operational complexity.

How does your delivery app know exactly where to find you? It’s thanks to geocoding, the process of turning “123 Main Street” into precise latitude and longitude coordinates.

In today’s location-driven digital landscape, the ability to convert addresses into geographic data is essential for businesses worldwide. Whether for delivery platforms, customer distribution analysis, or location-based marketing campaigns, geocoding is the bridge between human-readable addresses and machine-processable geographic information.

💡 Simplify your geocoding challenges with comprehensive global address data. For over 15 years, GeoPostcodes has delivered the most accurate worldwide geocoded ZIP Code database, handling complex address formats seamlessly. Browse our datasets and download a free sample here.

Introduction to geocoding and reverse geocoding

Geocoding turns an address into geographic coordinates (latitude and longitude). Reverse geocoding does the opposite: it takes coordinates and gives you a readable address.

Behind the scenes, geocoding uses algorithms to parse address components, match them to a geographic database, and return exact latitude and longitude. Reverse geocoding takes those coordinates and finds the closest formatted address component—super helpful for mobile applications that track user locations.

Its accuracy depends on the quality of the data you’re using. Knowing when to use each process helps you select the right tool: geocoding is ideal for converting addresses into map points, and reverse geocoding is crucial for showing users their current location.

Understanding Nominatim API

Nominatim is a free, open-source geocoding engine built on OpenStreetMap data. It supports both forward geocoding (converting addresses into coordinates) and reverse geocoding (converting coordinates into readable addresses). The API generates address results based on OpenStreetMap points and associated geographic data.

It is a free, open-source geocoding tool powered by OpenStreetMap, generating synthetic addresses from OSM points.

The homepage of Nominatim

It works globally, supports most countries and languages, and handles both forward and reverse geocoding through simple API endpoints: /search for addresses and /reverse for coordinates. Each endpoint offers extensive customization options for different geographic precision levels.

Key Features:

  • Free and open-source access
  • Multiple output formats (JSON, XML, GeoJSON)
  • Basic batch processing capabilities

Nominatim supports both free-form queries for natural language input and structured address searches with more control over address component matching. This dual approach accommodates various data input formats and user preferences.

Important Note: When using Nominatim for free, you must follow the usage rules and provide proper credit to maintain access.

Understanding OpenStreetMap data

Nominatim generates synthetic addresses, which are computer-generated address representations created from geographic data points rather than official postal addresses.

Nominatim relies on OpenStreetMap (OSM), a collaborative mapping project built by volunteers using aerial imagery, GPS, and other sources. This community effort provides wide coverage.

OSM data includes points (nodes), lines (ways), and groups (relations), which together create a detailed, comprehensive, free, and editable map of the planet. Nominatim then combines OSM location data (like building positions, street names, and administrative boundaries) to produce readable address formats, even when no formal address exists in postal systems.

Because of the open nature of OSM, anyone can edit it to keep the map up to date, especially after events like natural disasters or new construction. However, quality can vary between regions: urban areas are usually well-covered, while rural or less-populated regions may have less complete or outdated information.

Knowing this helps you set the right expectations when using Nominatim in different regions.

Working with the Nominatim API

Want to give it a try? You can use Nominatim to create custom geocoding applications, such as searching for locations by name or address. However, before getting started, you only need a minimal setup using Python’s geopy library and import the necessary modules to explore its functionality.

For example, you can refer to the following code that demonstrates a complete working example of geocoding. This example shows how to convert the White House address into precise coordinates:

from geopy.geocoders import Nominatim
from geopy.exc import GeocoderTimedOut, GeocoderServiceError

# Initialize the geocoder with a unique user agent
geolocator = Nominatim(user_agent="your_unique_app_name")

# Forward geocoding example
try:
    location = geolocator.geocode("1600 Pennsylvania Avenue, Washington, DC")
    if location:
        print(f"Address: {location.address}")
        print(f"Coordinates: {location.latitude}, {location.longitude}")
    else:
        print("Address not found")
except (GeocoderTimedOut, GeocoderServiceError) as e:
    print(f"Geocoding error: {e}")

This code creates a geocoder instance, queries an address, handles the response and potential errors, then extracts coordinates from the result. When run, it outputs the full formatted address and precise latitude/longitude coordinates.

For reverse geocoding, the process reverses with coordinate input:

# Reverse geocoding example
try:
    coordinates = "38.8977, -77.0365"  # White House coordinates
    location = geolocator.reverse(coordinates)
    if location:
        print(f"Address: {location.address}")
        print(f"Raw data: {location.raw}")
except (GeocoderTimedOut, GeocoderServiceError) as e:
    print(f"Reverse geocoding error: {e}")

Use structured searches when you have clean, separated address components and free-form searches for user-entered addresses.

The API’s documentation (available on the Nominatim website) provides comprehensive guidance for implementing custom geocoding solutions with various output formats and precision levels.

Best practices and common issues when geocoding with Nominatim

Successful geocoding with Nominatim depends on both proper API usage and an understanding of how OpenStreetMap data behaves. Clean input data, responsible API usage, and awareness of OpenStreetMap’s data model all play a role in producing reliable results.

API usage best practices

  1. Start with clean, well-formatted address data. Poor input data will produce unreliable geocoding results.
  2. Validate addresses before sending them by fixing formatting issues, trimming spaces, and standardizing abbreviations. Cache repeated addresses to reduce unnecessary API calls.
  3. Always implement rate limiting to respect API usage policies. Nominatim’s free service has usage limits, and exceeding them can result in blocked access.
  4. Be ready to handle errors such as timeouts or incorrect responses. When processing large datasets, batch requests with delays help avoid hitting rate limits.
  5. Use a custom user agent and provide clear attribution to OpenStreetMap to comply with the Nominatim usage policy.
  6. Geocode only at the level of precision required for your use case. If rooftop coordinates are unnecessary, street-level or postal code coordinates may be sufficient.

Data limitations and reliability considerations

  • Synthetic address generation: Nominatim produces synthetic addresses based on OpenStreetMap geographic data rather than official postal authority records. These inferred addresses can be inaccurate or misleading and may not be suitable for applications requiring verified address data.
  • Data inconsistency and vandalism risks: OpenStreetMap’s open editing model allows anyone to modify map data. While this enables rapid updates, it also introduces reliability risks. For example, the Pokémon Go incident demonstrated how users manipulated map data for gaming purposes.
  • Regional variation in data quality: Mapping coverage varies widely between regions. Western Europe often has detailed mapping, while developing markets may have incomplete or outdated data.
  • Processing complexity: Raw OpenStreetMap data is not always standardized or ready for automated workflows. Organizations often need additional validation, cleaning, or enrichment before integrating the data into operational systems.
  • Licensing considerations: Open-source data does not imply unrestricted use. Each dataset has specific licensing terms that define how the data can be used.

When should you use Nominatim?

Nominatim is suitable for projects that require flexible, low-cost geocoding based on OpenStreetMap data. Its open-source nature and public API make it accessible for experimentation and lightweight applications.

Use Nominatim when:

  • You are building prototypes or proof-of-concept applications.
  • You need basic forward or reverse geocoding without commercial licensing costs.
  • You are conducting research, academic projects, or internal data exploration.
  • You have the technical resources to self-host and manage the infrastructure.
  • Your application can tolerate variations in data completeness across regions.

Avoid relying exclusively on Nominatim when:

  • You operate high-volume, production-grade systems that require guaranteed uptime.
  • You need SLA-backed performance and predictable rate limits.
  • You require standardized, authoritative address data across multiple countries.
  • Your operations depend on consistent administrative hierarchies or postal accuracy.

Because Nominatim depends entirely on OpenStreetMap, data quality and update frequency vary by geography. Organizations using it in operational environments should evaluate whether its governance model, rate limits, and regional variability align with their requirements.

Alternatives to Nominatim

The selection of geocoding tools depends on several factors, from budget to accuracy requirements. While Nominatim provides free access to global mapping data, due to its limitations mentioned above, many businesses choose to invest in commercial solutions for the mission-critical applications.

When to Consider Commercial Solutions

For high-stakes applications where accuracy is paramount, commercial providers offer several advantages:

  • Curated, authoritative data: Professional services like GeoPostcodes provide comprehensive global address databases with precise coordinates, sourced from 1,500+ authoritative sources, eliminating the data inconsistencies inherent in crowd-sourced mapping
  • Consistent global coverage: Unlike OSM’s regional variations, commercial solutions offer standardized data quality across all markets
  • Verified address accuracy: No synthetic or inferred addresses—only verified, deliverable locations suitable for shipping and billing
  • Enterprise support and reliability: Dedicated support teams for business-critical operations

Choosing the Right Solution

Evaluate your specific requirements and choose the best solutions for you:

  • Budget-conscious projects: Nominatim works well for educational, non-profit, or basic mapping needs
  • Business applications: Commercial solutions provide the reliability and accuracy required for customer-facing services
  • Hybrid approach: Use multiple geocoding solutions simultaneously for validation and fallback in high-stakes scenarios

For businesses requiring systematic batch geocoding of large datasets without the specialized bandwidth to manage OSM’s complexities internally, you can build your scalable self-hosted solution, sourcing data from a professional data provider. This will eliminate the ongoing maintenance burden while ensuring consistent, accurate results across global operations.

Conclusion

Geocoding isn’t one-size-fits-all. The right solution depends on your precise needs, data volume, and budget. While free tools like Nominatim are powerful, managing them at scale takes time and requires a deep understanding of geocoding and reverse geocoding, as well as ongoing maintenance efforts.

For businesses that need systematic batch geocoding of large datasets and don’t have the specialized bandwidth to deal with them internally, you can explore commercial providers to create accurate geocoding applications or use a reference database to obtain less granular geocoding at a fraction of the complexity.

For over 15 years, GeoPostcodes’ data and boundaries have helped businesses worldwide simplify geocoding and reverse geocoding through highly accurate latitude and longitude coordinates. Browse our databases for free or request a quote.

FAQ

What is Nominatim geocoding?

Nominatim is a geocoder software tool that uses OpenStreetMap data to convert addresses into geographic coordinates. It processes OSM data to find locations and can perform reverse geocoding, transforming coordinates back into readable addresses using OSM object information.

What is the difference between Nominatim and OSRL?

Nominatim geocode focuses on converting addresses to geographic coordinates using OSM data, while OSRL is a routing tool. Nominatim handles geocoding software functions and reverse geocoding, whereas OSRM calculates routes between OSM points for navigation purposes.

How to get the latitude and longitude of a location?

There are several approaches to obtain geographic coordinates from addresses. For basic needs, you can use free geocoding tools like Nominatim – simply input your address to receive the corresponding latitude and longitude coordinates. However, for businesses requiring high accuracy, large-scale processing, or reliable support, commercial geocoding solutions offer significant advantages. Professional services like GeoPostcodes provide comprehensive global datasets with verified coordinates, better coverage in rural areas, and consistent data quality. These commercial alternatives eliminate the complexity of managing rate limits, handling data inconsistencies, and dealing with coverage gaps that can occur with free services. Choose based on your accuracy requirements, data volume, and whether you need enterprise-level reliability and support.

What is Photon vs Nominatim?

Both are geocoding software tools using OSM data for converting addresses to geographic coordinates. Photon offers faster search capabilities and can generate synthetic addresses, while Nominatim geocode provides more detailed OSM object information and handles bug reports more comprehensively.

What are the key features of Nominatim geocode for developers?

Nominatim geocode offers comprehensive geocoding capabilities, including forward address geocoding to obtain geographic coordinates and reverse geocoding to convert coordinates back to addresses. The tool can generate synthetic addresses for testing applications, utilizing OSM data for location information. Developers can create synthetic addresses for development purposes while accessing reliable geographic coordinates for mapping applications.

How does Nominatim geocode handle address conversion?

Nominatim geocode converts addresses to geographic coordinates and performs reverse geocoding to transform coordinates back to readable addresses.

It can generate synthetic addresses from OSM data. Always follow the Nominatim usage policy by providing proper attribution, using rate limiting, and including a unique user agent.

What geocoding capabilities does Nominatim offer for coordinate conversion?

Nominatim geocode provides comprehensive geocoding to obtain geographic coordinates from addresses and reverse geocoding for the opposite conversion.

The tool can generate synthetic addresses for testing purposes using OpenStreetMap data. Developers must comply with the Nominatim usage policy, including proper attribution and rate-limiting practices.

Related posts