Nominatim vs Photon geocoder

Looking up a location given free-form address is one of the most frequent operations on geospatial data. Almost every business needs to recognize and locate customer addresses. At the same time, differences in languages, country-specific address and postcode formats, typos and ambiguous names make it very hard to do it right.

This is why one normally uses a geocoder – a specialized search engine that is designed to return the most relevant location for a given address string.

Feature comparison

Nominatim geocoder is a “de-facto” standard in the world of open source geocoding engines. It is developed and maintained by the OpenStreetMap community.

Photon is another popular open-source geocoder with the focus on search-as-you-type suggestions and typos correction. It is developed and maintained by Komoot.

Both geocoders are fine pieces of software, supporting both forward and reverse geocoding and primarily use the OpenStreetMap dataset for address lookups.

FeatureNominatimPhoton
Structured searchyesno
Search-as-you-typenoyes
Hardware requirementshighmedium
Typo tolerancenoyes
Filtering resultsbounding box
county code
special phrases
bounding box
OSM tag name and value
Ranging resultsnolocation bias
DatabasePostGISElasticsearch
Data sourcesOpenStreetMap
Wikipedia
US Tiger & Postcodes
UK Postcodes
OpenStreetMap
Response formatsGeoJSON
JSON
HTML
XML
GeoJSON
Returned datafull, including geometrybasic
User interfaceyesno

Conclusion

So, which geocoder is the best, Nominatim or Photon? As usual, the answer is – it depends.

Photon excels in search-as-you-type scenarios. It tolerates typos and spelling mistakes. Photon is good for a general, free-form text geocoding. It is relatively lightweight and not very difficult to maintain – setting up your own instance takes from few hours to few days.

Nominatim on another hand has superior structured address search and filtering capabilities. It supports a number of output formats and advanced filters. Nominatim works best in scenarios when you at least roughly know what you’re looking for and where. Nominatim comes with significant complexity, hardware requirements, and maintenance overhead. It may take days and weeks to configure your own functional Nominatim instance.

In both cases, you’ll need to have expertise and time to set up your own geocoder instance. Alternatively, you can use our managed Photon and Nominatim geocoder instances. We take care of all aspects – configuration, updates, maintenance, availability, and security. We also provide consulting and custom software development. In case you’re looking for high-volume batch geocoding or cannot use 3rd party services due to security or privacy regulations, we can also set up a dedicated geocoder instance for you.

What is OpenStreetMap and how it is better than Google Maps

About OpenStreetMap

OpenStreetMap, or “OSM”, is a Wikipedia for the maps. It is a free, open, and global community project. OpenStreetMap mission is to map everything that worth to be mapped. And, similar to Wikipedia, OSM data can be added, edited and used by everyone.

I say “data” and not “maps” because that’s what OSM essentially is. Open Street Map is a big open database full of free geospatial data, available for everyone!

Indeed, OSM is widely used to create digital maps. But it can do way more than that. OSM applications include routing and navigation, converting GPS coordinates to addresses, searching places by name, analyzing map data and many many more.

Driving route from Berlin to Potsdam, Germany, calculated on OSM data
Driving route from Berlin to Potsdam, Germany, calculated on OSM data

In 2019, OpenStreetMap with its more than 5 000 000 members and more than than 1 200 000 contributors is clearly the biggest and most successful crowd-sourced mapping project in human history. And as Facebook, Uber, Microsoft and thousands of others are utilizing OSM data in their products, almost anyone can be counted as OSM user, direct or indirect.

Power of crowdsourcing

OpenStreetMap project was started in 2004. Back then map data were controlled by commercial organizations and governments, hard to use and expensive to buy. Mapping itself was done primarily by the teams of GIS specialists. Most of the time, they were not in a position to know how well data they map reflecting the reality, to validate and timely update them.

OpenStreetMap managed to disrupt the industry and change all of that in just a few years. It helped to demystify cartography and geography as a science and has given everyone the possibility and tools needed to contribute. No long formalities, no expensive licenses or equipment – anyone with a computer and Internet access could join and start making the world better.

And that approach worked amazingly well!

First 10 years of OpenStreetMap mapping progress

