Package whois :: Module geomap
[frames | no frames]

Module whois.geomap

whois Python module
-------------------

Geographical localisation of countries thanks to a longitude and latitude database.

Querying coordinates of a single country:

>>> whois.geomap.getLongLat('SPAIN')
(40.0, -4.0)

Drawing the world map with circles at given countries:

>>> from pylab import show
>>> whois.geomap.world({'CANADA': 48, 'FRANCE': 4, 'INDIA': 570})
>>> show()

Function Summary
  getLongLat(Country)
Returns the country longitude and latitude, 'None' if country not found.
  loadCountryLocations()
Loads the file of country longitudes and latitudes.
  loadCountryTranslation()
Loads the file of whois country to geos country translation.
  strCoord2Num(StrValue)
Converts a string longitude or latitude to a float number.
  world(CountryStats, smin, coeff, func, noticks, c, marker, cmap, norm, vmin, vmax, alpha, linewidths, faceted, **kwargs)
Draws the world map with circles at country location.

Variable Summary
str __ModulePath__ = '/home/jm/dev/lib/whois'

Function Details

getLongLat(Country)

Returns the country longitude and latitude, 'None' if country not found.
>>> Coords = getLongLat(Country)
Input:
  • Country = country name, *uppercase* only
Output:
  • Coords = tuple (longitude, latitude) or 'None'

loadCountryLocations()

Loads the file of country longitudes and latitudes.
>>> loadCountryLocations()

loadCountryTranslation()

Loads the file of whois country to geos country translation.
>>> loadCountryTranslation()

strCoord2Num(StrValue)

Converts a string longitude or latitude to a float number.
>>> Coord = strCoord2Num(StrValue)
Input:
  • Value = string coordinate as 'DD MM O', DD degrees, MM minutes, O orientation (= 'E', 'W', 'N' or 'S')
Output:
  • Coord = float coordinate (degrees)

world(CountryStats, smin=200.0, coeff=1.0, func=None, noticks=True, c='b', marker='o', cmap=None, norm=None, vmin=None, vmax=None, alpha=1.0, linewidths=None, faceted=True, **kwargs)

Draws the world map with circles at country location. The circles surface is proportional to a function of input data for each country (see below).
>>> ScatterObj = world(CountryStats, smin=200.0, coeff=1.0, func=None, noticks=True, c='b', marker='o', cmap=None, norm=None, vmin=None, vmax=None, alpha=1.0, linewidths=None, faceted=True, **kwargs)

Important note: saving a map as PNG significantly decreases circle surface.

Input:
  • CountryStats = dictionary of country stats, CountryStats[Country] = integer
  • smin = minimum circle surface (pixels, world = 2048x1024)
  • coeff = circle sizing coefficient
  • func = input data function
  • noticks = do not draw axis ticks
  • other args = see matplotlib 'scatter' function documention
Output:
  • ScatterObj = the 'scatter' draw object
Example:
>>> whois.geomap.world({'CANADA': 50, 'FRANCE': 34, 'INDIA': 67})

The circle surface is computed this way:

S = map(func, coeff * array(CountryStats.values()) + smin)

Variable Details

__ModulePath__

Type:
str
Value:
'/home/jm/dev/lib/whois'                                               

Generated by Epydoc 2.1 on Sat Mar 31 22:33:24 2007 http://epydoc.sf.net