Skip to content

Instantly share code, notes, and snippets.

View sgillies's full-sized avatar

Sean Gillies sgillies

View GitHub Profile
@sgillies
sgillies / build.sh
Last active March 7, 2017 01:45
Building GDAL and friends for inclusion in Rasterio binary wheels
#!/bin/bash
export MACOSX_DEPLOYMENT_TARGET=10.6
export ARCHFLAGS="-arch i386 -arch x86_64"
# GEOS from source.
cd ~/work/geos-3.4.2
./configure CFLAGS="-Os -arch i386 -arch x86_64" CXXFLAGS="-Os -arch i386 -arch x86_64" LDFLAGS="-arch i386 -arch x86_64"
make clean
make
# Copy and paste lines 2-8 (or 4-8 if you didn't delete the miniconda directory) into your terminal, hit return, and check back in 2 mins.
curl http://repo.continuum.io/miniconda/Miniconda-3.7.0-MacOSX-x86_64.sh > /tmp/miniconda.sh
bash /tmp/miniconda.sh -b
export PATH=$HOME/miniconda/bin:$PATH
conda create -n osgeoenv --yes -c https://conda.binstar.org/osgeo gdal
conda install -n osgeoenv --yes -c https://conda.binstar.org/sgillies rasterio
source activate osgeoenv
rio transform --src_crs epsg:4326 --dst_crs epsg:3857 "[-105, 40]"
# Result should be:
# [-11688546.533293728, 4865942.279503176]
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@sgillies
sgillies / README.md
Last active August 29, 2015 14:06
Install Rasterio 0.13.1 on Ubuntu 14.04

I found two problems with installing Rasterio on 14.04

  1. The .c files in Rasterio source distributions (on PyPI) don't compile on 14.04. Generating source for the sdists using Cython 0.20.1 should fix these issue. In the meanwhile, the workaround is to install rasterio from GitHub and use Cython to generate the .c files locally.
  2. Ubuntu 14.04 has no venv for python 3. In a launchpad issue I found that it's a complicated policy issue and there's no fix shipped. The workaround is to create a virtual environment using a python2 virtualenv.

wget the script in this gist, make it executable, and run it to install rasterio and its dependencies on 14.04. After it finishes, type source rasterio/bin/activate to enter the virtual environment with rasterio installed.

Rasterio 0.13.2 will fix #1 above, after which you can just do pip install rasterio==0.13.2.

@sgillies
sgillies / demo.ipynb
Last active August 29, 2015 14:06
Shapely 1.4
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@sgillies
sgillies / README.md
Last active August 29, 2015 14:05
Dateline Crossing Test

A demonstration of the trouble with dateline-crossing features. Without extra info it's unclear whether you mean the longest possible line or the shortest possible line. GitHub has the longer interpretation of my two lines, but I mean the shorter.

The bounding box recommendation in geojson/draft-geojson#42 gives software the extra info needed to interpret the geometries: I mean the geometry that fits in the box that has a SW corner at [170, 10] and a NW corner at [-170, 11].

@sgillies
sgillies / pain.md
Last active August 29, 2015 14:04
Python GDAL/OGR pain points
# Adapted from http://jakevdp.github.io/blog/2012/12/19/sparse-svds-in-python/.
import numpy as np
import matplotlib.pyplot as plt
from time import time
from scipy.sparse import csc_matrix
def sparse_matrix(N1, N2, f, conversion=np.asarray, rseed=0):