Skip to content

Instantly share code, notes, and snippets.

@glw
glw / install_pyenv.sh
Created August 1, 2023 05:57
Install pyenv on WSL (Ubuntu)
# Install pyenv
curl -L https://github.com/pyenv/pyenv-installer/raw/master/bin/pyenv-installer | bash
# other install directions https://github.com/pyenv/pyenv
# Install dependencies
sudo apt-get install -y git make gcc build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev xz-utils tk-dev
@glw
glw / lidar_install.sh
Created January 12, 2023 21:28
Lidar software installs
https://help.ubuntu.com/community/CompilingEasyHowTo
sudo checkinstall << which puts the program in the package manager for clean, easy removal later. This replaces the old sudo make install command.
# gdal
# las-perf
git clone https://github.com/hobu/laz-perf.git \
cd laz-perf \
mkdir build \
cd build \
@glw
glw / psycopg.py
Last active July 12, 2022 19:56
psycopg2 quick n easy connect to db
import geopandas as gpd
import psycopg2
# import psycopg2.extras
# If you want to use yaml create a config file
import yaml
# yaml config file load
config = yaml.safe_load(open("config.yaml"))
@glw
glw / find-and-cp-all-files
Created February 17, 2022 15:56
find and copy all files of a particular name without directory structure
find ./ -name 'G0*' -type f -exec cp -t /media/sf_Z_DRIVE/fpcc-trails/trails-2021/ --force --backup=t '{}' +
@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
@glw
glw / notes.md
Last active November 2, 2021 04:03
Jupyter Notebooks in Virtual Environments
@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 / 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 / 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 / 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",