Helium Explorer Data Analysis with Python
Previous Coverage Map — Helium Explorer article:
- What are the preprocessing steps in image processing?
- How do you extract data from the Helium Explorer using Selenium and Pyautogui?
- How do you iterate through different cities on Helium Explorer using Selenium?
- Learn the preprocessing steps in image processing on Helium Explorer.
- Recognize the different parameters passed through to Pyautogui’s screenshot() function.
- Learn how to iterate through multiple cities located on the Coverage Map.
End Sample Size
To use the 13 cities from our last article as the end sample size, let’s go ahead and collect their URLs from the address bar of our browser.
The URLs of all 13 cities in our end sample size are:
Now that we have all of the URLs in a list, we can focus on how to use Pyautogui to take screenshots of the Helium Coverage Map.
Pre-requisites for running Pyautogui with Python
The easiest way to install Pyautogui on a Python environment is through the installer pip.
pip install pyautogui
How to take screenshots using Pyautogui with Python?
Once you have completed the pre-requisites section, you’re ready to start extracting image data from the Helium Coverage Map.
Step 1: First import all the libraries we will be using in this Python script(lines 2–6).
Step 2: Initiate an instance of Google Chrome and access Helium Explorer. Before we can open the Helium Explorer on Chrome, we need to access a web driver that Selenium will use to interface with the Chrome browser. The options attribute of the webdriver class allows us to specify how we want the automated Chrome browser to instantiate(lines 8–10).
Step 3: Once you have instantiated the webdriver with the correct options parameters(line 14), you can now access the Coverage Map (line 16). After implicitly waiting for 15 seconds (line 17), go ahead and take a screenshot of the screen and save it as a PNG image(lines 19–20) before exiting from our automated instance of Google Chrome (line 21).
This resulting image is what we’re looking for, but there’s too much clutter on the screen that will make it harder to process large quantities of data if we wanted to.
Thankfully, Pyautogui’s screenshot() function is great to use along with Selenium because you’re able to pull up whichever website you want and screenshot specific dimensions of your screen.
Pyautogui’s screenshot region
Using Pyautogui screenshot’s region() function we’re able to crop down our screenshots to an optimal size(line 27).
The coordinates of the upper left corner of your screen are 0,0 and if you had a 1920×1080 monitor, the coordinates of the lower right corner of your screen would be 1920,1080.
With that information, you should reasonably be able to play with the values to set the region on your own monitor.
Iterating through different cities on Helium Explorer
Since we had the URLs of our sample size in a list called cityurl, we’re able to iterate through all 13 cities using a for loop (line 22). Every screenshot that is taken has the loop iteration stored in its name. Since our sample size is 13 and the index of the first cityurl is , there are going to be 13 screenshots taken named image0 — image12.
In the next article, we will use image processing to find the number of online and offline Helium Hotspots per city, analyze the data, and then use machine learning to draw inferences on HNT token earnings.
Don’t have a Bitcoin wallet yet? Start storing, trading, and earning cryptocurrencies with CoinBase.
Bitcoin Cash donation: qqdxn2rk4ze9q2zp7vmcrlaw9tdqnlf0eu8mumkz3l
Bitcoin donation: 39n7ovER7BUb7qP7rwH8EsZ2gx99JN7mYV
This article is for informational purposes only. It should not be considered Financial or Legal Advice. Contained information may not be accurate at all times. Consult a financial professional before making any major financial decisions