Permalink
Browse files

feat: Add python code to enable easy incorporation

- Stores feature in two csv files in subfolder now
  • Loading branch information...
andirs committed Nov 1, 2017
1 parent 8f0040c commit 59e65765f7351591c70d75416a8aae9bdc37a501
@@ -33,7 +33,7 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 25,
"metadata": {
"collapsed": true
},
@@ -52,7 +52,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 26,
"metadata": {
"collapsed": false
},
@@ -63,7 +63,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 27,
"metadata": {
"collapsed": false
},
@@ -357,7 +357,7 @@
"4 0.0 "
]
},
"execution_count": 4,
"execution_count": 27,
"metadata": {},
"output_type": "execute_result"
}
@@ -368,7 +368,7 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 28,
"metadata": {
"collapsed": false
},
@@ -379,7 +379,7 @@
"195308"
]
},
"execution_count": 5,
"execution_count": 28,
"metadata": {},
"output_type": "execute_result"
}
@@ -615,7 +615,7 @@
},
{
"cell_type": "code",
"execution_count": 14,
"execution_count": 43,
"metadata": {
"collapsed": true
},
@@ -643,7 +643,7 @@
},
{
"cell_type": "code",
"execution_count": 15,
"execution_count": 44,
"metadata": {
"collapsed": false
},
@@ -652,14 +652,258 @@
"def get_lat_long(address_dict):\n",
" lat_lng_dict = {}\n",
" for address in address_dict:\n",
" lat_lng_dict[address] = (address_dict[address][0]['geometry']['location']['lat'], \n",
" address_dict[address][0]['geometry']['location']['lng'])\n",
" lat_lng_dict[address] = [(address_dict[address][0]['geometry']['location']['lat'], \n",
" address_dict[address][0]['geometry']['location']['lng'])]\n",
" return lat_lng_dict"
]
},
{
"cell_type": "code",
"execution_count": 16,
"execution_count": 45,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"{'100 Hoffman Avenue, San Francisco': [(37.7531106, -122.4410957)],\n",
" '1000 Ocean Avenue, San Francisco': [(37.7232908, -122.4529247)],\n",
" '1067 POST, San Francisco': [(37.7866445, -122.4193329)],\n",
" '109 Oak Street, San Francisco': [(37.7749469, -122.4212156)],\n",
" '1091 Portola Drive, San Francisco': [(37.7400312, -122.4586575)],\n",
" '1145 Stanyan Street, San Francisco': [(37.7634628, -122.4526316)],\n",
" '1290 16th Avenue , San Francisco': [(37.7639903, -122.4736446)],\n",
" '1295 Shafter Avenue, San Francisco': [(37.7275225, -122.385028)],\n",
" '1298 Girard Street, San Francisco': [(37.7166417, -122.4004505)],\n",
" '1301 TURK, San Francisco': [(37.7804435, -122.430725)],\n",
" '1325 Leavenworth Street , San Francisco': [(37.7933971, -122.4165178)],\n",
" '1340 POWELL, San Francisco': [(37.7970513, -122.4099507)],\n",
" '1348 45th Avenue, San Francisco': [(37.7614112, -122.5046487)],\n",
" '135 SANCHEZ, San Francisco': [(37.767088, -122.4307689)],\n",
" '1415 Evans Avenue, San Francisco': [(37.740742, -122.3853284)],\n",
" '1443 GROVE, San Francisco': [(37.7754351, -122.4402719)],\n",
" '1814 Stockton Street, San Francisco': [(37.8025537, -122.409369)],\n",
" '1935 32nd Avenue, San Francisco': [(37.7509061, -122.4905279)],\n",
" '194 Park Street, San Francisco': [(37.7364417, -122.4212155)],\n",
" '2150 California Street, San Francisco': [(37.7896976, -122.4299245)],\n",
" '2155 18th Avenue, San Francisco': [(37.7476471, -122.4754049)],\n",
" '218 Lincoln Blvd, San Francisco': [(37.80156660000001, -122.455466)],\n",
" '2245 JERROLD, San Francisco': [(37.7452434, -122.4012488)],\n",
" '2251 Greenwich Street, San Francisco': [(37.7986661, -122.4367471)],\n",
" '2300 FOLSOM, San Francisco': [(37.7602611, -122.4151762)],\n",
" '2430 San Bruno Avenue, San Francisco': [(37.7315794, -122.4055626)],\n",
" '285 Olympia Way, San Francisco': [(37.7511703, -122.4562239)],\n",
" '299 Vermont Street, San Francisco': [(37.7661645, -122.4043209)],\n",
" '3305 3rd Street, San Francisco': [(37.7479108, -122.3871002)],\n",
" '36 BLUXOME, San Francisco': [(37.7772827, -122.3967853)],\n",
" '380 The Embarcadero, San Francisco': [(37.79652129999999, -122.395473)],\n",
" '3880 26th Street, San Francisco': [(37.7486317, -122.4265007)],\n",
" '390 Buckingham Way, San Francisco': [(37.7278234, -122.478942)],\n",
" '441 12th Avenue, San Francisco': [(37.7798718, -122.4709543)],\n",
" '449 MISSION ROCK, San Francisco': [(37.7727739, -122.38923)],\n",
" '499 41st Avenue, San Francisco': [(37.7794499, -122.5026855)],\n",
" '530 Sansome Street, San Francisco': [(37.7955293, -122.4013894)],\n",
" '551 26th Avenue, San Francisco': [(37.779036, -122.486066)],\n",
" '655 PRESIDIO, San Francisco': [(37.7856729, -122.4468446)],\n",
" '720 Moscow Street, San Francisco': [(37.7163609, -122.431631)],\n",
" '798 Wisconsin Street, San Francisco': [(37.7573061, -122.3989451)],\n",
" '8 Capital Street, San Francisco': [(37.7108622, -122.4585864)],\n",
" '80 Digby Street, San Francisco': [(37.7402791, -122.4333702)],\n",
" '800 Avenue I, San Francisco': [(36.1444838, -115.1438187)],\n",
" '935 FOLSOM, San Francisco': [(37.7794237, -122.4041048)]}"
]
},
"execution_count": 45,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"get_lat_long(google_address_dict) # additional step for google results to get latitude and longitude values"
]
},
{
"cell_type": "code",
"execution_count": 46,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"# additional step for google results to get latitude and longitude values\n",
"google_address_dict = get_lat_long(google_address_dict)"
]
},
{
"cell_type": "code",
"execution_count": 51,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"{'100 Hoffman Avenue, San Francisco': [(37.7531106, -122.4410957)],\n",
" '1000 Ocean Avenue, San Francisco': [(37.7232908, -122.4529247)],\n",
" '1067 POST, San Francisco': [(37.7866445, -122.4193329)],\n",
" '109 Oak Street, San Francisco': [(37.7749469, -122.4212156)],\n",
" '1091 Portola Drive, San Francisco': [(37.7400312, -122.4586575)],\n",
" '1145 Stanyan Street, San Francisco': [(37.7634628, -122.4526316)],\n",
" '1290 16th Avenue , San Francisco': [(37.7639903, -122.4736446)],\n",
" '1295 Shafter Avenue, San Francisco': [(37.7275225, -122.385028)],\n",
" '1298 Girard Street, San Francisco': [(37.7166417, -122.4004505)],\n",
" '1301 TURK, San Francisco': [(37.7804435, -122.430725)],\n",
" '1325 Leavenworth Street , San Francisco': [(37.7933971, -122.4165178)],\n",
" '1340 POWELL, San Francisco': [(37.7970513, -122.4099507)],\n",
" '1348 45th Avenue, San Francisco': [(37.7614112, -122.5046487)],\n",
" '135 SANCHEZ, San Francisco': [(37.767088, -122.4307689)],\n",
" '1415 Evans Avenue, San Francisco': [(37.740742, -122.3853284)],\n",
" '1443 GROVE, San Francisco': [(37.7754351, -122.4402719)],\n",
" '1814 Stockton Street, San Francisco': [(37.8025537, -122.409369)],\n",
" '1935 32nd Avenue, San Francisco': [(37.7509061, -122.4905279)],\n",
" '194 Park Street, San Francisco': [(37.7364417, -122.4212155)],\n",
" '2150 California Street, San Francisco': [(37.7896976, -122.4299245)],\n",
" '2155 18th Avenue, San Francisco': [(37.7476471, -122.4754049)],\n",
" '218 Lincoln Blvd, San Francisco': [(37.80156660000001, -122.455466)],\n",
" '2245 JERROLD, San Francisco': [(37.7452434, -122.4012488)],\n",
" '2251 Greenwich Street, San Francisco': [(37.7986661, -122.4367471)],\n",
" '2300 FOLSOM, San Francisco': [(37.7602611, -122.4151762)],\n",
" '2430 San Bruno Avenue, San Francisco': [(37.7315794, -122.4055626)],\n",
" '285 Olympia Way, San Francisco': [(37.7511703, -122.4562239)],\n",
" '299 Vermont Street, San Francisco': [(37.7661645, -122.4043209)],\n",
" '3305 3rd Street, San Francisco': [(37.7479108, -122.3871002)],\n",
" '36 BLUXOME, San Francisco': [(37.7772827, -122.3967853)],\n",
" '380 The Embarcadero, San Francisco': [(37.79652129999999, -122.395473)],\n",
" '3880 26th Street, San Francisco': [(37.7486317, -122.4265007)],\n",
" '390 Buckingham Way, San Francisco': [(37.7278234, -122.478942)],\n",
" '441 12th Avenue, San Francisco': [(37.7798718, -122.4709543)],\n",
" '449 MISSION ROCK, San Francisco': [(37.7727739, -122.38923)],\n",
" '499 41st Avenue, San Francisco': [(37.7794499, -122.5026855)],\n",
" '530 Sansome Street, San Francisco': [(37.7955293, -122.4013894)],\n",
" '551 26th Avenue, San Francisco': [(37.779036, -122.486066)],\n",
" '655 PRESIDIO, San Francisco': [(37.7856729, -122.4468446)],\n",
" '720 Moscow Street, San Francisco': [(37.7163609, -122.431631)],\n",
" '798 Wisconsin Street, San Francisco': [(37.7573061, -122.3989451)],\n",
" '8 Capital Street, San Francisco': [(37.7108622, -122.4585864)],\n",
" '80 Digby Street, San Francisco': [(37.7402791, -122.4333702)],\n",
" '800 Avenue I, San Francisco': [(36.1444838, -115.1438187)],\n",
" '935 FOLSOM, San Francisco': [(37.7794237, -122.4041048)]}"
]
},
"execution_count": 51,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"google_address_dict"
]
},
{
"cell_type": "code",
"execution_count": 61,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"fire_station_table = pd.DataFrame.from_dict(google_address_dict, orient='index')\n",
"fire_station_table.to_csv('fire_stations.csv', index=True)"
]
},
{
"cell_type": "code",
"execution_count": 68,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"tt = pd.DataFrame.to_dict(pd.read_csv('fire_stations.csv', index_col=0))"
]
},
{
"cell_type": "code",
"execution_count": 72,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"{'100 Hoffman Avenue, San Francisco': '(37.7531106, -122.4410957)',\n",
" '1000 Ocean Avenue, San Francisco': '(37.7232908, -122.4529247)',\n",
" '1067 POST, San Francisco': '(37.7866445, -122.4193329)',\n",
" '109 Oak Street, San Francisco': '(37.7749469, -122.4212156)',\n",
" '1091 Portola Drive, San Francisco': '(37.7400312, -122.4586575)',\n",
" '1145 Stanyan Street, San Francisco': '(37.7634628, -122.4526316)',\n",
" '1290 16th Avenue , San Francisco': '(37.7639903, -122.4736446)',\n",
" '1295 Shafter Avenue, San Francisco': '(37.7275225, -122.385028)',\n",
" '1298 Girard Street, San Francisco': '(37.7166417, -122.4004505)',\n",
" '1301 TURK, San Francisco': '(37.7804435, -122.430725)',\n",
" '1325 Leavenworth Street , San Francisco': '(37.7933971, -122.4165178)',\n",
" '1340 POWELL, San Francisco': '(37.7970513, -122.4099507)',\n",
" '1348 45th Avenue, San Francisco': '(37.7614112, -122.5046487)',\n",
" '135 SANCHEZ, San Francisco': '(37.767088, -122.4307689)',\n",
" '1415 Evans Avenue, San Francisco': '(37.740742, -122.3853284)',\n",
" '1443 GROVE, San Francisco': '(37.7754351, -122.4402719)',\n",
" '1814 Stockton Street, San Francisco': '(37.8025537, -122.409369)',\n",
" '1935 32nd Avenue, San Francisco': '(37.7509061, -122.4905279)',\n",
" '194 Park Street, San Francisco': '(37.7364417, -122.4212155)',\n",
" '2150 California Street, San Francisco': '(37.7896976, -122.4299245)',\n",
" '2155 18th Avenue, San Francisco': '(37.7476471, -122.4754049)',\n",
" '218 Lincoln Blvd, San Francisco': '(37.80156660000001, -122.455466)',\n",
" '2245 JERROLD, San Francisco': '(37.7452434, -122.4012488)',\n",
" '2251 Greenwich Street, San Francisco': '(37.7986661, -122.4367471)',\n",
" '2300 FOLSOM, San Francisco': '(37.7602611, -122.4151762)',\n",
" '2430 San Bruno Avenue, San Francisco': '(37.7315794, -122.4055626)',\n",
" '285 Olympia Way, San Francisco': '(37.7511703, -122.4562239)',\n",
" '299 Vermont Street, San Francisco': '(37.7661645, -122.4043209)',\n",
" '3305 3rd Street, San Francisco': '(37.7479108, -122.3871002)',\n",
" '36 BLUXOME, San Francisco': '(37.7772827, -122.3967853)',\n",
" '380 The Embarcadero, San Francisco': '(37.79652129999999, -122.395473)',\n",
" '3880 26th Street, San Francisco': '(37.7486317, -122.4265007)',\n",
" '390 Buckingham Way, San Francisco': '(37.7278234, -122.478942)',\n",
" '441 12th Avenue, San Francisco': '(37.7798718, -122.4709543)',\n",
" '449 MISSION ROCK, San Francisco': '(37.7727739, -122.38923)',\n",
" '499 41st Avenue, San Francisco': '(37.7794499, -122.5026855)',\n",
" '530 Sansome Street, San Francisco': '(37.7955293, -122.4013894)',\n",
" '551 26th Avenue, San Francisco': '(37.779036, -122.486066)',\n",
" '655 PRESIDIO, San Francisco': '(37.7856729, -122.4468446)',\n",
" '720 Moscow Street, San Francisco': '(37.7163609, -122.431631)',\n",
" '798 Wisconsin Street, San Francisco': '(37.7573061, -122.3989451)',\n",
" '8 Capital Street, San Francisco': '(37.7108622, -122.4585864)',\n",
" '80 Digby Street, San Francisco': '(37.7402791, -122.4333702)',\n",
" '800 Avenue I, San Francisco': '(36.1444838, -115.1438187)',\n",
" '935 FOLSOM, San Francisco': '(37.7794237, -122.4041048)'}"
]
},
"execution_count": 72,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"tt['0']"
]
},
{
"cell_type": "code",
"execution_count": 53,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"test = pd.DataFrame.to_dict(fire_station_table)"
]
},
{
"cell_type": "code",
"execution_count": 54,
"metadata": {
"collapsed": false
},
@@ -714,25 +958,13 @@
" '935 FOLSOM, San Francisco': (37.7794237, -122.4041048)}"
]
},
"execution_count": 16,
"execution_count": 54,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"get_lat_long(google_address_dict) # additional step for google results to get latitude and longitude values"
]
},
{
"cell_type": "code",
"execution_count": 17,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"# additional step for google results to get latitude and longitude values\n",
"google_address_dict = get_lat_long(google_address_dict)"
"test[0]"
]
},
{
@@ -843,7 +1075,7 @@
"execution_count": 22,
"metadata": {
"collapsed": false,
"scrolled": true
"scrolled": false
},
"outputs": [
{
@@ -2072,15 +2304,6 @@
"source": [
"address"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
}
],
"metadata": {
Oops, something went wrong.

0 comments on commit 59e6576

Please sign in to comment.