Skip to content

Instantly share code, notes, and snippets.

@andybell
andybell / Batch_geotif.sh
Created May 30, 2015 01:41
Batch GDAL tif to geotif
#copies all tifs in a folder and saves them as compressed geotifs
mkdir geotifs
for file in *.tif
do
#gdal_translate
gdal_translate -of GTiff -co "COMPRESS=LZW" $file geotifs/$file
done
@andybell
andybell / index.html
Last active August 29, 2015 14:26
Reference Layer above polygon
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<!--The viewport meta tag is used to improve the presentation and behavior of the samples
on iOS devices-->
<meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no">
<title>Unique Value Renderer</title>
<link rel="stylesheet" href="http://js.arcgis.com/3.14/esri/css/esri.css">
@andybell
andybell / pt_cloud_subset
Created November 3, 2015 20:14
quickly subset point cloud text file
#!/bin/bash
# uses grep wildcard to get a subset of a XYZ pointcloud
# usage: file_in, file_out, x, y
# echo arguments to the shell
echo $1 $2 $3 $4
in=$1
out=$2
x=$3
@andybell
andybell / replaceZero.cal
Created November 18, 2015 22:23
field calculator replace zero values with null
# replace all zeros with <Null>, anything else keep the same
def replaceZero(value):
if value == 0:
return None
else:
return value
__esri_field_calculator_splitter__
replaceZero( !current_richness_Native_Fish!)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@andybell
andybell / BareET_sept2015.csv
Last active September 26, 2016 15:06
Creates bare ET vs measured graphs at five stations
Method D1 D2 D3 D4 D5
CalSIMETAW 0.4 0.4 0.4
DETAW 0.4 0.4 2.7
DisALEXI 2 1.8 1.6 1.7 1.3
ITRC 1.3 1.5 0.8 0.9 0.7
SIMS 1.3 1.3 1.6
UCD-METRIC 1.5 2.4 1.6 2.5 1.8
UCD-PT 3.3 3.3 4.4
MEASURED 0.17 0.35 0.051 0.41 0.39

Keybase proof

I hereby claim:

  • I am andybell on github.
  • I am andybell (https://keybase.io/andybell) on keybase.
  • I have a public key whose fingerprint is 0A0B 34A8 1594 3CE5 B786 0A6F E6E6 9A9E 21F4 FD66

To claim this, I am signing this object:

@andybell
andybell / mtb-example.py
Created January 25, 2019 15:36
MarinegeoTemplateBuilder Example Script
import MarinegeoTemplateBuilder # load the MarinegeoTemplateBuilder library
from MarinegeoTemplateBuilder.classes import Field, Vocab # load the objects to contstruct fields + vocab
# python dictionary of the metadata values to prefill
metadataValues = {"TemplateVersion": "v0.0.0",
"Title": "This is a demo workbook"}
# list of fields to construct
fields = [
@andybell
andybell / normalizeField.py
Last active July 1, 2019 20:30
Earth Genome GRAT Normalize Index Field
import arcpy
def normalizeField(in_table, in_field, out_field, index_min, index_max):
"""
Normalizes a field to a new range
:param in_table: input table
:param in_field: field with the original values
:param out_field: output field
:param index_min: the minimum value for the new range
:param index_max: the mazimum value for the new range
:return:
@andybell
andybell / timeit.py
Created July 10, 2019 13:37
Timer decorator
import time
# timer decorator
# adapted from https://medium.com/pythonhive/python-decorator-to-measure-the-execution-time-of-methods-fa04cb6bb36d
def timeit(method):
def timed(*args, **kw):
ts = time.time()
result = method(*args, **kw)
te = time.time()
if 'log_time' in kw: