d_rats.geopy package

Submodules

d_rats.geopy.distance module

class d_rats.geopy.distance.Distance(kilometers=0, miles=0, feet=0, nautical=0)

Bases: object

feet
ft
kilometers
km
mi
miles
nautical
nm
class d_rats.geopy.distance.GeodesicDistance(a, b)

Bases: d_rats.geopy.distance.Distance

calculate()

Calculate and set the distance between self.a and self.b, which should be two geodesic points. Since there are multiple formulas to calculate this, implementation is left up to the subclass.

kilometers
class d_rats.geopy.distance.GreatCircleDistance(a, b)

Bases: d_rats.geopy.distance.GeodesicDistance

Use spherical geometry to calculate the surface distance between two geodesic points. This formula can be written many different ways, including just the use of the spherical law of cosines or the haversine formula.

The class member RADIUS indicates which radius of the earth to use, in kilometers. The default is to use the module constant EARTH_RADIUS, which uses the average great-circle radius.

RADIUS = 6372.795
calculate()
kilometers
class d_rats.geopy.distance.VincentyDistance(a, b)

Bases: d_rats.geopy.distance.GeodesicDistance

Calculate the geodesic distance between two points using the formula devised by Thaddeus Vincenty, with an accurate ellipsoidal model of the earth.

The class attribute ELLIPSOID indicates which ellipsoidal model of the earth to use. If it is a string, it is looked up in the ELLIPSOIDS dictionary to obtain the major and minor semiaxes and the flattening. Otherwise, it should be a tuple with those values. The most globally accurate model is WGS-84. See the comments above the ELLIPSOIDS dictionary for more information.

ELLIPSOID = (6378.137, 6356.7523142, 0.0033528106647474805)
calculate()
forward_azimuth
kilometers
d_rats.geopy.distance.arc_degrees(arcminutes=0, arcseconds=0)

Calculate the decimal equivalent of the sum of arcminutes and arcseconds in degrees.

d_rats.geopy.distance.destination(start, bearing, distance, radius=6372.795)
d_rats.geopy.distance.distance

alias of VincentyDistance

d_rats.geopy.distance.feet(miles=0, kilometers=0, nautical=0)
d_rats.geopy.distance.ft(miles=0, kilometers=0, nautical=0)
d_rats.geopy.distance.kilometers(miles=0, feet=0, nautical=0)
d_rats.geopy.distance.km(miles=0, feet=0, nautical=0)
d_rats.geopy.distance.mi(kilometers=0, feet=0, nautical=0)
d_rats.geopy.distance.miles(kilometers=0, feet=0, nautical=0)
d_rats.geopy.distance.nautical(kilometers=0, miles=0, feet=0)
d_rats.geopy.distance.nm(kilometers=0, miles=0, feet=0)
d_rats.geopy.distance.vincenty_destination(start, bearing, distance, ellipsoid=(6378.137, 6356.7523142, 0.0033528106647474805))

d_rats.geopy.geocoders module

class d_rats.geopy.geocoders.Geocoder

Bases: object

Base class for all geocoders.

geocode(string)
class d_rats.geopy.geocoders.MediaWiki(format_url, transform_string=None)

Bases: d_rats.geopy.geocoders.WebGeocoder

geocode(string)
geocode_url(url)
parse_xhtml(page)
classmethod transform_string(string)

Do the WikiMedia dance: replace spaces with underscores.

class d_rats.geopy.geocoders.SemanticMediaWiki(format_url, attributes=None, relations=None, prefer_semantic=False, transform_string=None)

Bases: d_rats.geopy.geocoders.MediaWiki

geocode_url(url, tried=None)
get_attributes(thing, attributes=None)
get_label(thing)
get_relations(thing, relations=None)
parse_rdf(page)

Parse the URL of the RDF link from the <head> of page.

transform_semantic(string)

Normalize semantic attribute and relation names by replacing spaces with underscores and capitalizing the result.

class d_rats.geopy.geocoders.Google(api_key=None, domain='maps.google.com', resource='maps/geo', format_string='%s', output_format='kml')

Bases: d_rats.geopy.geocoders.WebGeocoder

