Skip to content

Instantly share code, notes, and snippets.

🕶

Brian Bancroft brianbancroft

🕶
Block or report user

Report or block brianbancroft

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@brianbancroft
brianbancroft / custom-task.js
Created Apr 16, 2019 — forked from CITguy/custom-task.js
Basic pattern for creating a custom Transform stream for use with gulp tasks.
View custom-task.js
var gulp = require('gulp');
var myTransform = require('./myTransform');
gulp.task('foobar', function (){
return gulp.src("foobar.js")
.pipe(myTransform())
.pipe(gulp.dest('.'));
});
@brianbancroft
brianbancroft / 1_decipher-richText.js
Last active Apr 2, 2019
Deciphering Contentful Rich Text Blocks in React. The second file is an example of the graphql output that would go into this.
View 1_decipher-richText.js
import React from 'react'
const classList = marks => marks.map(i => i.type).join(' ')
const elementMap = {
paragraph: 'p',
'heading-1': 'h1',
'heading-2': 'h2',
'heading-3': 'h3',
'heading-4': 'h4',
@brianbancroft
brianbancroft / .env
Last active Nov 10, 2018
Basic Nodemailer App
View .env
EMAIL_ADDRESS=''
EMAIL_PASSWORD=''
View test.geojson
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@brianbancroft
brianbancroft / test.xml
Created Oct 1, 2018
QGIS Imhof Hillshade Gadient
View test.xml
<!DOCTYPE qgis_style>
<qgis_style version="1">
<symbols/>
<colorramps>
<colorramp name="imhof_hillshade_dark" type="gradient">
<prop k="color1" v="119,66,70,255"/>
<prop k="color2" v="255,220,115,51"/>
<prop k="discrete" v="0"/>
<prop k="rampType" v="gradient"/>
<prop k="stops" v="0.278729;21,27,30,230:0.449878;0,132,168,51:0.603912;171,107,212,0:0.809291;255,193,127,38"/>
@brianbancroft
brianbancroft / grab.py
Last active Sep 5, 2018
Get bounding boxes for all CMAs in Canada using QGIS
View grab.py
bounding_boxes = []
features = iface.activeLayer().selectedFeatures()
for feature in features:
bounding_boxes.append({
'city': feature.attributes()[2],
'max_x': feature.geometry().boundingBox().toRectF().topRight().x(),
'max_y': feature.geometry().boundingBox().toRectF().topRight().y(),
'min_x': feature.geometry().boundingBox().toRectF().bottomLeft().x(),
View incomes_without_children.geojson
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@brianbancroft
brianbancroft / clean-ids.py
Created Jul 26, 2018
Cleans census tract id's which have accidentally been converted to floats from strings.
View clean-ids.py
import psycopg2
database = ''
host = 'localhost'
port = 5432
user = ''
password = ''
table = ''
@brianbancroft
brianbancroft / generate.py
Created Jun 7, 2018
Generates a series of output images from a map scene in QGIS. Needs heavy editing.
View generate.py
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from qgis.core import *
coverage = "/Users/joellawhead/qgis_data/atlas/grid.shp"
atlasPattern = "/Users/joellawhead/qgis_data/atlas/output_"
# Load the map layer. This example uses a shapefile
# but you can use any supported QGIS layer.
vlyr = QgsVectorLayer(coverage, "grid", "ogr")
View gist:2cb17b975a0b3240de05e5b8a5960096
"""
Likely not useful to anyone else, but just putting it out there.
This script will take a directory of GeoTIFFs and merge them together without issues.
This script simply decompresses the files, runs nearblack to remove pseudo-black borders caused by compression, and then uses gdalwarp to stitch the files together.
The script is designed to use the minimal amount of disk space possible -- it cleans up each file after decompression and continually merges with a master image.
"""
import os
You can’t perform that action at this time.