Skip to content

Instantly share code, notes, and snippets.

@allenaven
allenaven / flatten_ebooks_dir.py
Created June 25, 2017 10:51
Moves ebook files from complicated directory structure to all one folder, deletes excess metadata files and dir paths
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Fri May 12 19:09:58 2017
@author: aa
"""
import os
import shutil
@allenaven
allenaven / qgis_toolbar_reset.py
Created May 24, 2017 04:30
Reset lost QGIS toolbar to current window.
# Run it the QGIS Python command window:
qgis.utils.iface.mapNavToolToolBar().move(150,40)
@allenaven
allenaven / al_coastal_boatramps.geojson
Last active February 19, 2017 02:01
Boatramps in coastal Alabama, excluding small private-use ramps
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@allenaven
allenaven / readme.md
Last active November 19, 2016 10:16
Log for my R benchmarkme results

benchmarkme Results

I periodically benchmark my computer systems in terms of their ability to carry out data analysis and related tasks in R. To do this I use the R benchmarkme package and I persist each set of results to a file (.rds to retain R class attribute) for posterity. I also log the run here at this very Gist.

I use the run_mark.R function, which I wrote based loosely on suggestions in the benchmarkme vignette, to do the benchmark tests and afterparty.

Machine description

Dell XPS 2011/Windows 10 (dual boot w/Debian)

@allenaven
allenaven / .block
Created November 7, 2016 07:44 — forked from nbremer/.block
Stretched Chord Diagram - From educations to occupations
height: 780
@allenaven
allenaven / atmospheric airtemp summaries.ipynb
Created June 15, 2016 09:42
Summarize atmospheric air temperatures by latitude band, day, and altitude from netCDF source files
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@allenaven
allenaven / read write excel from R.R
Created June 10, 2016 01:37
Read and write Excel from R using the openxlsx package. No infuriating Java dependencies. Easy to work with. Best Excel translator I know of.
# Example use of the openxlsx package
require(openxlsx) # For writing output in excel for collaborators
df1 <- data.frame(aa = letters[3:12], bb = 21:30, stringsAsFactors = FALSE)
df2 <- data.frame(cc = rnorm(20, 5, 1), dd = runif(20, 1, 5))
## Write the data to a new excel file
wb <- openxlsx::createWorkbook()
addWorksheet(wb, 'Wksheet name')
@allenaven
allenaven / s4_notes.md
Last active November 7, 2022 16:47
trying to build an s4 class that I need

Guide to using S4 classes in R

What is an "S4 class"?

S4 is a certain specification of R object class (thus, it is useful in object oriented programming). You define an S4 class based on the data you want it to hold, and you can then create many unique copies of that S4 class that hold different data but all adhere to the same specification and can take advantage of the same functions.

The concepts of class and method are crucial to understanding object-oriented programming:

  • class defines the behavior of objects in two ways:
  • Describes their attributes
@allenaven
allenaven / fl_srid.txt
Last active March 3, 2016 23:16
PostGIS spatial_ref_sys table fuzzy matches to %florida%
srid,auth_name,auth_srid,srtext,proj4text
2236,EPSG,2236,PROJCS["NAD83 / Florida East (ftUS)",GEOGCS["NAD83",DATUM["North_American_Datum_1983",SPHEROID["GRS 1980",6378137,298.257222101,AUTHORITY["EPSG","7019"]],TOWGS84[0,0,0,0,0,0,0],AUTHORITY["EPSG","6269"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4269"]],UNIT["US survey foot",0.3048006096012192,AUTHORITY["EPSG","9003"]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",24.33333333333333],PARAMETER["central_meridian",-81],PARAMETER["scale_factor",0.999941177],PARAMETER["false_easting",656166.667],PARAMETER["false_northing",0],AUTHORITY["EPSG","2236"],AXIS["X",EAST],AXIS["Y",NORTH]],+proj=tmerc +lat_0=24.33333333333333 +lon_0=-81 +k=0.999941177 +x_0=200000.0001016002 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=us-ft +no_defs
2237,EPSG,2237,PROJCS["NAD83 / Florida West (ftUS)",GEOGCS["NAD83",DATUM["North_American_Datum_1983",SPHEROID["GRS 1980",6378137,298.
@allenaven
allenaven / pt_thin.R
Created November 29, 2015 18:13
Thin an input point layer (e.g., animal telemetry locations) based on a user-specified grid for output to a SDM routine. Set up to use ESRI shapefiles, this can be modified.
# Allen Aven November 2015
# Function to thin a point input layer according to an input raster
require(sp)
require(rgdal)
require(raster)
require(dismo)
pt_thin <- function(infile, grid=grid, n_points=5) {