Skip to content

Instantly share code, notes, and snippets.

View perrygeo's full-sized avatar

Matthew Perry perrygeo

View GitHub Profile
@snorfalorpagus
snorfalorpagus / split.py
Created January 23, 2016 10:02
Shapely ST_Split
from shapely.geometry import Point, LineString, Polygon, GeometryCollection, MultiLineString
from shapely.ops import polygonize, unary_union, nearest_points
from shapely.wkt import loads as load_wkt
def split_polygon_line(polygon, line):
"""Split a Polygon with a LineString"""
assert(isinstance(polygon, Polygon))
assert(isinstance(line, LineString))
boundary = polygon.boundary
union = boundary.union(line)
#!/bin/bash
#
# tile_georef.sh
#
# Grab an mapbox ZYX tile and save as a geotiff with geoferencing
# tile_georef.sh 13 4168 3197 mapbox.satellite output.tif
#
set -u
@kgjenkins
kgjenkins / carson-projection.png
Last active July 18, 2016 21:48
Carson projection in CartoDB PostGIS
carson-projection.png
@samuelestabrook
samuelestabrook / Qt_fix_QGIS.md
Last active August 29, 2015 14:24
Fix Qt for Homebrew QGIS install

Fix Qt for Homebrew QGIS install

Go to terminal and roll back the Qt installation through GitHub

$ brew uninstall qt
$ brew install https://raw.githubusercontent.com/Homebrew/homebrew/8dd3478131b232553f4c0cab197f8443a0a559a6/Library/Formula/qt.rb
@coolaj86
coolaj86 / github-pages-https-lets-encrypt.md
Last active November 16, 2021 22:36
Github Pages: Let's Encrypt!
@mangecoeur
mangecoeur / description.md
Last active March 30, 2021 21:34
Pandas PostgresSQL support for loading to DB using fast COPY FROM method

This small subclass of the Pandas sqlalchemy-based SQL support for reading/storing tables uses the Postgres-specific "COPY FROM" method to insert large amounts of data to the database. It is much faster that using INSERT. To acheive this, the table is created in the normal way using sqlalchemy but no data is inserted. Instead the data is saved to a temporary CSV file (using Pandas' mature CSV support) then read back to Postgres using Psychopg2 support for COPY FROM STDIN.

@sgillies
sgillies / README.md
Last active April 6, 2020 12:53
Get raster value at a point using a tiny window

A Rasterio dataset's index() method gives you the row, col index of the pixel containing the point x, y (in the dataset's CRS units).

Define a 1x1 pixel read window starting at that index (see the tiny_window() function below) and use it to read an ndarray. The one in this case has shape (3, 1, 1): 3 bands, 1 row, and 1 column. The values of the 3 bands at the point x, y for this case are 28, 29, and 27.

@dalekunce
dalekunce / mac_gis_setup.md
Last active July 29, 2023 22:18
Yosemite GIS Machine Setup

Mac OS X GIS Setup

OS X Preferences


# Expand save panel by default
defaults write NSGlobalDomain NSNavPanelExpandedStateForSaveMode -bool true
import Control.Monad
import Control.Concurrent
import Data.Int
import System.Environment
sendSidewards :: Chan Int -> Chan Int -> IO ()
sendSidewards from to = do
n <- readChan from
writeChan to n
sendSidewards from to
@jkbrzt
jkbrzt / pyc
Last active June 6, 2023 14:59
Delete Python's compiled *.pyc files like a pro
#!/bin/sh
#
# Delete Python's compiled *.pyc and __pycache__ files like a pro
# https://gist.github.com/jakubroztocil/7892597
#
# Usage:
# Delele *.pyc and __pycache__ files recursively in the current directory:
# $ pyc
#
# The same, but under /path: