In Python ecosystem, there are few libraries for call calling geocoding web services. Sometimes, directly using raw Python instead can be faster.
Until recently, GeoPy
was the library for the job but we recently found a new project called Geocoder
and where wondering why it seems to do the same job. We didn't really found a clue but choose instead to compare both solutions.
Let's see how they differ.
Repositories
Python version support:
Winner: GeoPy
Explanation: GeoPy
supports CPython 2.7, CPython 3.2, CPython 3.4, PyPy, and PyPy3 whereas Geocoder
supports "only" CPython 2.7 and 3.4.
Command Line
Winner: Geocoder
Explanation: There is none on the GeoPy
side.
Formats support
Winner: Geocoder
Explanation: Better because there are WKT and GeoJSON output whereas only in Nominatim in GeoPy
.
Moreover, you can pipe results, combined with command line abilities.
Confidence
Draw
Explanation: in fact, it's not really library dependend but it varies from each provider.
Providers
Draw
Explanation: It depends of the choosen/required geocoder(s)
There are 17 providers on GeoPy
and 18 providers on Geocoder
(included one nearly obsolete, TomTom)
We didn't inspect deeper the reverse-geocoding abilities but both are available.
You can see a summary below.
Geocoder | GeoPy |
---|---|
ArcGIS | ArcGIS |
Baidu Maps | Baidu Maps |
Bing | Bing |
CanadaPost | |
FreeGeoIP | |
GeocodeFarm | |
Geocoder.ca | |
geocoder.us | |
Geonames | Geonames |
GeoOttawa | |
HERE | |
IGN France | |
MapQuest | MapQuest |
MaxMind | MaxMind |
NaviData | |
OpenCage | OpenCage |
OpenStreetMap | OpenStreetMap |
SmartyStreets | |
TomTom (dead so not useful anymore except for "old" TomTom clients e.g https://geocoder.tomtom.com | |
What3Words | What3Words |
Yahoo | Yahoo |
Yandex | Yandex |
Niceties
On both side, you can find some advantages.
On GeoPy
, you can calculate distance between points using Haversine formula.
On Geocoder
, you get for free the GeoIP support using FreeGeoIP
and MaxMind
. You can determine your location from your IP or get an IP for a location. You can also manage Elevation with the Google Elevation API
and find Time Zone
Both libraries can use proxies or autocompletion on returned results (using raw
on GeoPy) when using IPython.
Conclusion
In our opinion, GeoPy
really focus on (reverse)geocoding only whereas Geocoder
is also about including more than the usual geocoding functions, in particular with the command line support.
We cannot choose a winner, both projects are too interesting.
Feel free to comment if any mistake was made on our side or you think some additions can be useful.
PS: Due to feedback, we updated supported geocoders list.
Commentaires