Skip to content

Instantly share code, notes, and snippets.

View sgillies's full-sized avatar

Sean Gillies sgillies

View GitHub Profile
@sgillies
sgillies / advanced_rasterio_features.ipynb
Last active April 16, 2024 21:39
Advanced Rasterio features notebook
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@sgillies
sgillies / geo_interface.rst
Last active April 10, 2024 00:26
A Python Protocol for Geospatial Data

Author: Sean Gillies Version: 1.0

Abstract

This document describes a GeoJSON-like protocol for geo-spatial (GIS) vector data.

Introduction

@sgillies
sgillies / geojson-spec-1.0
Created September 21, 2011 21:11
The GeoJSON Specification
================================
The GeoJSON Format Specification
================================
:Abstract:
GeoJSON is a geospatial data interchange format based on JavaScript Object
Notation (JSON).
:Authors:
Howard Butler (Hobu Inc.),
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
from math import sqrt
from matplotlib import pyplot
from shapely.geometry import *
GM = (sqrt(5)-1.0)/2.0
W = 8.0
H = W*GM
SIZE = (W, H)
COLORS = ['#6699cc', '#ffcc33']
@sgillies
sgillies / stats.py
Last active April 26, 2023 08:38
Simple and fancy ways of computing stats of a rasterio dataset
"""Three ways of computing stats of a rasterio dataset."""
import dask.array
import numpy
import rasterio
from rasterio.windows import Window
# Compute mean of entire dataset read into memory. Easiest, but doesn't
# scale for very large datasets.
with rasterio.open(
@sgillies
sgillies / cfrw.py
Last active April 26, 2023 08:37
Rasterio concurrency example
"""Concurrent read-process-write example"""
import concurrent.futures
from itertools import islice
from time import sleep
import rasterio
CHUNK = 100
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@sgillies
sgillies / swap-coords.py
Created March 12, 2012 16:29
Swapping coordinates with Fiona
# Swapping x, y coords.
from descartes import PolygonPatch
from fiona import collection
from itertools import imap
import logging
from matplotlib import pyplot
log = logging.getLogger()
@sgillies
sgillies / config.py
Last active September 29, 2021 08:24
Custom Mapnik config paths
PATH_REMOVE = '/usr/local'
CUSTOM_CXXFLAGS = '-fvisibility-inlines-hidden -DU_CHARSET_IS_UTF8=1'
CUSTOM_LDFLAGS = ''
RUNTIME_LINK = 'static'
INPUT_PLUGINS = 'csv,gdal,geojson,occi,ogr,osm,postgis,python,raster,rasterlite,shape,sqlite'
WARNING_CXXFLAGS = '-Wno-deprecated-register -Wno-redeclared-class-member'
PATH = '../mapnik-packaging/osx/out/build-cpp03-libstdcpp-x86_64-macosx/bin/'
BOOST_INCLUDES = '../mapnik-packaging/osx/out/build-cpp03-libstdcpp-x86_64-macosx/include/boost'
BOOST_LIBS = '../mapnik-packaging/osx/out/build-cpp03-libstdcpp-x86_64-macosx/lib'
BOOST_PYTHON_LIB = 'boost_python-2.7'