This repository demonstrates how to build a C library that is included in the module distribution.
To build the C library:
python setup.py build_clib
#!/usr/bin/env python | |
import numpy | |
try: | |
from osgeo import gdal | |
except: | |
import gdal | |
try: | |
from osgeo import ogr | |
except: |
#!/bin/bash | |
# usage: export_to_csv.sh <database.sqlite> | |
sqlite3 $1 "SELECT tbl_name FROM sqlite_master WHERE type='table' and tbl_name not like 'sqlite_%';" | while read table; do | |
echo $table | |
sqlite3 $1 <<! | |
.headers on |
#!/usr/bin/env python | |
''' | |
A simple geoprocessing task: for each feature in layer1, find the distance to | |
all features in layer2 that are within 5 map units | |
''' | |
import fiona | |
from shapely.geometry import shape | |
from shapely.ops import nearest_points | |
import time |
''' | |
A simple model of a reservoir, which supplies water to a demand center and can | |
request water from another supply. The objective is to minimise the deficit in | |
supply to the demand center, then to minimise the difference between the | |
reservoir level at the end of the timestep and the target level. | |
variables: | |
- volume demanded by reservoir | |
- deficit between target volume and final volume | |
- volume supplied by reservoir |
/* | |
A very simple example using lp_solve, with the following problem: | |
Objective function | |
min: -9 C1 -10 C2; | |
Constraints | |
R1: -0 <= +C1 <= 10; | |
+C1 -C2 = 0; |
class CollectionLRU(fiona.Collection): | |
"""Wrapper for Fiona Collection that provides LRU read caching | |
""" | |
def __init__(self, *args, **kwargs): | |
fiona.Collection.__init__(self, *args, **kwargs) | |
self.cache = LRU(200) | |
def __getitem__(self, key): | |
try: | |
feature = self.cache[key] | |
except KeyError: |
# -*- coding: utf-8 -*- | |
from PySide import QtCore, QtGui | |
def wrapper(fn): | |
print('inside wrapper...') | |
def wrapped(*args, **kwargs): | |
print('inside wrapped!') | |
fn(*args, **kwargs) | |
return wrapped |
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) |