Recently I came across some R tutorials about creating interactive maps and I decided to build my own. I like the Google Maps interface design, so I wanted to make it look similar, i.e. the map across the entire browser window and the user controls visible in panels that change design while using them. As data overlay I wanted to use production data of existing oil wells.
Web App Requirements
Showing the location of oil wells on a map is great, but I wanted to add some additional data and user inputs:
- Show individual well information upon selecting it
- Show well clusters
- Indicate production amount by varying well marker size and color
- Show total number of wells and total production within the visible map
- Change color scheme
- Show or hide the legend
Data Source and Data Munging
While looking for old well production data, I found some at the Kentucky Geological Survey Website. After using their search function, I chose to download the 2014 oil production data file. It comes in Excel and has approx. 22,000 rows. It also shows production for each month per well; much more information that I require for this app.
I reduced the file size by using only the top 500 rows and by deleting most of the columns; I added a new feature, the total yearly production per well, by summing up all monthly production data before deleting these columns, too. Below is a sample of the data set.
The complete file can be viewed here.
For brevity reasons I will not go through the source code but focus on the features of the web application. You can download the source code from my Github Page.
Using the App
When running the app in the browser, the default controls are set, e.g. the default color scheme is set (brown = low production, green = high production) and no clusters are shown, only individual wells. The control panel also shows the number of wells (500, as per data set) and the total yearly production.
When zooming in, more individual wells are getting visible. Because less wells are now visible, the well number has decreased to 256 and the total production is less, too.
When switching on the cluster option, individual wells are aggregated into cluster markers that are color coded and also show the number of wells that are inside the cluster. When hovering the mouse over a cluster, the map shows the cluster area in blue.
When clicking on a cluster, the map will automatically zoom into the cluster area and split into smaller clusters. To view individual wells again, switch off the cluster option. Changing the color scheme will interactively change the color coding of the wells, as well as the legend.
You can download the source code and run your app from your R environment, or run it from Shinyapps.io (links are below). The data can be easily explored by using such visualizations, and you might discover anomalies and other interesting things.
Things to improve
The list to improve this app is long! I suggest you dive in and try the following:
- Add a production histogram into the control panel
- Count and display how many wells are not producing at all
- Color code not producing wells better
- Add more data points