Hurricane data has been written to florida.csv.
- Install node: https://nodejs.org/en/download. The latest LTS version should do.
- Install pnpm: https://pnpm.io/installation.
- Run
pnpm install
to install all packages. - Install sqlite3.
The user needs to supply the right environment variables to get the scripts to run properly.
- Run
DB=<desired_path_to_db> pnpm create_db
. - Run
DB=<desired_path_to_db> pnpm load_db
. - Run
OUTPUT_PATH=<desired_output_file> DB=<db path> pnpm write_hurricanes
.
The hurricane data should be in the file referenced by the output path.
The code loads the NOAA hurricane data into a SQLite3 database. I chose this approach because SQL databases make it easy to do things like rapidly query for all hurricane data that belongs to a particular cyclone number, or find the maximum wind speed for a particular cyclone number.
I then iterate through all hurricanes that have occurred since 1900 and for each row of hurricane lng/lat data, I compare the lng/lat to the Florida coastline to see if the lng/lat ever went inside it.
To accomplish this coastline check, I downloaded a GeoJSON file from https://github.com/danielcs88/fl_geo_json. I then used TurfJS, an open-source library maintained by MapBox, to detect whether the lng/lat was inside Florida.
- Preemptively check points to see if they are in a bounding box for Florida (i.e. a big box that encompasses Florida). If a point is outside of this bounding box, we can skip checking it against the fine-grained Florida GeoJSON and speed the process up.
- Add validation before entering data into the database.
- Support emitting data to other file formats.
- Add an automated test suite.
- Throw the whole thing out and rewrite in a language that supports multiple threads. The checks for each hurricane are expensive and the main bottleneck probably and Node/TS may not the best fit for this problem.
- Use this Florida GeoJSON from the Florida Fish and Wildlife Commission instead: https://geodata.myfwc.com/datasets/myfwc::florida-shoreline-1-to-40000-scale/explore?location=27.438860%2C-82.763397%2C10.39