Answers.Body: <p>PAMGuard is a bit fussy about the format of it's database tables, so I'd recommend getting PAMGuard to create a blank database table for you (add a GPS module and this will happen automatically). Then you'll need to either import data into the table, or write some code to insert data into that table. This could be done in any programming language that can connect to a CSV file and to a database - which is just about any programming language you can imagine, e.g. Matlab, R, Python, C, etc.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-07-03T18:03:58.460Z
Answers.LastActivityDate: 2022-07-03T18:03:58.460Z
Answers.UserDisplayName: Doug Gillespie
Answers.Body: <p>With R you can use the <code>addPgGps</code> function from the <code>PAMmisc</code> package. The only requirement is that your CSV file has columns named <code>UTC</code>, <code>Latitude</code>, and <code>Longitude</code>. If your times are not in UTC timezone then you can either convert them to UTC yourself, or provide the timezone your times are in with the <code>tz</code> argument (see <code>OlsonNames()</code> for a list of valid specifications) and the function will convert it for you before adding to the database. By default this tries date formats MM/DD/YYYY HH:MM:SS, MM-DD-YYYY HH:MM:SS, YYYY/MM/DD HH:MM:SS, and YYYY-MM-DD HH:MM:SS, so if your datetime format is different you will need to specify that with the <code>format</code> arugment. This will add these to your database as a table named <code>gpsData</code> and adds the same columns that PAMGuard would normally have for the GPS table. However, I'm not sure if PAMGuard is able to use these data for things like localization or showing the map.</p>
  <pre><code># PAMGuard database
  db &lt;- 'PamguardDb.sqlite3'
  # CSV of GPS data
  gps &lt;- 'GPSData.csv'
  library(PAMmisc)
  addPgGps(db=db, gps=gps, source='csv')
  # Example if your times are off California coast
  addPgGps(db=db, gps=gps, source='csv', tz='America/Los_Angeles')
  # Or example if you have dates in DD-MM-YYYY HH:MM:SS format
  addPgGps(db=db, gps=gps, source='csv', format='%d-%m-%Y %H:%M:%S')
  </code></pre>
  <p>Again, there is no guarantee that this will work with PAMGuard functionality that requires GPS data (although if there is enough interest I can try to work with the PAMGuard developers to make this happen). But it does mean that you have one less file to carry around since all that GPS data will live in the database, and if you use the <code>PAMpal</code> package for analysing your data it can easily access GPS data from your database and pair them to your detections:</p>
  <p><a href="https://taikisan21.github.io/PAMpal/NextStepsProcessing.html#adding-gps-data" rel="noreferrer">https://taikisan21.github.io/PAMpal/NextStepsProcessing.html#adding-gps-data</a></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-07-02T00:37:26.420Z
Answers.LastActivityDate: 2022-07-02T00:37:26.420Z
Answers.UserDisplayName: Taiki Sakai
Body: <p>I use a mobile recording platform (drifting recorders) where GPS data is collected in an independent data stream and saved as a csv file. I analyze my data in PAMGuard, and would like to integrate this GPS data directly into my PAMGuard database.</p>
  <p>Is there a streamlined way to integrate archival, externally collected GPS data into PAMGuard?</p>
  
Tags: <pamguard><gps>
Title: Adding external GPS data to PAMGuard
ThreadText: # Adding external GPS data to PAMGuard
  
  (Asked by: username_0 on 2022-07-01)
  
  I use a mobile recording platform (drifting recorders) where GPS data is collected in an independent data stream and saved as a csv file. I analyze my data in PAMGuard, and would like to integrate this GPS data directly into my PAMGuard database.
  
  Is there a streamlined way to integrate archival, externally collected GPS data into PAMGuard?
  
  **Tags:** pamguard, gps
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_2 on 2022-07-02. Score: 8 | Accepted answer
  
  With R you can use the addPgGps function from the PAMmisc package. The only requirement is that your CSV file has columns named UTC, Latitude, and Longitude. If your times are not in UTC timezone then you can either convert them to UTC yourself, or provide the timezone your times are in with the tz argument (see OlsonNames() for a list of valid specifications) and the function will convert it for you before adding to the database. By default this tries date formats MM/DD/YYYY HH:MM:SS, MM-DD-YYYY HH:MM:SS, YYYY/MM/DD HH:MM:SS, and YYYY-MM-DD HH:MM:SS, so if your datetime format is different you will need to specify that with the format arugment. This will add these to your database as a table named gpsData and adds the same columns that PAMGuard would normally have for the GPS table. However, I'm not sure if PAMGuard is able to use these data for things like localization or showing the map.
  # PAMGuard database
  db <- 'PamguardDb.sqlite3'
  # CSV of GPS data
  gps <- 'GPSData.csv'
  library(PAMmisc)
  addPgGps(db=db, gps=gps, source='csv')
  # Example if your times are off California coast
  addPgGps(db=db, gps=gps, source='csv', tz='America/Los_Angeles')
  # Or example if you have dates in DD-MM-YYYY HH:MM:SS format
  addPgGps(db=db, gps=gps, source='csv', format='%d-%m-%Y %H:%M:%S')
  
  Again, there is no guarantee that this will work with PAMGuard functionality that requires GPS data (although if there is enough interest I can try to work with the PAMGuard developers to make this happen). But it does mean that you have one less file to carry around since all that GPS data will live in the database, and if you use the PAMpal package for analysing your data it can easily access GPS data from your database and pair them to your detections:
  https://taikisan21.github.io/PAMpal/NextStepsProcessing.html#adding-gps-data
  
  
  ---
  
  ### Answer by username_1 on 2022-07-03. Score: 5
  
  PAMGuard is a bit fussy about the format of it's database tables, so I'd recommend getting PAMGuard to create a blank database table for you (add a GPS module and this will happen automatically). Then you'll need to either import data into the table, or write some code to insert data into that table. This could be done in any programming language that can connect to a CSV file and to a database - which is just about any programming language you can imagine, e.g. Matlab, R, Python, C, etc.
  
  
  ---
  
  