{"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":"markdown","source":"# BirdClef-2023 GeoData","metadata":{"papermill":{"duration":0.004571,"end_time":"2023-03-16T10:11:47.202301","exception":false,"start_time":"2023-03-16T10:11:47.19773","status":"completed"},"tags":[]}},{"cell_type":"code","source":"import geopandas as gpd\nfrom geopandas import GeoDataFrame\nfrom shapely.geometry import Point\nimport pandas as pd\nimport numpy as np\nimport matplotlib.pyplot as plt","metadata":{"_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","papermill":{"duration":0.733799,"end_time":"2023-03-16T10:11:47.939946","exception":false,"start_time":"2023-03-16T10:11:47.206147","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-04-06T12:18:01.253898Z","iopub.execute_input":"2023-04-06T12:18:01.254392Z","iopub.status.idle":"2023-04-06T12:18:01.959981Z","shell.execute_reply.started":"2023-04-06T12:18:01.254353Z","shell.execute_reply":"2023-04-06T12:18:01.958632Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_df = pd.read_csv('/kaggle/input/birdclef-2023/train_metadata.csv')\ndisplay(train_df)","metadata":{"papermill":{"duration":0.158635,"end_time":"2023-03-16T10:11:48.102075","exception":false,"start_time":"2023-03-16T10:11:47.94344","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-04-06T12:18:01.962772Z","iopub.execute_input":"2023-04-06T12:18:01.963630Z","iopub.status.idle":"2023-04-06T12:18:02.175115Z","shell.execute_reply.started":"2023-04-06T12:18:01.963588Z","shell.execute_reply":"2023-04-06T12:18:02.173785Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_df=train_df[['primary_label','latitude','longitude','common_name']]","metadata":{"execution":{"iopub.status.busy":"2023-04-06T12:18:02.176823Z","iopub.execute_input":"2023-04-06T12:18:02.177236Z","iopub.status.idle":"2023-04-06T12:18:02.188011Z","shell.execute_reply.started":"2023-04-06T12:18:02.177195Z","shell.execute_reply":"2023-04-06T12:18:02.186452Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"unique_df = train_df[['primary_label', 'common_name']].drop_duplicates()\nnames = unique_df['primary_label'].tolist()\ncnames = unique_df['common_name'].tolist()\nprint(len(names))","metadata":{"execution":{"iopub.status.busy":"2023-04-06T12:18:02.190009Z","iopub.execute_input":"2023-04-06T12:18:02.190446Z","iopub.status.idle":"2023-04-06T12:18:02.214021Z","shell.execute_reply.started":"2023-04-06T12:18:02.190396Z","shell.execute_reply":"2023-04-06T12:18:02.212944Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"names_df=names.copy()\nfor i,name in enumerate(names):\n    names_df[i]=train_df[train_df['primary_label']==name].reset_index(drop=True)","metadata":{"execution":{"iopub.status.busy":"2023-04-06T12:18:02.216575Z","iopub.execute_input":"2023-04-06T12:18:02.217328Z","iopub.status.idle":"2023-04-06T12:18:02.702365Z","shell.execute_reply.started":"2023-04-06T12:18:02.217290Z","shell.execute_reply":"2023-04-06T12:18:02.700647Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"geometry = [Point(xy) for xy in zip(train_df['longitude'], train_df['latitude'])]\ngdf = GeoDataFrame(train_df, geometry = geometry)\nworld = gpd.read_file(gpd.datasets.get_path('naturalearth_lowres'))\ngdf.plot(ax=world.plot(figsize=(12,12)), color='orange', markersize=10)\nplt.title('All')\nplt.show()","metadata":{"papermill":{"duration":3.223819,"end_time":"2023-03-16T10:11:52.279741","exception":false,"start_time":"2023-03-16T10:11:49.055922","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-04-06T12:18:02.706512Z","iopub.execute_input":"2023-04-06T12:18:02.707547Z","iopub.status.idle":"2023-04-06T12:18:06.913242Z","shell.execute_reply.started":"2023-04-06T12:18:02.707497Z","shell.execute_reply":"2023-04-06T12:18:06.911752Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"for i in range(len(names)):\n    datai=names_df[i]\n    name=names[i]\n    cname=cnames[i]\n    geometry = [Point(xy) for xy in zip(datai['longitude'], datai['latitude'])]\n    gdf = GeoDataFrame(datai, geometry = geometry)\n    world = gpd.read_file(gpd.datasets.get_path('naturalearth_lowres'))\n    gdf.plot(ax=world.plot(figsize=(12,12)), color='orange', markersize=15)\n    plt.title(name+' : '+cname)\n    plt.show()","metadata":{"papermill":{"duration":0.006013,"end_time":"2023-03-16T10:11:52.292832","exception":false,"start_time":"2023-03-16T10:11:52.286819","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-04-06T12:19:04.907938Z","iopub.execute_input":"2023-04-06T12:19:04.908554Z","iopub.status.idle":"2023-04-06T12:19:06.531001Z","shell.execute_reply.started":"2023-04-06T12:19:04.908504Z","shell.execute_reply":"2023-04-06T12:19:06.529381Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{"papermill":{"duration":0.005654,"end_time":"2023-03-16T10:11:52.304712","exception":false,"start_time":"2023-03-16T10:11:52.299058","status":"completed"},"tags":[]},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{"papermill":{"duration":0.005664,"end_time":"2023-03-16T10:11:52.316436","exception":false,"start_time":"2023-03-16T10:11:52.310772","status":"completed"},"tags":[]},"execution_count":null,"outputs":[]}]}