Morsel is a Python & Java library that generates sampling strategies for parameterised 2D space. This library currently supports several methods of sampling quadralateral shapes defined by x and y coordinates, including:
- random sampling: generating N random points inside a quad
- stratified systematic sampling: generating an N by N grid inside the quad and returning the centerpoint of each stratum
- stratified random sampling: generating an N by N grid inside the quad and selecting M random points inside each stratum
In addition to generating samples, Morsel contains tools that can be used to generate an efficient path that visits every sample point.
from morsel.entities import Vector, Triangle, Quad
from morsel.quad_field import Field
sample_field = Field(
Vector(0,0),
Vector(10.9,0),
Vector(10,10),
Vector(0,10))
# Generate a list of Vector objects containing x and y coordinates of samples
simple_random_samples = sample_field.get_simple_random_samples(7)
Field demo = new Field(
new Vector(0.0, 0.0),
new Vector(0.0, 10.0),
new Vector(10.0, 10.0),
new Vector(10.0, 0.0));
demo.generateRects(2, 2);
ArrayList<Vector> samples = demo.getSamples();
- stratified sampling of irregular shapes - Voronoi/Decomposition
- shortest path algorithm to allow for efficient sampling of generated points
- RESTful api wrapper for improved integration
- python support
Stratified soil sampling using an android application: