Blending R’s Hidden Gem and WebGIS Development: A Live Case
Originally, our app would have been made custom like last year’s app, except with more emphasis on the User Experience (UX) and User Interface (UI). However, we took a different route and decided to have it written in pure R. Those of you that don’t know the programming language, R is mainly a statistical programming language. This may sound far-fetched, but thanks to dedicated programmers and large open source community, R has come a long way and has now added another dimension – app development or in their terms “Shiny.” Shiny is the core library package to download with tremendous amount of documentation and galleries to show despite its relative infancy. Although it’s not exactly like Esri’s web-app builder where you plug and chug functional graphics and download, the framework of Shiny is similar to it…only with a lot of tinkering.
Critical Components of Shiny
At the bare bones, you can technically make a static Shiny app in less than 10 lines of code. Now, Shiny has fairly steep learning curve, especially to those that never used R. But have no fear, with a little dedication and finding the right sources, you can pick it up!
To develop a Shiny app, you need to have two functions – the UI and server. Like the definition, UI focuses on the web page aesthetics and is where you can maximize the UX. The aesthetics of the page are pre-written in Bootstrap, a golden interactive CSS template that saves web developers from insanity. An example in our app is implementing “absolutePanel” and inserting inside the flexible panel a “sliderInput” and “selectInput”. This gives the user the liberty to drag the panel wherever they want on the screen and select and slide based on the given choices. What’s even cooler, is you can improve the aesthetics of the UX by injecting your own code, which I’ll mention in the next section.
Thinking Outside the Box Here – Apply ArcGIS API
For simplicity and organizational purposes, we created separate pseudo CSS and JS files as R scripts and injected them to Shiny. The main API we used was Leaflet due to familiarity (R also has a leaflet library) and to keep the app lightweight to maximize rendering speed. We intended to inject the ArcGIS JS API into our app (i.e. geolocator and geocoder widget); however, we didn’t have enough time to do it and mixing APIs together can get messy quickly, which requires intensive back-and-forth testing and that takes up a lot of time.
Was it worth it?
Absolutely! Just imagine what you can do if you integrate Shiny via R and the ArcGIS JS API together – what kind of app you can make! You mix both open source and proprietary together. Lastly, when finished you can create a free Shiny account and host the app on their server for free (25 hours usage per month). There are additional plans at a bargain price, if you think people will go over the 25 hour limit. In the end, it’s up to you of what you make out of it.