Files
2026-09-02 14:19:09 +02:00

34 lines
1.0 KiB
Python

# Basic use and new schema method
import gdelt
import geopandas as gpd
def main():
gd = gdelt.gdelt()
# NOTE: output='gpd' is broken in gdelt 0.1.14 with current numpy/pandas
# (its parallel geometry builder feeds numpy arrays into DataFrame.apply,
# and it still uses the removed crs={'init': ...} form). We pull plain
# pandas and build the GeoDataFrame ourselves instead.
events = gd.Search(['2017 May 23'], table='events', output='pandas',
normcols=True, coverage=False)
events = events[events['actiongeolat'].notnull()
& events['actiongeolong'].notnull()]
events = gpd.GeoDataFrame(
events,
geometry=gpd.points_from_xy(events['actiongeolong'],
events['actiongeolat']),
crs='EPSG:4326',
)
print(events.shape)
print(events[['globaleventid', 'actiongeofullname', 'geometry']].head())
# new schema method
print(gd.schema('events'))
if __name__ == '__main__':
main()