I have a CSV of all earthquakes in my country for the last 10 years arranged by date and time. My goal is to plot each line chronologically one by one, so that I can compile these maps and produce a "time-lapse" of the earthquakes. The CSV is already sorted but I'll code the "sorting" function when I get there.
So if I have 10 earthquakes, the end products are 10 maps with each a single plot of where the earthquake happened.
from shapely.geometry import Point import geopandas as gpd from geopandas import GeoDataFrame import pandas as pd import os os.chdir(r'path') def plotPoint(): df = pd.read_csv('earthquakes.csv') geometry = [Point(xy) for xy in zip(df['Longitude'], df['Latitude'])] crs = "epsg:32651" gdf = GeoDataFrame(df, crs=crs, geometry=geometry) basemap = gpd.read_file('basemap.shp') for i in range(len(gdf)): # Counts how many rows there are then loops through each line of "gdf" if i == 0: # Skips over first line since it is the column header continue pt = gdf.plot(ax=basemap.plot(figsize=(10,6)), marker='o', color='red', markersize=15) print(pt[i]) # Executes "pt" one line at a time plotPoint()
When I run this, I get
File "C:\path\file.py", line 26, in plotPoint print(pt[i]) TypeError: 'AxesSubplot' object is not subscriptable
I'm still new to Python. Any leads?