init
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
# 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()
|
||||
Reference in New Issue
Block a user