Skip to content

Instantly share code, notes, and snippets.

@valgur
valgur / gdal_warp.py
Last active April 11, 2022 09:36
gdalwarp with GCPs via GDAL Python bindings
from pathlib import Path
from osgeo import gdal, osr
# Adapted from https://svn.osgeo.org/gdal/trunk/autotest/alg/warp.py
def warp_with_gcps(input_path, output_path, gcps, gcp_epsg=3301, output_epsg=3301):
# Open the source dataset and add GCPs to it
src_ds = gdal.OpenShared(str(input_path), gdal.GA_ReadOnly)
gcp_srs = osr.SpatialReference()
gcp_srs.ImportFromEPSG(gcp_epsg)
gcp_crs_wkt = gcp_srs.ExportToWkt()
@mbejda
mbejda / White-Female-Names.csv
Created November 2, 2015 01:35
Dataset of ~4,500 white (Caucasian) female names for NLP training and analysis. The names have been retrieved from US public inmate records. (last name, first name,gender,race).
last name first name gender race
abbott leslie b f white
abbott peggy s f white
abernathy rebecca r f white
abidin antoinette f white
able shaylene n f white
abrahante adneris e f white
abrams melanie a f white
abreu adriana f white
acevedo angela n f white
@graydon
graydon / country-bounding-boxes.py
Created April 23, 2014 00:03
country bounding boxes
# extracted from http//www.naturalearthdata.com/download/110m/cultural/ne_110m_admin_0_countries.zip
# under public domain terms
country_bounding_boxes = {
'AF': ('Afghanistan', (60.5284298033, 29.318572496, 75.1580277851, 38.4862816432)),
'AO': ('Angola', (11.6400960629, -17.9306364885, 24.0799052263, -4.43802336998)),
'AL': ('Albania', (19.3044861183, 39.624997667, 21.0200403175, 42.6882473822)),
'AE': ('United Arab Emirates', (51.5795186705, 22.4969475367, 56.3968473651, 26.055464179)),
'AR': ('Argentina', (-73.4154357571, -55.25, -53.628348965, -21.8323104794)),
'AM': ('Armenia', (43.5827458026, 38.7412014837, 46.5057198423, 41.2481285671)),
@marvin
marvin / client.py
Created December 17, 2012 13:50
simple python client/server socket binary stream
import socket
HOST = 'localhost'
PORT = 9876
ADDR = (HOST,PORT)
BUFSIZE = 4096
videofile = "videos/royalty-free_footage_wien_18_640x360.mp4"
bytes = open(videofile).read()
@jgomezdans
jgomezdans / modis_map.py
Created May 8, 2012 15:26
Plotting MODIS data with Matplotlib's Basemap
from osgeo import gdal
from osgeo import osr
import matplotlib.pyplot as plt
import numpy as np
from mpl_toolkits.basemap import Basemap
def reproject_dataset ( dataset, \
pixel_spacing=0.463/100., \
wkt_from="+proj=sinu +R=6371007.181 +nadgrids=@null +wktext", epsg_to=4326 ):
@aheckmann
aheckmann / storeImgInMongoWithMongoose.js
Created April 17, 2012 19:14
store/display an image in mongodb using mongoose/express
/**
* Module dependencies
*/
var express = require('express');
var fs = require('fs');
var mongoose = require('mongoose');
var Schema = mongoose.Schema;
// img path
import numpy as np
def symdirichlet(alpha, n):
v = np.zeros(n)+alpha
return np.random.dirichlet(v)
def exp_digamma(x):
if x < 0.1:
return x/100