Dashboards & Visualizations

Plot a map location using Maidenhead Grid Square

kashifqau
Explorer

Hello,

I am working with Radio data, which contains location in Maidenhead Grid Square format rather then latitude and longitude.

I want to know about how can I plot maps by using Maidenhead Grid Square

OR

How can I convert Maidenhead Grid Square to latitude and longitude using formula? (If I make the transformation into latitude and longitude that can be plotted further using Splunk)

Muhammad Kashhif

Labels (1)
Tags (1)
0 Karma
1 Solution

kashifqau
Explorer

I found a python library with name "pyhamtools", from where I extracted the formula for the conversion of Maidenhead Grid Square to latitude longitude and have implemented in Splunk as below

index="wsprindex" sourcetype="wsprsourcetype" | eval first=substr(grid,1,1) | eval second=substr(grid,2,1) | eval third=substr(grid,3,1) | eval fourth=substr(grid,4,1) | lookup asciitable.csv symbol As first OUTPUTNEW code as firstcode |eval valueA = "A" | eval value0 = "0"| lookup asciitable.csv symbol As second OUTPUTNEW code as secondcode | lookup asciitable.csv symbol As third OUTPUTNEW code as thirdcode | lookup asciitable.csv symbol As fourth OUTPUTNEW code as fourthcode | lookup asciitable.csv symbol As valueA OUTPUTNEW code as codeofA | lookup asciitable.csv symbol As value0 OUTPUTNEW code as codeof0 | eval longitude = ((((firstcode - codeofA) * 20) - 180) + ((thirdcode - codeof0) * 2)) | eval latitude = ((((secondcode - codeofA) * 10) - 90) + (fourthcode -codeof0)) | geostats longfield=longitude, latfield=latitude count by grid

(grid is the field, which contains Maidenhead Grid Square values and asciitable.csv is a lookup table which contains ascii values of alphabets and letters)

View solution in original post

0 Karma

kashifqau
Explorer

I found a python library with name "pyhamtools", from where I extracted the formula for the conversion of Maidenhead Grid Square to latitude longitude and have implemented in Splunk as below

index="wsprindex" sourcetype="wsprsourcetype" | eval first=substr(grid,1,1) | eval second=substr(grid,2,1) | eval third=substr(grid,3,1) | eval fourth=substr(grid,4,1) | lookup asciitable.csv symbol As first OUTPUTNEW code as firstcode |eval valueA = "A" | eval value0 = "0"| lookup asciitable.csv symbol As second OUTPUTNEW code as secondcode | lookup asciitable.csv symbol As third OUTPUTNEW code as thirdcode | lookup asciitable.csv symbol As fourth OUTPUTNEW code as fourthcode | lookup asciitable.csv symbol As valueA OUTPUTNEW code as codeofA | lookup asciitable.csv symbol As value0 OUTPUTNEW code as codeof0 | eval longitude = ((((firstcode - codeofA) * 20) - 180) + ((thirdcode - codeof0) * 2)) | eval latitude = ((((secondcode - codeofA) * 10) - 90) + (fourthcode -codeof0)) | geostats longfield=longitude, latfield=latitude count by grid

(grid is the field, which contains Maidenhead Grid Square values and asciitable.csv is a lookup table which contains ascii values of alphabets and letters)

0 Karma

niketn
Legend

@kashifqau, please accept your own answer to mark this question as answered!

____________________________________________
| makeresults | eval message= "Happy Splunking!!!"
0 Karma

crofrog
New Member

What is ascitable.csv?

0 Karma

to4kawa
Ultra Champion
{
            locator = locator.Trim().ToUpper();
            if (Regex.IsMatch(locator, "^[A-R]{2}[0-9]{2}$"))
            {
                LatLng ll = new LatLng();
                ll.Long = (locator[0] - 'A') * 20 + (locator[2] - '0' + 0.5) * 2 - 180;
                ll.Lat = (locator[1] - 'A') * 10 + (locator[3] - '0' + 0.5) - 90;
                return ll;
            }
            else if (Regex.IsMatch(locator, "^[A-R]{2}[0-9]{2}[A-X]{2}$"))
            {
                LatLng ll = new LatLng();
                ll.Long = (locator[0] - 'A') * 20 + (locator[2] - '0') * 2 + (locator[4] - 'A' + 0.5) / 12 - 180;
                ll.Lat = (locator[1] - 'A') * 10 + (locator[3] - '0') + (locator[5] - 'A' + 0.5) / 24 - 90;
                return ll;
            }
            else if (Regex.IsMatch(locator, "^[A-R]{2}[0-9]{2}[A-X]{2}[0-9]{2}$"))
            {
                LatLng ll = new LatLng();
                ll.Long = (locator[0] - 'A') * 20 + (locator[2] - '0') * 2 + (locator[4] - 'A' + 0.0) / 12 + (locator[6] - '0' + 0.5) / 120 - 180;
                ll.Lat = (locator[1] - 'A') * 10 + (locator[3] - '0') + (locator[5] - 'A' + 0.0) / 24 + (locator[7] - '0' + 0.5) / 240 - 90;
                return ll;
            }
            else if (Regex.IsMatch(locator, "^[A-R]{2}[0-9]{2}[A-X]{2}[0-9]{2}[A-X]{2}$"))
            {
                LatLng ll = new LatLng();
                ll.Long = (locator[0] - 'A') * 20 + (locator[2] - '0') * 2 + (locator[4] - 'A' + 0.0) / 12 + (locator[6] - '0' + 0.0) / 120 + (locator[8] - 'A' + 0.5) / 120 / 24 - 180;
                ll.Lat = (locator[1] - 'A') * 10 + (locator[3] - '0') + (locator[5] - 'A' + 0.0) / 24 + (locator[7] - '0' + 0.0) / 240 + (locator[9] - 'A' + 0.5) / 240 / 24 - 90;
                return ll;

https://unclassified.software/files/source/MaidenheadLocator.cs

You can calculate

0 Karma

sandyIscream
Communicator

I am guessing you want the formula to conver Maidenhead Grid square to latitude and longitude. if yes then you can go to the below link and check for it.

https://ham.stackexchange.com/questions/221/how-can-one-convert-from-lat-long-to-grid-square

I believe this will help you convert them to latitude and longitude. Then save this formula as macro in your search head, so you don't need to write it again n again for future purpose. You just have to call the macro.

0 Karma

kashifqau
Explorer

Thank you for your reply Sandylscream,
I am looking for an opposite formula of what you posted. The posted formula gets latitude/longitude as input and converts it into Maidenhead where I am looking for one to input Maidenhead and provides me with latitude/longitude
\

0 Karma
Get Updates on the Splunk Community!

Welcome to the Splunk Community!

(view in My Videos) We're so glad you're here! The Splunk Community is place to connect, learn, give back, and ...

Tech Talk | Elevating Digital Service Excellence: The Synergy of Splunk RUM & APM

Elevating Digital Service Excellence: The Synergy of Real User Monitoring and Application Performance ...

Adoption of RUM and APM at Splunk

    Unleash the power of Splunk Observability   Watch Now In this can't miss Tech Talk! The Splunk Growth ...