Skip to content

Bounds check filter

David Megginson edited this page Aug 25, 2015 · 1 revision

The hxlbounds utility reads a HXL-encoded dataset that includes latitude and longitude information (#lat_deg and #lon_deg), and reports any rows that don't fall inside the specified boundary. The boundary is a GeoJSON shape file that can contain multiple contours (such as islands, excluded enclaves, etc.).

There are many tools to convert other formats (such as ArcGIS) to GeoJSON, including this online converter.

Usage

usage: hxlbounds [-h] -b BOUNDS [-c tag,tag...] [infile] [outfile]

Perform bounds checking on a HXL dataset.

positional arguments:
  infile                HXL file to read (if omitted, use standard input).
  outfile               HXL file to write (if omitted, use standard output).

optional arguments:
  -h, --help            show this help message and exit
  -b BOUNDS, --bounds BOUNDS
                        GeoJSON file containing the boundary information.
  -c tag,tag..., --tags tag,tag...
                        Comma-separated list of column tags to include in
                        error reports

Output

Output consists of a series of error messages, like these:

out of bounds (row 168) ['#lat_deg=6.853972355', '#lon_deg=6.853972355', '#loc=Gargar  Clinic', '#adm1=Grand Cape Mount', '#adm2=Garwula']
out of bounds (row 186) ['#lat_deg=7.232787632', '#lon_deg=-11.254961', '#loc=Dasalamu  Clinic', '#adm1=Grand Cape Mount', '#adm2=Porkpa']
out of bounds (row 259) ['#lat_deg=4.7086', '#lon_deg=-7.257292', '#loc=Henriesville City Clinic', '#adm1=Grand Kru', '#adm2=Barclayville']

Examples

Check all rows in a dataset against the GeoJSON boundary data in "LBR.json":

hxlbounds -b LBR.json my-data.csv

Using hxlselect in a processing pipeline to validate only rows in a specific district:

hxlselect -q adm1=Coast | hxlbounds -b Coast-bounds.json