Skip to content

Instantly share code, notes, and snippets.

@mlt
mlt / ssurgo2rosetta.R
Last active June 1, 2016 18:03
SSURGO to DrainMod via Rosetta
## this script extracts soil component(s) data from SSURGO DB for use
## in DrainMod model. Rosetta should be used to derive VGM parameters
library(RODBC)
## library(RPostgreSQL)
library(plyr)
file <- 'ssurgo2rosetta.txt' # output file name to import into Rosetta
con <- odbcConnectAccess("C:/webdata/soils/soil_mn061/soildb_MN_2003.mdb")
## con <- odbcDriverConnect("Driver={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=C:/webdata/soils/soil_mn061/soildb_MN_2003.mdb")
@mlt
mlt / rst599.py
Created January 22, 2016 05:56
chirp_rst599
# Copyright 2015 Mikhail Titov <mlt@gmx.us>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@mlt
mlt / rst599_download.py
Created October 11, 2015 17:40
Sainsonic RST599 extraction
#!/usr/bin/env python
from __future__ import print_function
from datetime import timedelta
import argparse, os, sys
import logging
from serial import Serial, SerialException
from binascii import hexlify
import struct
import re
from chirp.bitwise import bcd_to_int
@mlt
mlt / crbasic-mode.el
Last active March 30, 2021 07:55
CR1 editing mode for CRBasic used in LoggerNet software from Campbell Scientific
;;; crbasic-mode.el --- CR1 editing mode
;; Copyright (C) 2014 Mikhail Titov
;; Author: Mikhail Titov <mlt@gmx.us>
;; URL: https://
;; Keywords: crbasic, cr1
;; Version: 1.0.0
;; This program is free software; you can redistribute it and/or modify
@mlt
mlt / table.shingle.R
Last active August 29, 2015 13:58 — forked from MrFlick/table.shingle.R
Update example with origin and legend
table.shingle<-function(..., as.data.frame=F) {
dots<-list(...)
stopifnot(all(sapply(dots, class) %in% c("shingle","factor")))
stopifnot(length(unique(sapply(dots, length)))==1)
dims<-sapply(dots, nlevels)
varnames<-tail(lapply(match.call(), deparse),-1)
varnames["as.data.frame"] <- NULL
res<-array(0, dims, `names<-`(lapply(dots, function(x) as.vector(sapply(levels(x), paste, collapse=":"))), varnames))
isinlevel<-function(z, ints) {
if(is.factor(z)) {
@mlt
mlt / persistent.py
Last active December 27, 2015 19:39
Ditch defaultdict and use get() with default instead
# -*- coding: utf-8 -*-
# ***************************************************************************
# PersistentDialog
# ---------------------
# Date : November 2013
# Copyright : (C) 2013 by Mikhail Titov
# Email : mlt at gmx dot us
# ***************************************************************************
# * *
# * This program is free software; you can redistribute it and/or modify *
@mlt
mlt / gist:2991670
Created June 25, 2012 22:06
Alternative approach for PIHM GIS watershed delineation
@echo off
set OSGEO4W_ROOT=C:\OSGeo4W
set GISBASE=%OSGEO4W_ROOT%\apps\grass\grass-6.4.2
rem set GISBASE=%OSGEO4W_ROOT%\apps\grass\grass-7.0.svn
rem set GRASS_SH=%OSGEO4W_ROOT%\apps\msys\bin\sh.exe
SET PATH=%GISBASE%\bin;%GISBASE%\lib;%OSGEO4W_ROOT%\bin;%OSGEO4W_ROOT%\apps\msys\bin;%PATH%
SET GISRC=.grassrc
md grassdata\default\PERMANENT