Skip to content

Instantly share code, notes, and snippets.

View phargogh's full-sized avatar

James Douglass phargogh

View GitHub Profile
@phargogh
phargogh / README.txt
Created February 5, 2020 02:53
Running a python program in GDB
To run a python program (such as nosetests) in GDB, do the following:
$ gdb --args python -m nose
Then at the gdb shell:
> start
> continue
@phargogh
phargogh / landcover-raster-attributes.py
Created December 17, 2019 19:55
A function to get pixel values from a GDAL landcover raster
import collections
from osgeo import gdal
RasterStats = collections.namedtuple('RasterStats', ['min', 'max'])
def get_raster_values_from_attr_table(filepath, band_index):
gdal_dataset = gdal.OpenEx(filepath, gdal.OF_RASTER)
band = gdal_dataset.GetRasterBand(1)
attr_table = band.GetDefaultRAT()
@phargogh
phargogh / FOO.bar
Created October 24, 2019 22:15
This is a test gist
This a file in a gist.
@phargogh
phargogh / 0_reuse_code.js
Last active September 3, 2015 22:48
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@phargogh
phargogh / union.py
Last active August 29, 2015 14:17
Failing function to take union of polygons and write to a vector
"""Module for preprocessing operations."""
# Including all import statements from the original file, in case that matters
# Original file available (raw) at http://adept.invest-natcap.googlecode.com/hg/adept/preprocessing.py
import os
import logging
import tempfile
import shutil
import math
import json