Skip to content

Instantly share code, notes, and snippets.

@simbamangu
simbamangu / runscoutbot.sh
Created February 14, 2024 07:31
Scoutbot setup and inference on image
# Install from source on Github
pip install git+https://github.com/WildMeOrg/scoutbot.git
# Run inference on a single image
scoutbot pipeline --config v3-cls EXAMPLE.JPG
import pandas as pd
import geopandas as gpd
from shapely.geometry import Point
from datetime import date, time, datetime, timedelta
# Load laser file
data = pd.read_csv('Laser.txt', header=None)
# Remove ' ft' and ' mph' from the height and speed columns and convert them to integers
data[1] = data[1].str.replace(' ft', '').astype(int)

After another Docker pull losing connection partway through a download (95% of 12GB this time), I spun up a virtual machine in the cloud and did the pull there, followed by docker save and downloading locally - this allows for a resumable download over SSH.

Overview:

  1. Set up cloud machine with either password or SSH key access (key access example below).
  2. Install docker
  3. docker pull the image
  4. docker save the image as compressed image using gzip
  5. Download with rsync
@simbamangu
simbamangu / summariseGPXfolder.R
Created December 1, 2022 08:40
Read a directory of GPX files and summarise by data type
# Read a directory of GPX files and summarise by data type
require(sf)
require(dplyr)
# Read all the GPX filenames/locations in target, recursive
gpxs <-
dir(
path = "../_data/tracklogs/",
recursive = T,
full.names = T,
# Usage
# python3 eulerAngles.py --logfile dataLog00017.TXT --outfile dataLog00017.csv
from math import atan2, asin, sqrt, pi
import pandas as pd
import argparse
# Parse arguments
ap = argparse.ArgumentParser()
@simbamangu
simbamangu / wpts2Rte.py
Created May 5, 2022 11:00
Python script to create GPX route from transect endpoints
#!/Library/Frameworks/Python.framework/Versions/3.6/bin/python3
# Input:
# - GPX file with waypoints
# Output:
# - GPX file with route
# ToDo:
# - Appify?
# - Naming conventions for different parsing of routes.
import gpxpy
# Download and analyse precipitation data for a polygon
# Libraries
library(raster)
library(sf)
library(rgdal)
library(utils) # For download.file
setwd("~/Downloads")
# Calculate the ground sample distance (cm/pixel) for oblique camera position.
# Sensor defaults for a Nikon D5600 with 35mm lens
# Inputs:
# Sw = sensor width in mm
# Sh = sensor height in mm
# f = focal length of lens in mm
# Pw = sensor width in pixels
# Ph = sensor height in pixels
# phi = off-nadir (directly below sensor) angle
# h = height of sensor above ground in metres
@simbamangu
simbamangu / cpyNsubfolder.sh
Last active February 11, 2021 08:27
Copy 'n' files to subfolder
# Copy 'n' files to subfolder
# Usage:
# cpn.sh N DEST
# Copies 'N' files to destination folder DEST
ls | sort | head -n $1 | xargs cp "{}" -t $2