Skip to content
master
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 

GeoGrapher

Photo by Andrew Neel on Unsplash

To run the script, cd into the appropriate directory and run python GeoGrapher.py into the command line.

The script goes to the United States Geological Survey (USGS) website to retrieve the geo.json file of Significant Earthquakes in the past 30 days, parsing it using split() function to extract:

Colons can be used to align columns.

Extracted Data Notes To .csv
title Title
country Country
longitude Latitude
latitude Longitude
magnitude Magnitude
alert Alert
tsunami Tsunami
range Range
direction (from nearest coast Direction
MMI
Significance
Mag_max Country affected
(coming soon) City affected

The script will print the logs to the command line, just as a check for the content. Using the Shapely module and the countries.geo.json, a point is constructed from the extracted earthquake coordinates.

Comparing each earthquake, a for loop runs over each point and checks whether the point intersects or the country polygon. If this is true, then it prints the country that the earthquake has affected.

Finally, the writerow() function prints this information in a tabular format to Earthquakes.csv. Note that additional running of this script overwrites previous files with the same name. To change this instead append to existing file, change the following line:

w = csv.writer(open("Earthquakes.csv","w"))

to

w = csv.writer(open("Earthquakes.csv","a"))

"a" means append (add the data to the end of this file if it already exists), while "w" only writes.

About

A short script that maps geographic attributes (earthquake affected, war, etc) to multiple countries/cities.

Resources

Releases

No releases published

Packages

No packages published

Languages