Skip to content

Instantly share code, notes, and snippets.

View hallahan's full-sized avatar

Nick Hallahan hallahan

View GitHub Profile
@hallahan
hallahan / gist:6970864
Created October 14, 2013 04:40
This is a very bare-bones example that demonstrates how to put an SWT Browser view into a Swing JFrame. Note that you need to download the SWT toolkit and put it in your classpath of your Java project for this to work.
import java.awt.Canvas;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JTextField;
import org.eclipse.swt.SWT;
import org.eclipse.swt.awt.SWT_AWT;
import org.eclipse.swt.browser.Browser;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
@hallahan
hallahan / gist:6971068
Created October 14, 2013 05:10
Basic Fahrenheit to Celsius converter with Swing. Try converting Degrees, Minutes, Seconds coordinates to Decimal coordinates.
public class CelsiusConverterGUI extends javax.swing.JFrame {
/**
* Creates new form CelsiusConverterGUI
*/
public CelsiusConverterGUI() {
initComponents();
}
@hallahan
hallahan / GenericMapBrowser.java
Last active December 25, 2015 11:39
The main view of a generic map navigation application.
import java.awt.Canvas;
import java.awt.EventQueue;
import java.text.DateFormat;
import java.util.Date;
import java.util.Locale;
import javax.swing.JFrame;
/**
*
* @author Nicholas Hallahan
@hallahan
hallahan / gist:7604087
Created November 22, 2013 17:53
Putting the ! there actually makes sense with the wording in the logic, because the else statement has the var googleRowNumber, and the row number is indeed a google row, not a TMS row.
if (!isTMSstructure) {
imgName = imageFile.getName();
} else {
int zoom = Integer.parseInt(resultZoomDirectory.getName());
int googleRowNumber = Integer.parseInt(FileUtils.getFileNameWithoutExtension(imageFile.getName()));
imgName = String.valueOf(
(int) (Math.pow(2, zoom) - 1 - googleRowNumber)) + "." + FileUtils.getFileExtension(imageFile.getName());
}
@hallahan
hallahan / gist:7622315
Created November 24, 2013 01:40
Trying to cut holes in B4 with the BQA band
import os
import sys
import arcpy
import numpy
import math
from arcpy.sa import *
arcpy.CheckOutExtension('Spatial')
arcpy.env.overwriteOutput = True
cwd = os.getcwd()
@hallahan
hallahan / gist:7622346
Created November 24, 2013 01:43
trying to set values iteratively in numpy
import os
import sys
import arcpy
import numpy
import math
from arcpy.sa import *
arcpy.CheckOutExtension('Spatial')
arcpy.env.overwriteOutput = True
cwd = os.getcwd()
@hallahan
hallahan / create-binary-mask.py
Last active December 29, 2015 05:39
Creates a binary mask of cloud vs no cloud using BQA values that are classified as cloud.
import os
import sys
import arcpy
import numpy
import math
from arcpy.sa import *
arcpy.CheckOutExtension('Spatial')
arcpy.env.overwriteOutput = True
cwd = os.getcwd()
@hallahan
hallahan / sum-masks.py
Created November 24, 2013 04:35
Sums a bunch of binary masks together so you can have classification groups that show how many images in our set are cloudless.
import os
import sys
import arcpy
from arcpy.sa import *
arcpy.CheckOutExtension('Spatial')
arcpy.env.overwriteOutput = True
cwd = os.getcwd()
inputPath = cwd + "\\intermediate\\"
outputPath = cwd + "\\output\\"
@hallahan
hallahan / rgb-holes.py
Last active December 30, 2015 17:59
This script just composites bands 4,3,2 into an RGB composite tiff for all of the outputs of holy cloud imagery.
# cloud-hole-all.py
# Nicholas Hallahan nick@theoutpost.io
# Sun Nov 24 2013
# This script just composites bands 4,3,2 into an RGB composite tiff for all of the outputs
# of holy cloud imagery.
import os
import arcpy
@hallahan
hallahan / average-rgb-nyira.py
Created December 8, 2013 23:00
This script averages together all of the RGB values from each image. Because the clouded pixels are set to 0, Those values are ignored in the average. We divide the sum of values by another raster that is the sum of valid pixels based on BQA classification.
# average-rgb2.py
# Nicholas Hallahan nick@theoutpost.io
# Sat Nov 30 2013
import os
import arcpy
from arcpy.sa import *
arcpy.CheckOutExtension('Spatial')