Sunday, February 10, 2019

Updated iNaturalist Upload Scripts

After a few rainy days I managed to come up with a python script using pyinaturalist which is at least as efficient as the existing upload method. For people uploading a large number of photos of the same species it is much more efficient.

The basic workflow is to put all the photos in a folder with the common name or scientific name and/or taxon number as the name of the folder.


You can put dozens of photos in any of these folders, so uploading fifty observations of the same species only requires running the script once. All the photos in every folder in the master folder will be uploaded as an individual observation.

What about uploading multiple photos to the same observation? This isn't much harder, add the photos to a sub-folder in the species folder. The script doesn't care what name, so I usually just leave these as "new folder." All the photos in this subfolder will be uploaded to an individual observation.

When you run the script, it gives you a few inputs to fill out:
The more annoying of these are "APP ID" and "APP Secret." You have to create an app for iNaturalist to upload through scripts. Fortunately this just takes a few seconds. The folder it wants is the main folder which contains all the species folders to be uploaded. Even if you are uploading just one species the folder with the photos will need to be in a master folder containing nothing but species folders to be uploaded.

Chances are you will want to go in the code and fill out default values for most of the entries so you will not have to fill them out every time you run the script. It is commented where to add them to the import_gui.py file.

Once the script is done, it moves all the files out of this folder, and puts them next to the main folder in a folder called "Uploaded." This should keep you from re-uploading everything if you lose connection mid-upload. Just run the script again, all the uploaded photos will now be gone. 

Since it got rather long, I uploaded it to Github as iNaturalist-Uploads. There are three files which all must be in the same folder. upload_folders.py is the file which is run as a python script. The other two (import_gui.py and import_functions.py) have functions which I preferred to put in a different folder to keep it less messy. All three files need to be saved to the same folder to run.

This probably doesn't make sense for most users as it is way less intuitive than the site submission tool, but if you are experienced with python or have a ton of photos of a limited number of species to upload this starts to make sense.

No comments: