Skip to content

Instantly share code, notes, and snippets.

View lx-88's full-sized avatar

Michael Ewald lx-88

  • Northwest USA
View GitHub Profile
class Point(object):
def __init__(self, x, y):
self.x = x
self.y = y
# See how I dont have to define these above but should define them in init?
self.secret = 'hello Burke'
self.message = None
self.model_results = list()
@lx-88
lx-88 / logging_and_argparse_example.py
Last active December 28, 2015 22:47
Demonstrate a quick example of how to use argparse and to setup python logging (both console and to a file) and pass the logger between functions.
#!/usr/bin/env python
"""
MIT License (MIT)
Copyright (c) 2015. Michael Ewald <mewald@geomaticsresearch.com>, GeomaticsResearch LLC
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
@lx-88
lx-88 / superscript in R ggplot2 axis label.R
Created September 8, 2015 05:50
Include a superscript in a ggplot2 axis label. Useful for a unit...
# use expression
# within expression, ~ represents a space
chanDensity_plot <- ggplot(data=chan_density_df, aes(x=site, y=density)) +
geom_bar(stat='identity') +
labs(x="Site", y=expression(Channel~Density~(km/km^2)), title='LIDAR-derived channel density')
@lx-88
lx-88 / merge_spatial_dataframes.py
Created August 7, 2015 21:49
Merge files within a directory when the ending of the filename matches a given string. Uses geopandas.
def concat_spatial_df(folder_to_search, ends_with=".shp"):
"""
Merge spatial data layers that meet the ending provided by ends_with and within
folder folder_to_search and it's children
import os
import pandas as pd
import geopandas
"""
# Find files to merge
@lx-88
lx-88 / list_moving_window.py
Created July 31, 2015 18:31
Moving window for a nested python list
# Test fixture for lineStrings
lineStrings = [(i, "obj{0}".format(i),) for i in range(1011)]
stepSize = 200
nSteps = len(lineStrings)/stepSize
print "there are {0} objs in lineStrings".format(len(lineStrings))
steps = range(0, nSteps+1)
for stepI in steps:
# Get the first object in the window
@lx-88
lx-88 / read_VH400.ino
Last active August 27, 2023 15:17
Arduino function to read a Vegetronix VH400 Soil Moisture Sensor. See http://www.vegetronix.com/Products/VH400/
// MIT License (MIT)
//
// Copyright (c) 2015. Michael Ewald, GeomaticsResearch LLC.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
@lx-88
lx-88 / get_paths.py
Last active August 4, 2017 17:36
Recursively search directory for files with specific file extensions.
#!/usr/bin/env python
import sys
import os
"""
MIT License (MIT)
Copyright (c) 2015. GeomaticsResearch LLC.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@lx-88
lx-88 / MIT_license_template.py
Last active March 21, 2019 22:22
MIT License Template
"""
MIT License (MIT)
Copyright (c) 2015. <Authors>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is