Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
29 lines (23 sloc) 742 Bytes
"""Example using the Cow API to generate a shapefile."""
from io import BytesIO
import json
import requests
import geopandas as gpd
def main():
"""Our main method."""
url = (
"https://mesonet.agron.iastate.edu/api/1/cow.json?wfo=DMX&"
"begints=2019-01-01T00:00Z&endts=2019-08-06T00:00Z&"
"phenomena=TO&lsrtype=TO&"
)
reg = requests.get(url)
jsobj = reg.json()
for name in ['events', 'stormreports']:
# This feels hacky, but I did not find another means yet to do it
buf = BytesIO()
buf.write(json.dumps(jsobj[name]).encode("ASCII"))
buf.seek(0)
events = gpd.read_file(buf)
events.to_file(name + ".shp")
if __name__ == '__main__':
main()
You can’t perform that action at this time.