OpenCage Geocoding Using KNIME

OpenCage Geocoder

A standard installation of KNIME does not come with a built in Geocoder node but it’s very easy to either install one or make your own.

KNIME has a page dedicated to Geo Nodes (https://www.knime.com/book/geo-nodes) using the Palladian Community Nodes that supports both MapQuest and Google.

But if you want to roll your own using another geocoding service it’s very easy.

OpenCage Geocoding API

OpenCage is a well known Geocoding API that has very reasonable pricing allowing you to test the service for free and paid plans starting at €45 per month for 10,000 requests per day. First you should sign up to the service and get an API key for the free trial plan.

OpenCage Pricing Plans

Using my OpenCage component you can create a simple workflow as shown below. This example shown how easy it is to feed addresses, geocode and then present the results on a map colour coded by location.

OpenCage Geocoding workflow

Opening the OpenCage component shows the details. Essentially it’s three configuration nodes used for the input, a GET Request to connect to the OpenCage API and parsing and cleaning of the return data.

OpenCage Component

Node Configuration

The node has a few configuration options:

  • API Key provided by OpenCage
  • Field that contains the address information to Geocode
  • Rate limit option in requests per second (dependant on your plan)
OpenCage Configuration

Node Output

The node will output all input data plus:

  • Latitude
  • Longitude
  • Confidence Score
  • HTTP Status Code
  • OpenStreetMap link
  • Address returned by OpenCage

An example out put looks like the table below.

AddressStatusconfidencelatlngurlname
735 S Figueroa Street, Suite 150 Los Angeles, CA 90017200933.866183-118.2816171https://www.openstreetmap.org/?mlat=33.86618&mlon=-118.28162#map=17/33.86618/-118.28162South Figueroa Street, Los Angeles, CA 90248-4007, United States of America
865 Avenue of the Americas New York, NY 10001200940.7478596-73.9894889https://www.openstreetmap.org/?mlat=40.74786&mlon=-73.98949#map=17/40.74786/-73.98949Nordstrom Rack, 865 6th Avenue, New York, NY 10001, United States of America
224B Colonie Center Albany, NY 12205200942.7065888-73.8202512https://www.openstreetmap.org/?mlat=42.70659&mlon=-73.82025#map=16/42.70659/-73.82025Colonie Center, 224 Colonie Center, Colonie, NY 12205, United States of America
555 12th Street Northwest, Front 1 Washington D.C. 20004200738.8969674-77.0272414https://www.openstreetmap.org/?mlat=38.89697&mlon=-77.02724#map=17/38.89697/-77.02724Crunch Fitness, 555 12th Street Northwest, Washington, DC 20004, United States of America

Using the Latitude/Longitude to Coordinate (from Palladian), Colour Manager and Map Renderer (from Palladian) it’s easy to plot the co-ordinates on a map by colour and add labels.

Map Viewer

Creating components like this is a great way to wrap a complex process into a simple to use and re-usable node.

Join the conversation

2 Comments

  1. Hi,
    thank you for this helpful node.
    I am new to knime and was happy to see that there is this connection to opencagedata existing.
    But somehow I wont get any results. The node itself is executing properly, but I get back only a status 403 and nothing else.
    Am I missing a general setting?

    1. Hi,

      This was my mistake as I accidentally hard coded the API key. I’ve updated the version on KNIME Hub so if you download and try again it should work.

      /Bob

Leave a comment

Your email address will not be published. Required fields are marked *