Skip to content

Instantly share code, notes, and snippets.

View danclewley's full-sized avatar

Daniel Clewley danclewley

View GitHub Profile
@danclewley
danclewley / reproject_neodaas_netcdf.py
Created November 14, 2018 21:21
Reproject NEODAAS NetCDF
#!/usr/bin/env python
"""
Create a single layer tif in WGS84 projection from
NEODAAS (https://www.neodaas.ac.uk/) netCDF files in mercator projection.
Converts the location array to GCPs and uses these to warp the image with
GDAL.
Dan Clewley (dac@pml.ac.uk).
<!-- SPDLib Metrics file -->
<spdlib:metrics xmlns:spdlib="http://www.spdlib.org/xml/">
<!-- HOME -->
<spdlib:metric metric="home" field="HOME"/>
<!-- WD -->
@danclewley
danclewley / read_plot_spectra.py
Created May 1, 2018 13:22
Example of reading a spectra from a BIL file
"""
Example of reading the spectra from a single pixel using
arsf_envi_reader (https://github.com/pmlrsg/arsf_tools)
Dan Clewley, NERC-ARF-DAN
2018-05-01
"""
from arsf_envi_reader import numpy_bin_reader
from arsf_envi_reader import envi_header
from matplotlib import pyplot as plt
@danclewley
danclewley / run_tiled_segmentation.py
Created July 9, 2016 17:02
RSGISLib Tiled Segmentation
#!/usr/bin/env python
"""
Apply RSGISLib segmentation to image
using standard or tiled approach.
For more details see:
https://spectraldifferences.wordpress.com/2016/07/09/scalable-image-segmentation-using-rsgislib/
Dan Clewley (09/07/2016)
@danclewley
danclewley / apply_savgol_filter.py
Created June 27, 2016 07:25
Apply Savitzky-Golay filter to an ENVI BIL file
#!/usr/bin/env python
"""
Apply Savitzky-Golay filter to an ENVI BIL file
Uses scipy
http://docs.scipy.org/doc/scipy/reference/generated/scipy.signal.savgol_filter.html
And arsf_envi_reader (available from: https://github.com/pmlrsg/arsf_tools)
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Mosaic files within a zip archive using RSGISLib
Author: Dan Clewley
Creation Date: 02/09/2015
Designed to mosaic Environemnt Agency LiDAR-derived DTM and DSM files
downloaded in ASCII format from http://environment.data.gov.uk/ds/survey
#!/usr/bin/env python
"""
A script to create a GIF from a sequence of images using
ImageMagick.
Applies natural sorting to file names.
Dan Clewley (http://spectraldifferences.wordpress.com)
"""
import argparse
import re
import sys
from rios import applier
from rios import cuiprogress
import numpy
def calcstats(info, inputs, outputs):
# Calc standard deviation of bands for each pixel
stdev_pixels = numpy.std(inputs.inimage, axis=0)
# Reshape to make 3-dimensional array (required for output)
outputs.outimage = stdev_pixels.reshape((1,stdev_pixels.shape[0],stdev_pixels.shape[1]))
import sys
from rios import applier
from rios import cuiprogress
import numpy
def calcstats(info, inputs, outputs):
# Calc standard deviation of bands for each pixel
stdev_pixels = numpy.std(inputs.inimage, axis=0)
# Reshape to make 3-dimensional array (required for output)
outputs.outimage = stdev_pixels.reshape((1,stdev_pixels.shape[0],stdev_pixels.shape[1]))
@danclewley
danclewley / topoCorrection.py
Last active August 29, 2015 13:56
A script topographically correct SAR data using RIOS applier.
#!/usr/bin/env python
#
# A script topographically correct SAR data using RIOS applier.
#
# Dan Clewley (clewley@usc.edu) - 05/02/2013
#
# The correction uses:
#
# sigma0_norm = sigma0 * (A_flat / A_slope) * (cos(theta_ref) / cos(theta_loc))^n
#