In fact, OpenStreetMap became so successful that Google had to play a “catch-up” game. The company introduced Google Map Maker, with familiar OSM-like interface, to allow people around the world to contribute.

Of course, it was not the same. The main difference is – if you contribute to OSM, data belong to you and OSM community, and stay free and open for everybody, under creative commons license. And when you contribute to Google Maps – well, all changes you make belong to Google, and it is up to Google to decide who and how can use that data.

Number of monthly edits for OpenStreetMap exceeds 8 000 000
Number of monthly edits for OpenStreetMap exceeds 8 000 000

In addition, every change made to OpenStreetMap is immediately visible to others, when in the case of Google it is delayed by long moderation and review process.

Crowdsourced mapping with immediate access to the changes appeared to be especially important for mapping crisis and natural disaster areas. In 2010, when Haiti suffered from a disastrous earthquake, OSM volunteers managed to map the whole island in just a couple of days from satellite imagery.

OpenStreetMap volunteers mapping Haiti after 2010 earthquake

This would not be possible with any existing commercial provider. Businesses are bound to mapping data that are profitable to sell. Also, most of the time they only capable of publishing results on a particular schedule and cannot do it every second, as OSM does. And, even Google with huge investments, cannot match the scale and the power local knowledge of the OSM community.

History of OpenStreetMap

Like most many things, OpenStreetMap started small. In August 2004, Steve Coast, back than a physics student at UCL, came up with an initiative to create free, editable maps of UK.

Just a few months later, by the end of 2004, web site openstreetmap.org was up and running, based on 100% open source software. It contained community email list, wiki documentation and first versions of map editing software.

By the end of 2005, OpenStreetMap had more than 1000 registered users. And in August 2006 OpenStreetMap Foundation was formally registered as a non-profit, UK based company. At that time OSM community included more than 3000 members.

Following infographic depicts major and noteworthy OpenStreetMap milestones.

Moments of OpenStreetMap history infographic, by Martin Elmer, from Visually
Moments of OpenStreetMap history infographic, from Visually

Part of OSM success related to its explosive community growth and perfect timing. OSM growth matched with the global adoption of smartphones, which at the same time can benefit from the quality offline map data and ideal for the “on-the-go” mapping. Most of the smartphone map and navigation applications are fully or partially based on the OpenStreetMap.

Explosive growth of OSM community year-to-year
Explosive growth of OSM community year-to-year

Another important component of success is related to the active position of the OpenStreetMap Foundation. Successful negotiations with companies like Bing, DigiGlobe, and Ersi allowed using their high-quality satellite and aerial imagery for the OpenStreetMap mapping efforts. Thanks to this, the ever-growing OSM community had enough raw material to work on.

Arcgis satellite imagery as base layer in OSM map editor
Arcgis satellite imagery as base layer in OSM map editor

OpenStreetMap vs Google Maps

OpenStreetMap data widely used to create “digital maps” or “slippy maps“, similar to Google Maps. Both OpenStreetMap and Google Maps support searching places by name and route calculations.

OpenStreetMap vs Google Maps

No surprise that Google Maps, as a state-of-the-art commercial product backed by one of the biggest tech companies in the world, has more polish on it.

It has smarter place search, better user interface, fast 3D accelerated map rendering. Google Maps also gives its users the possibility to submit new and corrected information, which may be added to the map after moderation.

Google Maps also has amazing satellite and aerial imagery, and very cool “street view” mode – something that current OpenStreetMap cannot offer.

How can OpenStreetMap compete or be better than that? By offering features that Google Maps, as a cloud service, cannot offer.

OpenStreetMap is more than just a map of the world, place search and navigation. It gives free and unlimited access to the entire dataset, with a complete history of changes, without limiting who and how can use it. OpenStreetMap is a perfect foundation for emerging innovative and creative solutions and targeted products.

With OSM, map data for the whole planet can be downloaded and used completely offline. Google Maps can only cache small region and generally can not work without an Internet connection.

OSM dataset can be used to large-scale geocoding, routing and analysis, which would be impossible using Google Maps.

OpenStreetMap for business

OpenStreetMap is awesome, yet using it for your business may be quite challenging. As a non-profit organization, OSM does not provide uptime SLAs, support and consulting.

