Skip to content

Commit 3767476

Browse files
author
Michael Galarnyk
committed
Added a Geocodding section for my own education
1 parent feeb04d commit 3767476

File tree

2 files changed

+177
-0
lines changed

2 files changed

+177
-0
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"cells": [],
3+
"metadata": {},
4+
"nbformat": 4,
5+
"nbformat_minor": 1
6+
}

Geocoding/Geocoding.ipynb

Lines changed: 171 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"metadata": {},
6+
"source": [
7+
"# Reverse Geocoding State"
8+
]
9+
},
10+
{
11+
"cell_type": "markdown",
12+
"metadata": {},
13+
"source": [
14+
"This is answering a [stackoverflow question](https://stackoverflow.com/questions/25008191/find-out-if-lat-lon-coordinates-fall-inside-a-us-state)"
15+
]
16+
},
17+
{
18+
"cell_type": "code",
19+
"execution_count": 43,
20+
"metadata": {
21+
"collapsed": false
22+
},
23+
"outputs": [],
24+
"source": [
25+
"# You need to first install geocoder\n",
26+
"# !pip install geocoder"
27+
]
28+
},
29+
{
30+
"cell_type": "code",
31+
"execution_count": 39,
32+
"metadata": {
33+
"collapsed": false
34+
},
35+
"outputs": [],
36+
"source": [
37+
"import geocoder"
38+
]
39+
},
40+
{
41+
"cell_type": "code",
42+
"execution_count": 40,
43+
"metadata": {
44+
"collapsed": false
45+
},
46+
"outputs": [],
47+
"source": [
48+
"results = geocoder.google('32.781065, -96.797117', reverse = True)"
49+
]
50+
},
51+
{
52+
"cell_type": "code",
53+
"execution_count": 44,
54+
"metadata": {
55+
"collapsed": false
56+
},
57+
"outputs": [
58+
{
59+
"name": "stdout",
60+
"output_type": "stream",
61+
"text": [
62+
"Texas\n"
63+
]
64+
}
65+
],
66+
"source": [
67+
"print(results.current_result.state_long)"
68+
]
69+
},
70+
{
71+
"cell_type": "code",
72+
"execution_count": 50,
73+
"metadata": {
74+
"collapsed": false
75+
},
76+
"outputs": [
77+
{
78+
"data": {
79+
"text/plain": [
80+
"u'Dallas County'"
81+
]
82+
},
83+
"execution_count": 50,
84+
"metadata": {},
85+
"output_type": "execute_result"
86+
}
87+
],
88+
"source": [
89+
"results.current_result.county"
90+
]
91+
},
92+
{
93+
"cell_type": "markdown",
94+
"metadata": {},
95+
"source": [
96+
"# Reverse Geocoding County"
97+
]
98+
},
99+
{
100+
"cell_type": "markdown",
101+
"metadata": {},
102+
"source": [
103+
"https://stackoverflow.com/questions/44208780/find-the-county-for-a-city-state"
104+
]
105+
},
106+
{
107+
"cell_type": "code",
108+
"execution_count": 51,
109+
"metadata": {
110+
"collapsed": true
111+
},
112+
"outputs": [],
113+
"source": [
114+
"g = geocoder.google([45.15, -75.14], method='reverse')"
115+
]
116+
},
117+
{
118+
"cell_type": "code",
119+
"execution_count": 52,
120+
"metadata": {
121+
"collapsed": false
122+
},
123+
"outputs": [
124+
{
125+
"data": {
126+
"text/plain": [
127+
"u'Ontario'"
128+
]
129+
},
130+
"execution_count": 52,
131+
"metadata": {},
132+
"output_type": "execute_result"
133+
}
134+
],
135+
"source": [
136+
"g.current_result.state_long"
137+
]
138+
},
139+
{
140+
"cell_type": "code",
141+
"execution_count": null,
142+
"metadata": {
143+
"collapsed": true
144+
},
145+
"outputs": [],
146+
"source": []
147+
}
148+
],
149+
"metadata": {
150+
"anaconda-cloud": {},
151+
"kernelspec": {
152+
"display_name": "Python [conda root]",
153+
"language": "python",
154+
"name": "conda-root-py"
155+
},
156+
"language_info": {
157+
"codemirror_mode": {
158+
"name": "ipython",
159+
"version": 2
160+
},
161+
"file_extension": ".py",
162+
"mimetype": "text/x-python",
163+
"name": "python",
164+
"nbconvert_exporter": "python",
165+
"pygments_lexer": "ipython2",
166+
"version": "2.7.12"
167+
}
168+
},
169+
"nbformat": 4,
170+
"nbformat_minor": 1
171+
}

0 commit comments

Comments
 (0)