タクシー需要予測

未来のタクシー需要を先読みしよう!

賞金: 100,000 参加ユーザー数: 280 約1年前に終了

【EDA】座標系の緯度経度変換とfoliumによる可視化

座標系の可視化

・State Plane Coordinate Systemが初見だったので、緯度経度変換を試みましたのでメモです。
・とりあえずfolium上に点を打ちたかったのでメモです。

import pandas as pd
pd.options.display.max_columns = 100
pd.options.display.max_rows = 999
pd.options.display.float_format = '{:.6f}'.format

import warnings
warnings.filterwarnings('ignore')

from pyproj import Proj, transform
import folium
from google.colab import drive
drive.mount('/content/drive')
Drive already mounted at /content/drive; to attempt to forcibly remount, call drive.mount("/content/drive", force_remount=True).
path = "/content/drive/MyDrive/tmp/7_probspace/3_taxi/"
zone = pd.read_csv(path+'data/taxi_zones.csv')
# 緯度経度に変換
def sp2latlong(row):
  inProj = Proj(init='epsg:2263', preserve_units=True)
  outProj = Proj(init='epsg:4326')
  return transform(inProj, outProj, row["X"], row["Y"])

zone[["long","lat"]] = zone.apply(lambda x:sp2latlong(x), axis=1, result_type='expand')
zone
LocationID X Y long lat
0 0 990618.795051 203105.532318 -73.977023 40.724152
1 1 1005999.211465 216570.160207 -73.921491 40.761085
2 2 979781.103303 198536.380519 -74.016120 40.711612
3 3 993782.574750 231481.048878 -73.965569 40.802033
4 4 988005.473266 189064.601119 -73.986459 40.685615
5 5 985545.308060 192934.884487 -73.995329 40.696238
6 6 985409.939590 186473.826450 -73.995818 40.678504
7 7 997520.588883 232274.162568 -73.952065 40.804205
8 8 1000990.471500 238412.229126 -73.939516 40.821046
9 9 993784.366691 224349.916883 -73.965572 40.782460
10 10 984734.419691 199062.702717 -73.998253 40.713058
11 11 987059.930613 216980.297541 -73.989857 40.762237
12 12 985939.886284 218603.522675 -73.993899 40.766692
13 13 985103.511142 189424.994278 -73.996922 40.686605
14 14 988251.145129 192619.772936 -73.985571 40.695373
15 15 988025.704896 194936.823442 -73.986383 40.701732
16 16 984266.581407 211937.944079 -73.999940 40.748397
17 17 1001328.229336 232772.309614 -73.938310 40.805566
18 18 999491.706781 227336.882497 -73.944957 40.790650
19 19 988348.121326 204486.635308 -73.985214 40.727944
20 20 982084.066286 196731.733219 -74.007812 40.706660
21 21 981114.731618 195542.004470 -74.011308 40.703394
22 22 985142.963791 209806.230709 -73.996778 40.742546
23 23 991023.099286 190887.289491 -73.975577 40.690616
24 24 987356.960940 213802.382670 -73.988786 40.753514
25 25 988875.126508 207912.937312 -73.983310 40.737348
26 26 985738.766591 206141.008242 -73.994628 40.732486
27 27 984616.422735 204729.465979 -73.998678 40.728612
28 28 998816.051812 240775.021260 -73.947368 40.827535
29 29 982261.075534 203550.791285 -74.007176 40.725376
30 30 1015442.387384 215841.865002 -73.887406 40.759057
31 31 1045786.102387 173472.416535 -73.778264 40.642605
32 32 990590.519000 209010.276122 -73.977119 40.740359
33 33 1019479.471765 221607.471802 -73.872804 40.774867
34 34 996835.032220 218174.790003 -73.954568 40.765507
35 35 995409.701765 218659.383729 -73.959713 40.766839
36 36 989414.886084 221232.172168 -73.981352 40.773906
37 37 987581.075606 221911.050507 -73.987973 40.775770
38 38 984968.854761 201803.794503 -73.997407 40.720581
39 39 998464.788931 211283.664795 -73.948699 40.746590
40 40 1002636.940025 214178.874402 -73.933634 40.754529
41 41 986822.878438 201304.868259 -73.990718 40.719212
42 42 993163.012434 229962.809716 -73.967808 40.797866
43 43 996892.499732 237145.858731 -73.954325 40.817577
44 44 981926.019728 207147.398964 -74.008386 40.735248
45 45 990502.253134 215519.865935 -73.977432 40.758226
46 46 991966.940592 215006.459745 -73.972145 40.756816
47 47 990242.622713 217778.289482 -73.978367 40.764425
48 48 988148.815733 212087.794423 -73.985929 40.748808
49 49 994820.493140 234227.640382 -73.961815 40.809570
50 50 990638.973215 211668.106693 -73.976942 40.747654
51 51 1004521.785696 220336.309601 -73.926812 40.771425
52 52 990062.886973 184111.792889 -73.979045 40.672019
53 53 986340.471812 211966.866225 -73.992455 40.748476
54 54 1000792.132152 216799.116340 -73.940286 40.761724
55 55 983595.776972 197398.396504 -74.002360 40.708490
56 56 983868.950387 203012.498007 -74.001375 40.723899
57 57 1010097.755219 222807.414929 -73.906672 40.778193
58 58 990391.043675 205865.651703 -73.977842 40.731728
59 59 1003837.481998 207164.423377 -73.929321 40.735273
60 60 993898.329957 214924.499415 -73.965174 40.756589
61 61 988633.708586 216109.041064 -73.984176 40.759845
62 62 982389.517117 201116.796517 -74.006712 40.718696
63 63 989154.879219 199911.447906 -73.982307 40.715386
64 64 992214.287741 212221.562058 -73.971256 40.749172
65 65 986888.777072 208992.915596 -73.990478 40.740313
66 66 996166.327458 223633.864977 -73.956972 40.780491
67 67 993753.310704 219279.162682 -73.965691 40.768542
68 68 991777.637057 227739.890845 -73.972815 40.791766
69 69 990266.785345 224949.075601 -73.978273 40.784107
70 70 1000390.410604 245761.392287 -73.941667 40.841219
71 71 982999.734449 213409.888398 -74.004513 40.752437
72 72 983558.014551 206915.396729 -74.002497 40.734612
73 73 996132.623796 201170.111116 -73.957134 40.718834
74 74 995586.732453 198307.282684 -73.959108 40.710977
75 75 1010929.715155 211369.883417 -73.903713 40.746798
76 76 980668.187168 197575.689861 -74.012919 40.708976
77 77 999253.108568 222193.818758 -73.945830 40.776534
78 78 997763.158272 222907.634704 -73.951208 40.778496
map = folium.Map(location=[zone["lat"].mean(), zone["long"].mean()],  tiles='cartodbpositron',zoom_start=11)

for i, d in zone.iterrows():
  folium.Marker(location=[d["lat"], d["long"]]).add_to(map)

map
Make this Notebook Trusted to load map: File -> Trust Notebook

添付データ

  • Icon13
    datascience

    mini_forestさま

    foliumやprojのような便利なツールがあるとは知りませんでした。
    ありがとうございました。

    Aws4 request&x amz signedheaders=host&x amz signature=82b9fd5ec3c737bc1c1f49fa63e4cfe674b44f8582b88f88b89aa40dce64bdd7
    mini_forest

    とんでもないです!!
    せっかくの位置情報なので何か有用なことに使えないかなと思い調べてみた内容の共有でした!

    Favicon
    new user
    コメントするには 新規登録 もしくは ログイン が必要です。