After running all the below code:

Go to https://www.nabatmonitoring.org/ and click partner portal.Login to your account and proceed to the project that matches project_id (projects tab). Click on your project and navigate there. Once inside the project page, click the 'Bulk Upload Status' tab and view the data that this script just processed. If there are errors, make changes and try again with either this R code or the Website.

Note:

All of uploads through nabatr use the 'Full Metadata' option. To view more information, go to your project, select the 'Upload Survey Data' button at the top, and click any of the types to popup a box with more information. (Capture records are currently unavailable through nabatr. Go to Website to upload.)

Get a token for NABat Database

library(nabatr)
# Enter your NABat username here
username = 'NABat_Username'
token = get_nabat_gql_token(username)
token

# Note: if you leave run token = get_nabat_gql_token(),
#   it will prompt you for a username and then a password

Get Project dataframe which contains all of your NABat projects in the NABat Database

# Refresh token
token = get_refresh_token(token)
# Get your projects lookup table
project_df = get_projects(token)
# Display your projects lookup table
project_df

Select a project id from project_df above

### Change this value to the project ID you want to upload data to
project_id = 000

Get User ID

user_id = get_user_id_by_email(username, token)

Set survey_type, file_name, and file_path

# Type of data to be uploading ex:
## 'bulk_sae' = Stationary Acoustic data
## 'bulk_mae' = Mobile Acoustic Data
## 'bulk_hib' = Hibernacula Colony Count Data
## 'bulk_mat' = Maternity Colony Count Data
## 'bulk_ee' = Emergence Count Data
survey_type = 'bulk_sae'

# Location of file to be uploaded and processed into NABat Database/Website
## Don't end in "/"
## valid Ex: (mac) /users/johndoe/downloads/example.csv or (windows) C:/path/to/example.csv
## * Windows users * - Be sure to switch backward slashes '\' to forward slashes '/'
file_path = '/users/johndoe/downloads/example.csv' 

Upload to NABat

# Refresh token
token = get_refresh_token(token)
# Uploads file_path csv into the NABat database
## Double check project_id, survey_type, and project_id!
upload_data(token = token, 
  user_id = user_id, 
  file_path = file_path,
  project_id = project_id,
  survey_type = survey_type)


usgs/nabatr documentation built on Jan. 28, 2024, 7:10 a.m.