Geoscience Reference
In-Depth Information
Now complete, we can test the program by specifying the input CSV file (xy.csv),
the output format (Spatialite), the output name (test) and the EPSG code (4326) (i.e.
for a latitude/longitude projection). Once complete, we can use ogrinfo to check
t he contents of the database and visualize the data (Fig. 14.6 ).
python dm_createxy.py -i xy.csv -f SQLite -o test -s 4326
5 coordinates added to Spatialite (test.db)
ogrinfo -so -al test.db
INFO: Open of 'test.db'
using driver 'SQLite' successful.
Layer name: xylayer
Geometry: Point
Feature Count: 5
Extent: (-1.220000, 45.300000) - (4.500000, 48.200000)
Layer SRS WKT:
(unknown)
FID Column = OGC_FID
Geometry Column = GEOMETRY
14.2.6 Point-Based Sampling Frames
Statistical sampling and surveying forms an integral part of many scientific disci-
plines from ecology to forestry and remote sensing. Sampling is an essential part of
these fields since a complete census of a population is rarely possible due to time and
cost constraints. Consequently, a design-based inventory is used as a means of draw-
ing an inference about a population. There are different types of sampling approaches
that include systematic, random and transect samples. Furthermore, these sampling
approaches can also be stratified to divide the population into homogeneous strata
(groups) for more efficient field work and reduce estimation errors. Further informa-
tion on sampling and designing surveys can be found in Scheaffer et al. (1990).
Consequently when a sample needs to be drawn from a population for either an
inventory or as part of a validation exercise, it is necessary to generate a point-based
sampling frame. In the next example we will present a Python based OGR example
that will generate either a random or systematic sample of points within a spatial
extent defined by a bounding box.
In the first section, we import the Python libraries that are required for the pro-
gram, which include the argparse, random, ogr and osr . Note that the path
and version of Python may differ on your computer.
#!/usr/bin/python2.6
import random, sys, argparse
from osgeo import ogr, osr
We start by defining a main function that accepts a number of command line
arguments that are passed to the program. These include the type of sampling frame,
 
 
Search WWH ::




Custom Search