This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import geocoder | |
g = geocoder.google('Ottawa, Ontario') | |
g.latlng | |
[45.4215296, -75.6971930999] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
from datetime import timedelta | |
from flask import make_response, request, current_app, Flask, jsonify | |
from functools import update_wrapper | |
def crossdomain(origin=None, methods=None, headers=None, | |
max_age=21600, attach_to_all=True, | |
automatic_options=True): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import geo | |
toporama = geo.toporama('Ottawa') | |
toporama.download() | |
# Default toporama would be 50K | |
# geo.toporama(<location>, scale='250K') | |
# Default location for download would be root of the python script | |
# toporama.download('download here/') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> import pydie | |
>>> pydie.roll('3d1') | |
3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
# Input | |
string = '3d6+2' | |
# Regex Pattern | |
pattern = re.compile(r'(?P<multiplier>\d+)d(?P<die>\d+)m?(?P<math>\D)?(?P<modifier>\d+)?') | |
match = pattern.match(string) | |
# Attributes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import geocoder | |
places = geocoder.places('Kabul, Afghanistan', keyword='Embassy') | |
for place in places: | |
print place.json | |
print place.latlng |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import coordinate | |
# MGRS to LatLng | |
c = coordinate.get('41R QQ 123 123') | |
print c.latlng | |
# LatLng to MGRS | |
c = coordinate.get('41.123, -78.123') | |
print c.mgrs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import csv | |
with open(join('us-data', 'codes.txt')) as f: | |
rows = list(csv.DictReader(f, dialect='excel-tab')) | |
codes = dict([(row['Postal Code'].lower(), row['State']) for row in rows]) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<osm-script output="json" timeout="25"> | |
<!-- gather results --> | |
<union> | |
<query type="way"> | |
<has-kv k="addr:housenumber"/> | |
<user name="DenisCarriere"/> | |
<has-kv k="source" v="survey"/> | |
</query> | |
</union> | |
<!-- print results --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# To Install: | |
# $ pip install geocoder | |
>>> import geocoder | |
>>> g = geocoder.opencage("New York City", key="YOUR API KEY") | |
>>> g.latlng | |
[40.7305991, -73.9865812] | |
>>> g.json | |
{"status": "OK", "locality": "New York City", ...} |
OlderNewer