Javascript, NodeJS, and ArcGIS

Python may be the most popular programming language for geospatial work; however, JavaScript's usefulness continues to grow at a fast pace. In this post, we explore how JavaScript and NodeJS can be used with the ArcGIS platform.

A Changing Landscape

Esri’s ArcGIS Online and ArcGIS Enterprise have become a mainstay of GIS.  For those who have been in industry for more than 10 years, you have most likely witnessed the transition from desktop GIS to Web GIS.  In the early days, GIS staff were thrust into the world of Web GIS and welcomed it whole heartedly.  For many of us (like myself), the shift opened exciting opportunities to connect people to your GIS via the Web.  Attend any conference with seasoned GIS professionals, and you’re sure to hear stories (good or bad) about the ‘early days’ of ArcIMS, ArcGIS Viewer for Flex (RIP Flash), and Silverlight.  For me, the most fundamental shift was when Esri released the Esri JS API.  Since that moment, I have never stopped learning about JavaScript, the web, and ways to become more efficient with programming.  These have been exciting times, to say the least!  

In one of our recent blog articles, we outlined the reason you might use Esri’s Cloud vs a Custom Stack.  When building a custom stack, there are endless opportunities for you to build web applications to best fit your end user’s needs.  If you are an Esri customer, you likely have seen the advancement of application ‘templates’ that no longer require web applications be built from the ground up.  In the Esri ecosystem, customization and configuration have replaced the complexities of coding.  When custom needs arise, there are still boundless opportunities for building applications with Esri’s ever advancing JS API.  However, in many cases, you would be hard pressed to justify not using one of Esri’s out of the box application templates.

As a GIS developer, you might have mixed feelings (I did) about your love of development being replaced by these new shiny out of the box templates (shakes fist at cloud).  Of course, there will always be a need for building custom web applications and user experiences in the Esri ecosystem, but the landscape has indeed changed.  In fact, what Esri has done, is free up our time for doing other things and open a whole new door of opportunity.  Esri’s entire platform is exposed as an API that now allows developers to automate workflows, administer users and content, and innovate.  A new path of learning now exists.

Programming in ArcGIS

The Esri ecosystem does not exist as software products that are completely isolated, but rather are comprised of a system of systems.  Content in ArcGIS Online serve as a central nervous system that inform (and are informed) by the entire geospatial infrastructure.  For example, IoT devices collecting data can update ArcGIS Feature Services which feed into ArcGIS Dashboards that are embedded into Story Maps.  At the same time, machine learning models running on Python in ArcGIS Notebooks might be creating derivative products that are consumed by GIS Analysts using ArcGIS Pro.  All this to basically say… everything is connected!  

Python has been fully embraced by Esri, and is the scripting language of choice across much of the ArcGIS platform.  ArcGIS Notebooks (built on Jupyter Notebook) only have kernel support for Python, not R or any other popular data science languages.   The ArcGIS API for Python is a great way for Python developers to interact with the ArcGIS platform.  The documentation provides guides and workflow examples that allow administrators, data scientists, and content publishers to programmatically interact with the platform and automate their work.

What some people may not know, is that the Python API is just an abstraction layer built on top of the lower-level ArcGIS REST API. The ArcGIS REST API exposes HTTP endpoints, providing a programming language agnostic method of interacting with the ArcGIS platform.

NodeJS and JavaScript

The Esri JS API was (and still is) the preferred library for building web applications in the Esri ecosystem.  With the decline (and ultimate discontinued support) of Flash, Esri developers adopted JavaScript along with the entire web developer community. I mention this, not only because I love JavaScript, but because there are many GIS developers who have accumulated a vast working knowledge of JavaScript (and all of its quirks).  The downside of JavaScript, is that it could only run within the browser.  Server-side developers used other languages (.NET, PHP) to run code outside of the browser.  Node.JS was born as a direct result of this limitation.  It allowed JavaScript to be run outside of the browser as a standalone application.

Both Node.JS and JavaScript run on Chrome’s V8 JavaScript engine.  It takes your JavaScript, and converts it to machine code that your computer can run without needing to interpret it first.  Since Node.JS runs outside of the browser, what you can do with JavaScript is limited only by your imagination.  At CartoLab, Node.JS is used in everything from performing ETL to serving highly scalable API’s.  We use it extensively to extend the ArcGIS platform and it even powers our recent product, Snapshots, for adding backups and version control to your ArcGIS content.  In a recent blog article, I outlined how we used Node.JS to build faster geoprocessing API’s for ArcGIS Enterprise.

In 2007, Jeff Atwood famously coined the phrase “Any application that can be written in JavaScript, will eventually be written in JavaScript”.  For better or worse, this revelation is quickly becoming a reality.  In my personal opinion, it’s for the better.

NodeJS and ArcGIS

Although I’m an advocate for working in multiple programming languages as a form of cross-training, I’m also a staunch defender of being expertly proficient in at least one language.  As a GIS Developer, I believe JavaScript is that language to master.  Being a proficient Node.JS developer also lends itself to being a good web developer.  At CartoLab, being a full-stack developer requires a good understanding of JavaScript on both the server and the client.  In many cases, we build software that is isomorphic, meaning the same JavaScript runs on both the server and the browser.  Proficiency across the stack produces better software with the added benefit of increased developer happiness.  

If you look across the developer resources for the ArcGIS Platform, you will not see Node.JS referenced much.  Python takes the prize here, and for good reason.  The community has adopted Python as the de facto language for ArcGIS Desktop and ArcGIS Pro programming for years.  It has well documented API’s and is treated as a first-class citizen in their support / training offerings.  Node.JS is not completely left out.  In January 2021, Esri officially supported an open source project called ArcGIS REST JS.  ArcGIS REST JS, much like the ArcGIS API for Python, is an abstraction library for the ArcGIS REST API.  It provides an interface for using JavaScript (browser and Node.js) to interact with the ArcGIS Platform.  Personally, I find working directly with the ArcGIS REST API with Node.JS to be more productive, but others may enjoy the benefits that the ArcGIS REST JS library offers.

Browse through Esri’s other open source projects, and you’ll quickly see many other popular projects leveraging JavaScript (solution.jsKoopJS).  If you’re looking for becoming a better developer and have an interest in adopting Node.JS as part of your operations, I say go for it. 

With NodeJS, you can do everything that Python can do in the ArcGIS ecosystem, and for me… do it with a bigger grin!

Previous
Previous

Secure ArcGIS Feature Service Webhooks with Node.JS and Twilio

Next
Next

ESRI Cloud vs A Custom Geospatial Stack