Omniscope Custom Blocks › Preparation/Geo/Gridsquare

Gridsquare

Converts Maidenhead grid square locators (such as IO91wm) to the longitude and latitude of the square's centre.

Preparation › Geo Python

Open the demo in Omniscope Download demo.ioz Sample data: station-log.csv Source on GitHub

Omniscope custom block · Preparation

Grid square locators such as IO91wm, turned into a longitude and latitude you can map, at whatever precision the locator gives.

Python · pandas · nothing extra to install

The problem it solves

Radio logs, contest entries and some field records give a location as a Maidenhead locator: IO91wm rather than a latitude and longitude. A map view needs coordinates, and the conversion, though simple arithmetic, is fiddly to write as a formula: letters and digits alternate, each pair has its own base and square size, and logs mix 4-, 6- and 8-character locators.

The block converts each locator to the centre of the square it names, at the precision the locator gives, and leaves records with a missing or invalid locator in place with empty coordinates, so nothing silently lands in the wrong place.

How it works

What goes in

Station log

12 invented stations with their locator and number of contacts.

Station Locator Contacts
Hilltop relay IO91 14
Harbour club IO91wm 9
Coastal lookout IO80fr52 5
Ridge camp IO93fb34xk 8
Canal workshop IO92ZZ 7
Market square 1

12 rows in the sample file; the six above show each case.

The options

Option Demo setting What it does
Grid square field Locator The field with the locators.
Longitude field Longitude Name of the longitude field to add.
Latitude field Latitude Name of the latitude field to add.

What comes out

Records with coordinates

Station Locator Contacts Longitude Latitude
Hilltop relay IO91 14 -1.00000 51.50000
Harbour club IO91wm 9 -0.12500 51.52083
Moorland portable IO83qn 22 -2.62500 53.56250
Island beacon IO70jc 3 -5.20833 50.10417
Valley school io92jl 6 -1.20833 52.47917
Fen weather post JO02bf 11 0.12500 52.22917
Coastal lookout IO80fr52 5 -3.53750 50.71875
Ridge camp IO93fb34xk 8 -1.55017 53.06016
Ferry station IN69 2 -7.00000 49.50000
Northern outpost IP90jd 4 -1.20833 60.14583
Canal workshop IO92ZZ 7
Market square 1

The block's message: "10 of 12 records located; 1 not a valid locator (empty Longitude and Latitude)". Hilltop relay's 4-character locator puts it at the centre of a square about 139 by 111 km; Ridge camp's 10-character one is within a square about 24 by 19 m.

Where it pays off

Amateur radio: Contact maps

Map the stations in a contest or activity log, sized by number of contacts, from the locators in the log.

Field work: Survey records

Place field observations or equipment readings logged with a grid square on a map, and keep track of which ones need a better location.

Data quality: Checking logged locations

Filter on an empty Longitude to list the records whose locator is missing or mistyped.

Use cases describe typical scenarios and are illustrative; the sample data is invented.

Why do this in Omniscope

How it fits into an Omniscope workflow

Log (File or Database) → Gridsquare → Report (map view)

Feed one record per station, contact or observation with its locator. Add a Record Filter on an empty Longitude to list the records that could not be located.

Try it

  1. Open the demo project (demo.iox on the demo server, or import demo.ioz from this folder): 12 invented stations with their locators.
  2. The question: where are these stations?
  3. Open Gridsquare: Grid square field is Locator; the two field names are left as Longitude and Latitude. Run it.
  4. Look at the output: ten stations have coordinates; Canal workshop (IO92ZZ) and Market square (no locator) have none, and the block's message counts them.
  5. Compare Hilltop relay (IO91, a 2 x 1 degree square) with Harbour club (IO91wm, a subsquare inside it): both are in the same 4-character square, the second placed far more precisely.

Running in Omniscope

Omniscope workflow
Omniscope workflow

The demo project's workflow: the sample data, the block, and a Validate data check on its output.

Language and libraries

Python. It uses pandas (BSD 3-Clause), part of Omniscope's Python environment. Nothing else to install.

Tested

The block is covered by automated tests that run its script against a stand-in for Omniscope's Python API: the sample data, every locator length (checked against an independent implementation), the eight-character example, the corners of the grid, case and spaces, invalid and missing locators, existing fields with the new names, custom field names, bad options, no input, a numeric field, empty input, and 210,000 records.

Reference

Fields it reads

NameTypeWhat it does
Grid square fieldFieldThe text field with the grid square locators, for example "IO91wm" (2 to 10 characters).

Options

NameTypeWhat it does
Longitude fieldTextName of the field to create for the longitude (X) of the square's centre, in decimal degrees. An existing field with this name is replaced.
Latitude fieldTextName of the field to create for the latitude (Y) of the square's centre, in decimal degrees. An existing field with this name is replaced.

Outputs

OutputWhat it holds
LocatedThe input records with the longitude and latitude of each locator's centre added; empty where the locator is missing or not valid.