Skip to content

Instantly share code, notes, and snippets.

<!DOCTYPE html>
<html>
<head>
<title>Corona Tiles</title>
<link href="https://developers.google.com/maps/documentation/javascript/examples/default.css" rel="stylesheet">
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"></script>
<script>
var map;
var width256Tile = 142;
var height256Tile = 41;
@chadcooper
chadcooper / square-img.py
Last active December 24, 2015 08:29
Quick and dirty copy/paste of an image onto a larger square.
import matplotlib.pyplot as plt
import numpy as np
import matplotlib
input_img = plt.imread("/home/chad/Projects/corona/leaflet/ds1105-2235df023_23_b_resize.tif")
x = input_img.shape[1]
y = input_img.shape[0]
c = x/2
y1 = c - (y/2)
y2 = c + (y/2)
@chadcooper
chadcooper / find-prj-file.py
Created August 9, 2013 13:33
Finds a specified prj file in the ArcGIS Coordinate Systems directory.
import os, fnmatch, arcpy
def locate(pattern, root=arcpy.GetInstallInfo()["InstallDir"] + "\Coordinate Systems"):
"""Locate all files matching supplied filename pattern in and below
supplied root directory.
"""
for path, dirs, files in os.walk(os.path.abspath(root)):
for filename in fnmatch.filter(files, pattern):
@chadcooper
chadcooper / ini-tool-validator.py
Created August 9, 2013 13:30
Tool validator script for ArcGIS 10.0 Toolbox that reads a config.ini or XML config file to use to populate tool fields.
class ToolValidator:
"""Class for validating a tool's parameter values and controlling
the behavior of the tool's dialog.
"""
class ParseIni(object):
"""Class for parsing VIESORE ini configuration files"""
def __init__(self):
self.viesore_ini = r"C:\Program Files (x86)\VIESORE\Config\ViesoreConfig.ini"
import arcpy
in_raster = r"\\psf\Home\Documents\ArcGIS\Default.gdb\rastercalc13"
in_raster_obj = arcpy.Raster(in_raster)
arcpy.env.extent = in_raster
arcpy.env.cellSize = in_raster
arcpy.env.overwriteOutput = 1
# Raster already projected earlier in CreateProject.py process
arcpy.CheckOutExtension("Spatial")
Con("VerySmallKittyHawk","VerySmallKittyHawk" + 10, "VerySmallKittyHawk", "VALUE > 0")
@chadcooper
chadcooper / file-picker.py
Created July 1, 2013 20:52
Super simple file picker jobbie.
import wx
class MyForm(wx.Frame):
def __init__(self):
wx.Frame.__init__(self, None, wx.ID_ANY, "File Picker")
self.panel = wx.Panel(self, wx.ID_ANY)
box = wx.BoxSizer(wx.SB_VERTICAL)
self.file_picker = wx.FilePickerCtrl(self.panel, -1)
@chadcooper
chadcooper / reportlab-flowables.py
Last active December 18, 2015 16:08
Creating a PDF using flowables.
from reportlab.pdfgen.canvas import Canvas
from reportlab.lib.styles import getSampleStyleSheet
from reportlab.lib.units import inch
from reportlab.lib import colors
from reportlab.platypus import Paragraph, Frame, TableStyle, Table, Spacer, Image
from reportlab.lib.pagesizes import letter
import datetime
c = Canvas('doc.pdf', pagesize=letter)
f = Frame(inch, inch, 6.5*inch, 9*inch, showBoundary=0)
@chadcooper
chadcooper / reportlab-table.py
Last active October 29, 2024 11:46
Create alternating row colors in table with Reportlab.
from reportlab.lib import colors
from reportlab.lib.pagesizes import letter
from reportlab.platypus import Table, TableStyle, Paragraph
from reportlab.pdfgen.canvas import Canvas
from reportlab.lib.styles import getSampleStyleSheet
styles = getSampleStyleSheet()
style = styles["BodyText"]
canv = Canvas("doc.pdf", pagesize=letter)
$ sphinx-build -b latex -a -E . latex
$ cd latex
$ make all-pdf