We at Geoapify believe that this limits OSM adoption, and happy to support you by providing stable, affordable, business-friendly OpenStreetMap mapping service. In addition to maps, we also provide a complete set of tools, including places search, geocoding, routing and reachability analysis.

And the best thing – you can register and start to use this all for free, also for commercial purposes. Give our services a try with our interactive Playground – no registration required.

You can reach us at any time at [email protected]. We will be happy to help!

Map animation with Mapbox GL

What can be more eye-catching than smooth, interactive, three-dimensional map animation? Impress your visitors by displaying your map data in stunning 3D!

Previously we have compared OpenLayers and Leaflet map libraries. Both are great choices if you want to add interactive map to your website. They are free, battle-tested, extensible and supported by active communities.

But what if you need a very fast, animated, eye-catching 3D map? Both Leaflet API and OpenMapLayersAPI do not support 3D and free-form map rotation. In this case Mapbox GL map library can be a great option.

Mapbox GL JS is one of the most advanced JavaScript map rendering libraries when it comes to smooth interactive animation. Mapbox GL API is slightly harder to use and not compatible with existing Leaflet plugins and examples. But it is using hardware-accelerated WebGL technology to dynamically draw data with the speed and smoothness of a video game.

In this article I’ll show you how to animate and implement 3D map rotation around a selected point. The end result should look like this:

Map rotation animation in 3D with Mapbox GL

If you short on time and just looking for the complete HTML code, you can find it at the bottom of the page.

Setting up our 3D map

As first step, we need to add imports for Mapbox GL library and its CSS style sheet into the HEAD of our page

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/mapbox-gl/0.53.1/mapbox-gl.css" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/mapbox-gl/0.53.1/mapbox-gl.js"></script>

Once imported, we can define a <div> element which will host map visualization and add Javascript code which will initialize Mapbox GL to render our map in 3D with specified initial location, zoom, pitch and bearing. Please do not forget to put your real API key instead of “YOUR_API_KEY” placeholder in the map tiles URL.

<div id='map'></div>
<script>
var map = new mapboxgl.Map({
    container: 'map',
    style: {
        "version": 8,
        "sources": {
            "basemap": {
                "type": "raster",
                // map tile source 
                "tiles": [
                    "https://maps.geoapify.com/v1/tile/carto/{z}/{x}/{y}.png?api_key=YOUR_API_KEY"
                ],
                "tileSize": 256
            }
        },
        "layers": [{
            "id": "basemap",
            "type": "raster",
            "source": "basemap",
            "minzoom": 0,
            "maxzoom": 22
        }]
    },
    center: [-73.991462, 40.724637], // starting position
    zoom: 12, // starting zoom
    pitch: 60, // starting pitch in degrees
    bearing: 0, // starting bearing in degree
});

This should give us basic interactive 3D map. You should be able to move the map to a different locations, zoom in and out, and change view angle.

Interactive 3D map view of Manhattan, NY
Interactive 3D map view of Manhattan, NY

Adding map rotation animation

As next step, let’s add dynamic map animation, which will change view angle to create effect of flying around the map center. Please add the following code into our <script> block and refresh the page:

function rotateCamera(timestamp) {
    // rotate at approximately ~10 degrees per second
    map.rotateTo((timestamp / 100) % 360, {duration: 0});
    // request the next frame of the animation
    requestAnimationFrame(rotateCamera);
}

map.on('load', function () {
    // start the animation
    rotateCamera(0);
});

Final steps

As the last step, let’s add basic map navigation controls and basemap attribution.

// map navigation controls
map.addControl(new mapboxgl.NavigationControl());

// attribution
map.addControl(new mapboxgl.AttributionControl({
	compact: false,
	customAttribution: 'Powered by <a href="https://geoapify.com/">Geoapify</a> | © <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
}));
Complete map with controls and attribution
Complete map with controls and attribution

Complete HTML code

Final version of the HTML page could look like this. Please feel free to copy the code, insert API key and open it in your browser to see how it works.

