Skip to main content

A utility for geocoding csv files.

Project description

This is a Python based utility for geocoding csv files using various online geocoding service.

Installation

Installation using pip

pip install giokoda

Installation from source

Download the source code from github, Example

git clone https://github.com/WorldBank-Transport/giokoda.git

Install the module and its dependancies

cd giokoda
python setup.py install

Usage

This utility can be used as a Python module or as an executable script.

Using as python module

Basic example:

import giokoda
giokoda.geocode_csv('input.csv')

The above code will try to goecode the provided ‘input.csv’ file and write its output to ‘input.csv-geocoded.csv’

A geocode_csv function can geocode entities from a provided input csv file and write results to a csv file.

It also returns a dictionary containing error, success and total count of geocoded rows.

General syntax:

geocode_csv('input/file.csv', **kwargs)

Required parameter

infile, (filepath/str)

path to a csv file to geocode.

Optional keyword arguments (**kwargs)

outfile, (filepath/str)

path to file to write output csv

service, (str), default: ‘nominatim’.

Name of a geocoding service to use. This can be a name of any geocoding service that is supported by geopy.

query_column, (str), default: ‘name’

Name of a column containg text to geocode.

query_columns (list): default: []. A list of a columns to be combined in order to produce a text to geocode.

service_kwargs, (dict)

Optional keyword arguments for initialization of geocoding service.

delimiter (str): default: ‘,’, A one-character string used to separate fields.

quotechar (str): default: ‘”’, A one-character string used to quote fields containing special characters in a csv file, such as the delimiter or quotechar, or which contain new-line characters.

Return

geocode_csv() returns a dictionary of success, error and total count:

{
    'total': 0,
    'success': 0,
    'error': 0
}

Using an executable script

  • Run geocode_csv via command line interface.

Example:

geocode_csv /input/file.csv

or including a api key:

geocode_csv --service <SERVICE-NAME> --params '{"api_key": "<YOUR-API-KEY>"}' /input/file.csv

General usage:

geocode_csv [-h] [-o OUTPUT] [-s SERVICE] [-c COLUMN] [-p PARAMS] input

Required argument

input

Full path to csv file to geocode

Optional arguments

-h, –help

show this help message and exit

-o OUTPUT, –output OUTPUT

Full path to output file

-s SERVICE, –service SERVICE

Geocoding service name, example arcgis, baidu, google, googlev3, geocoderdotus, geonames, yahoo, placefinder, opencage, openmapquest, mapquest, liveaddress, navidata, nominatim, geocodefarm, what3words, yandex and ignfrance

-c [COLUMN [COLUMN …]], –column [COLUMN [COLUMN …]]

Name(s) for column(s) containing text content to geocode. Multiple column names should be separated by white space.

-p PARAMS, –params PARAMS

Keyword arguments for geocoding service initialization presented as json object

-d DELIMITER, –delimiter DELIMITER

A one-character string used to separate fields in a csv file

-q QUOTECHAR, –quotechar QUOTECHAR

A one-character string used to quote fields containing special characters in a csv file, such as the delimiter or quotechar, or which contain new-line characters.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

giokoda-0.1.2.tar.gz (5.6 kB view details)

Uploaded Source

File details

Details for the file giokoda-0.1.2.tar.gz.

File metadata

  • Download URL: giokoda-0.1.2.tar.gz
  • Upload date:
  • Size: 5.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for giokoda-0.1.2.tar.gz
Algorithm Hash digest
SHA256 6c4721bb1967983bfde85c1f90d2516fe5d376722b532d2c34382019489eed55
MD5 3cd40378e656438d0639b64fdc551973
BLAKE2b-256 ba9d578d7f0153a216c4e4846fb4f5803a03b67626e8e97825128dd9fcf91b0a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page