Overview¶
Creating the SWOT database locally was very similar to that of the HUC database creation earlier. Similarly, I used Pandas to efficiently work with the data, and GeoPandas for some nice geospatial functions. In this section, I’ll go over how to use the SWORD database provided by Elizabeth Altenau. I’ll also show how to run the code to generate our SWOT database from this and go more into the code I’ve written in the Code Explained section.
Important: I found this resource useful in learning about the format of SWOT Feature IDs and the SWOT mission as a whole.
Creation Procedure¶
Navigate to the /SWOT/ directory of the cloned repository using:
cd feature-translation-service/SWOT/
Here you will see a create_swot_dataset.py file. Running this code requires that you have two input parameters: the input directory (containing the SWORD database) and the output directory where the final database (.csv file) will be written to.
-i [input directory]
-o [output directory]
Important: I was given a ZIP file named NA_MergedDB_v02 that contained a single shapefile (and its necessary counterparts) that defined the entire SWORD database. In order to not make any assumptions about the structure of future SWOT data, I simply extracted this ZIP file and placed the resulting folder in a directory I created called SWOT_Data/. Thus, the directory structure looks as follows:
feature-translation-service/ |—— SWOT/ |———— SWOT_Data/ |—————— NA_MergedDB_v02/ |———————— NA_MergedDB_v02.shp |———————— NA_MergedDB_v02.dbf |———————— NA_MergedDB_v02.shx |———————— NA_MergedDB_v02.prj |———————— NA_MergedDB_v02.nc
This way, any future SWOT shapefile information can be directly put into the SWOT_Data/ folder similarly to that of the NA_MergedDB_v02 data.
Once you’ve extracted the SWORD database (or other databases) as shown above, you can run the code below.
Run the Code¶
As an example, you might run:
python create_SWOT_dataset.py -i "SWOT_Data/" -o "Database/"
python create_SWOT_dataset.py -i "SWOT_Data/" -o "path/to/Desktop/folder/"
Running this code will generate a SWOT database for all SWOT data included in the input directory. You will see a .csv named “SWOT_data.csv” appear in the output directory you specified through the command line when the program has finished.
This .csv file can then be directly uploaded to AWS through the many techniques. I will go into all AWS-related tasks in the Migrating to AWS section later.