Skip to content

Instantly share code, notes, and snippets.

@glw
glw / tiff_2_jpg_convert.py
Last active April 20, 2018 21:20
convert tiff to jpg and transfer exif tags
import argparse
import pyexiv2
import cv2
import os.path
import numpy as np
ap = argparse.ArgumentParser()
ap.add_argument("-i", "--input", required=True, help="input image name.")
args = vars(ap.parse_args())
@glw
glw / covariance-matrix-notes.md
Created April 23, 2018 16:16
covariance matrix
@glw
glw / NDVI-calc.sh
Last active October 11, 2023 21:42
NDVI calculation
# gets read from a database, hardwired here
NDVI_COLORMAP="006600 008800 00BB00 00FF00 CCFF00 FFFF00 FFCC00 FF8800 FF0000 EE0000 DD0000 CC0000 BB0000 AA0000 990000 880000 770000"
NIR_INPUT=nir_input.tif
NIR_OUTPUT=nir_output.tif
RED_INPUT=red_input.tif
RED_OUTPUT=red_output.tif
NDVI_IMAGE=new_ndvi.tif
@glw
glw / port_forward
Created June 5, 2018 21:14
tensorboard from cloud to your local machine
source: https://stackoverflow.com/questions/37987839/how-can-i-run-tensorboard-on-a-remote-server#40413202
ssh -L 16006:127.0.0.1:6006 user@my_server_ip
$ tensorboard --logdir=/path/
* open browser on local machine. >> localhost:16006
@glw
glw / pdal_cheatsheet.md
Last active January 24, 2019 21:01
Pdal Pipeline Cheatsheet

Run PDAL on docker

docker run -it --rm -v $(pwd):/data pdal/pdal pdal pipeline /path/to/json/file/simple_crop.json

Simple_crop.json - using WKT point location and a distance of 50ft

{
  "pipeline":[
    "path/to/original/las/file/lidar.las",
@glw
glw / install_qgis_ltr_ubuntu.sh
Last active October 10, 2019 17:19
install qgis LTR on Ubuntu
sudo add-apt-repository -y ppa:ubuntugis/ubuntugis-unstable
sudo sh -c 'echo "deb https://qgis.org/ubuntugis-ltr xenial main" >> /etc/apt/sources.list'
sudo sh -c 'echo "deb-src https://qgis.org/ubuntugis-ltr xenial main " >> /etc/apt/sources.list'
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-key 51F523511C7028C3
sudo apt-get update
sudo apt-get install -y qgis qgis-plugin-grass
@glw
glw / excel_insert_image
Last active February 24, 2021 03:01
handy image insert into excel column by file path in separate column
# 1. Open excel file
# 2. Make sure there is a column of file paths to files. Eg. C://directory1/direcotry1/image01.jpg
# 3. Make sure the column to the right of the file paths is open for the images to be inserted.
# 4. Go to Developer > Visual Basic. A new window will open. In the right hand menu under "Microsoft Excel Objects", right click the
# sheet name you are working with (eg. "Sheet1"). Right click it > Insert > Module.
# 5. A New window will pop up for your code. Copy and past the code below into the window and Run.
# 6. It will prompt you to select the entire column and rows containing the file path to the images. Select it and click ok.
Sub InsertPicFromFile()
Dim xRg As Range
@glw
glw / create_csv_from_image_dir.py
Last active October 5, 2021 21:39
Python files to Export Image attachments from AGOL FGDB and, create a CSV file from a directory of those images (only works for JPG files for now)
# Create CSV from a list of files in a given directory. It is the companion file of export_photos.py. It doesnt take into account multiple photos associated with the same ID. Meant to be used with "export_photos.py"
import csv
import os
import argparse
import itertools
parser = argparse.ArgumentParser()
parser.add_argument('-i','--input folder', type=str, required=True, help='path location of images')
parser.add_argument('-o','--output folder', type=str, help='path location for csv output, leave blank if same as input.')
@glw
glw / notes.md
Last active November 2, 2021 04:03
Jupyter Notebooks in Virtual Environments
@glw
glw / find_duplicate_file_names
Created February 17, 2022 00:12
recursively find duplicate files names in a directory
find /path/to/directory/ -type f -print0 | awk -F/ 'BEGIN { RS="\0" } { n=$NF } k[n]==1 { print p[n]; } k[n] { print $0 } { p[n]=$0; k[n]++ }' > duplicate_files.txt
source: https://unix.stackexchange.com/a/468461/363004