<html>
<head>
    <meta charset='utf-8' />
    <title>Mapbox GL example: rotate map animation in 3D</title>
    <meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/mapbox-gl/0.53.1/mapbox-gl.css" />
    <script src="https://cdnjs.cloudflare.com/ajax/libs/mapbox-gl/0.53.1/mapbox-gl.js"></script>
    <style>
        body { margin:0; padding:0; }
        #map { position:absolute; top:0; bottom:0; width:100%; }
    </style>
</head>
<body>

<div id='map'></div>
<script>
var map = new mapboxgl.Map({
    container: 'map',
    style: {
        "version": 8,
        "sources": {
            "basemap": {
                "type": "raster",
                // map tile source 
                "tiles": [
                    "https://maps.geoapify.com/v1/tile/carto/{z}/{x}/{y}.png?api_key=YOUR_API_KEY"
                ],
                "tileSize": 256
            }
        },
        "layers": [{
            "id": "basemap",
            "type": "raster",
            "source": "basemap",
            "minzoom": 0,
            "maxzoom": 22
        }]
    },
    center: [-73.991462, 40.724637], // starting position
    zoom: 12, // starting zoom
    pitch: 60, // starting pitch in degrees
    bearing: 0, // starting bearing in degree
});

function rotateCamera(timestamp) {
    // rotate at approximately ~10 degrees per second
    map.rotateTo((timestamp / 100) % 360, {duration: 0});
    // request the next frame of the animation
    requestAnimationFrame(rotateCamera);
}

map.on('load', function () {
    // start the animation
    rotateCamera(0);
});

// map navigation controls
map.addControl(new mapboxgl.NavigationControl());

// attribution
map.addControl(new mapboxgl.AttributionControl({
	compact: false,
	customAttribution: 'Powered by <a href="https://geoapify.com/">Geoapify</a> | © <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
}));
	
</script>

</body>
</html>

Summary

Mapbox GL generally requires more JavaScript code to be written than Leaflet and can be more complicated to maintain.

So, you may ask when to use Leaflet and when to use Mapbox GL?

The answer is simple – if you don’t need 3D and extremely fast animation then Leaflet would be the best choice. It has biggest community, best documentation, extensive set of plugins and works well in any situation. And if you really need advanced 3D maps with animations and top rendering speed on modern devices – then Mapbox GL is your friend.

From GIS to Geospatial Intelligence

Technology advances in cycles. Moreover, the periods of evolution interleaved with revolutionary changes. And it seems that we are standing on the edge of the next revolutionary transition from experts-oriented GiS to Geospatial Intelligence solutions available for the much wider audience. The solutions which are easy to understand to a non-expert, easy to use, and affordable to small companies and individuals.

Geospatial intelligence brings more and more value to business intelligence products. As a result, the answer to the key question “where” start to play an extremely significant role by making business decisions.

Location Intelligence for business intelligence
Location Intelligence for business intelligence

Role of Geospatial Intelligence in our life

Imagine a holiday planning website where you can filter hotels by reachability. For example, visualize only hotels reachable within 10 minutes of walking from the beach or ski lift. Great, isn’t it?

Another case could be a property listing website. The website where you can choose a property with desired amenities nearby and optimize your commute time to the office or university. The website could help you, in addition, to find the best price-value ratio or investment potential based on your needs!

There are a lot of examples of geospatial intelligence appliance for business cases as well. For instance, an event planning service which takes an account of the living places of participants. Or office relocation website which suggests the best locations based on employees commute time and rental prices.

Good transport connection
Good transport connection

The increasing popularity of Geospatial solutions

Broad adoption of Geospatial intelligence can have an effect comparable to the transition from printed maps to digital maps. However, nowadays we can’t imagine our routine without smartphones and car navigation systems which guide us to the destination in an optimal way.

It is hard to believe, but just 15 to 20 years ago printed maps were the most common way to plan a route. Technologies like GPS, digital maps and computer-based routing were existing and moreover well-developed. But they were accessible only to experts, big organizations, and governments.

Geoapify mission to make geospatial intelligence affordable for everyone

At Geoapify, we see our mission in democratizing geospatial intelligence and underlying technologies. We intend to make it accessible, usable, and valuable for everyone who has unanswered “where” questions.

Our APIs provide everything you need to create a spatial solution from zero. Solution builder Mapifator helps to make custom maps with geospatial analytics technologies layers with graphical interface.