{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"pygments_lexer":"ipython3","nbconvert_exporter":"python","version":"3.6.4","file_extension":".py","codemirror_mode":{"name":"ipython","version":3},"name":"python","mimetype":"text/x-python"}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"import pandas as pd\nimport numpy as np\nfrom tqdm.notebook import tqdm\nimport matplotlib.pyplot as plt","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2022-10-24T20:05:42.991612Z","iopub.execute_input":"2022-10-24T20:05:42.992044Z","iopub.status.idle":"2022-10-24T20:05:42.997239Z","shell.execute_reply.started":"2022-10-24T20:05:42.992009Z","shell.execute_reply":"2022-10-24T20:05:42.996256Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"This notebook uses the pyproj library to project latitude and longitude.","metadata":{}},{"cell_type":"code","source":"import pyproj\n# example proj(longitude, latitude)\n# EPSG:2260,  New York East,   BOX[40.88,-75.87,45.02,-73.23]],\n# SARATOGA\nproj = pyproj.Proj(\"EPSG:2260\") \nprint(proj(-73.829, 40.669))\n\n# EPSG:2263,  New York Long Island,   BBOX[40.47,-74.26,41.3,-71.8]] \n# AQUEDUCT, BELMONT\nproj2 = pyproj.Proj(\"EPSG:2263\") \nprint(proj2(-73.829, 40.669))","metadata":{"execution":{"iopub.status.busy":"2022-10-24T20:05:44.555646Z","iopub.execute_input":"2022-10-24T20:05:44.556069Z","iopub.status.idle":"2022-10-24T20:05:44.612755Z","shell.execute_reply.started":"2022-10-24T20:05:44.556036Z","shell.execute_reply":"2022-10-24T20:05:44.611520Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df = pd.read_csv(\"../input/big-data-derby-2022/nyra_tracking_table.csv\")\ndf = df.sort_values(by=['track_id','race_date','race_number','program_number','trakus_index']).reset_index(drop=True)\ndf","metadata":{"execution":{"iopub.status.busy":"2022-10-24T20:05:46.972107Z","iopub.execute_input":"2022-10-24T20:05:46.973359Z","iopub.status.idle":"2022-10-24T20:05:59.813783Z","shell.execute_reply.started":"2022-10-24T20:05:46.973310Z","shell.execute_reply":"2022-10-24T20:05:59.812441Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# EPSG 2260, 2263","metadata":{}},{"cell_type":"code","source":"proj=pyproj.Proj(\"EPSG:2260\")\nproj2 = pyproj.Proj(\"EPSG:2263\") \n\ntrack_ids = df['track_id'].values\nlnglat_values = df[['longitude','latitude']].values\n\nxy_values = []\nfor track_id, lnglat in tqdm(zip(track_ids, lnglat_values), total=len(lnglat_values)):\n    if track_id == 'SAR':\n        x, y = proj(*lnglat)\n    elif (track_id == 'AQU') or (track_id == 'BEL'):\n        x, y = proj2(*lnglat)\n    xy_values.append([x,y])\n    \nxy_values = np.array(xy_values)\ndf[['x','y']] = xy_values","metadata":{"execution":{"iopub.status.busy":"2022-10-24T20:11:02.049989Z","iopub.execute_input":"2022-10-24T20:11:02.050618Z","iopub.status.idle":"2022-10-24T20:12:17.910205Z","shell.execute_reply.started":"2022-10-24T20:11:02.050563Z","shell.execute_reply":"2022-10-24T20:12:17.909178Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Plot","metadata":{}},{"cell_type":"code","source":"first_user_df = df.loc[:315]\n\nplt.subplots(figsize=(8,5))\nplt.subplot(1,2,1)\nplt.scatter(first_user_df['longitude'], first_user_df['latitude'])\nplt.title('lnglat plot')\nplt.axis('square')\nplt.subplot(1,2,2)\nplt.title('epsg2260/epsg2263 plot')\nplt.scatter(first_user_df['x'], first_user_df['y'])\nplt.axis('square')\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-10-24T20:12:32.435162Z","iopub.execute_input":"2022-10-24T20:12:32.435595Z","iopub.status.idle":"2022-10-24T20:12:32.806618Z","shell.execute_reply.started":"2022-10-24T20:12:32.435558Z","shell.execute_reply":"2022-10-24T20:12:32.805459Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}