Geocoder using the Google Maps API.

geocode(string, exactly_one=True)
geocode_url(url, exactly_one=True)
parse_csv(page, exactly_one=True)
parse_js(page, exactly_one=True)

This parses JavaScript returned by queries the actual Google Maps interface and could thus break easily. However, this is desirable if the HTTP geocoder doesn’t work for addresses in your country (the UK, for example).

parse_json(page, exactly_one=True)
parse_kml(page, exactly_one=True)
parse_xml(page, exactly_one=True)

Parse a location name, latitude, and longitude from an XML response.

url
class d_rats.geopy.geocoders.Yahoo(app_id, format_string='%s', output_format='xml')

Bases: d_rats.geopy.geocoders.WebGeocoder

Geocoder using the Yahoo! Maps API.

Note: The Terms of Use dictate that the stand-alone geocoder may only be used for displaying Yahoo! Maps or points on Yahoo! Maps. Lame.

See the Yahoo! Maps API Terms of Use for more information: http://developer.yahoo.com/maps/mapsTerms.html

geocode(string, exactly_one=True)
geocode_url(url, exactly_one=True)
parse_xml(page, exactly_one=True)

Parse a location name, latitude, and longitude from an XML response.

class d_rats.geopy.geocoders.GeocoderDotUS(username=None, password=None, format_string='%s', protocol='xmlrpc')

Bases: d_rats.geopy.geocoders.WebGeocoder

Geocoder using the United States-only geocoder.us API at http://geocoder.us. This geocoder is free for non-commercial purposes, otherwise you must register and pay per call. This class supports both free and commercial API usage.

geocode(string, exactly_one=True)
geocode_rest(string, exactly_one=True)
geocode_xmlrpc(string, exactly_one=True)
parse_rdf(page, exactly_one=True)

Parse a location name, latitude, and longitude from an RDF response.

url
class d_rats.geopy.geocoders.VirtualEarth(domain='local.live.com', format_string='%s')

Bases: d_rats.geopy.geocoders.WebGeocoder

Geocoder using Microsoft’s Windows Live Local web service, powered by Virtual Earth.

WARNING: This does not use a published API and can easily break if Microsoft changes their JavaScript.

AMBIGUOUS_LOCATION = <_sre.SRE_Pattern object at 0x034B6B30>
AMBIGUOUS_SPLIT = <_sre.SRE_Pattern object at 0x03912220>
SINGLE_LOCATION = <_sre.SRE_Pattern object at 0x032E3CF0>
STRING_QUOTE = <_sre.SRE_Pattern object at 0x032983C8>
geocode(string, exactly_one=True)
geocode_url(url, exactly_one=True)
parse_javascript(page, exactly_one=True)
url
class d_rats.geopy.geocoders.GeoNames(format_string='%s', output_format='xml')

Bases: d_rats.geopy.geocoders.WebGeocoder

geocode(string, exactly_one=True)
geocode_url(url, exactly_one=True)
parse_json(page, exactly_one)
parse_xml(page, exactly_one)
url

d_rats.geopy.util module

d_rats.geopy.util.parse_geo(string, regex=None)

Return a 2-tuple of Decimals parsed from string. The default regular expression can parse most common coordinate formats, including:

41.5;-81.0 41.5,-81.0 41.5 -81.0 41.5 N -81.0 W -41.5 S;81.0 E 23 26m 22s N 23 27m 30s E 23 26’ 22” N 23 27’ 30” E

...and more whitespace and separator variations. UTF-8 characters such as the degree symbol, prime (arcminutes), and double prime (arcseconds) are also supported. Coordinates given from South and West will be converted appropriately (by switching their signs).

A custom expression can be given using the regex argument. It can be a string or compiled regular expression, and must contain groups named ‘latitude_degrees’ and ‘longitude_degrees’. It can optionally contain groups named ‘latitude_minutes’, ‘latitude_seconds’, ‘longitude_minutes’, ‘longitude_seconds’ for increased precision. Optional single-character groups named ‘north_south’ and ‘east_west’ may be included to indicate direction, it is assumed that the coordinates reference North and East otherwise.

Module contents

Table Of Contents

This Page