New Feature Opens Door to Custom Models for Mapping and Valuing Nature's Benefits
This is the second in a series of blog-style posts sharing software-related advances at NatCap. Check out the first post about our new Natural Capital Project Data Hub, and stay tuned for more releases in the coming year making it easier and quicker for decision-makers to use natural capital data for a more sustainable and prosperous world.
The Natural Capital Project (NatCap) software team is excited to announce that our ecosystem service modeling platform, InVEST, now supports plugins! This feature makes it possible for people to develop their own custom, InVEST-like models that can be run in the InVEST Workbench – the user interface for our models – and share them with others.
Why did we develop this feature?
Over the years, we’ve gotten many requests for new models, or variations on existing models, both from inside and outside of NatCap: “I wish [X] was an InVEST model” or “I want to run the InVEST coastal vulnerability model but change this one step.” The current way to change a core model or add a new core model involves a slow approval process to ensure both high-quality software and scientific credibility. It also requires a commitment to ongoing science and software support for the model. It is a major benefit for developers to be able to focus on their model and not worry about maintaining the underlying desktop application or distributing it across multiple operating systems. With plugins, we wanted to allow scientists and developers to get the benefits of an “InVEST model” for their projects without having to go through the core model approval process. Unlike the core models, a plugin is not “official,” i.e., not reviewed or specifically maintained by NatCap.
We also believe there is value in having a shared interface for ecosystem services models. Seeing different ecosystem service models, or different versions of the same model, side-by-side in the workbench facilitates running them together and comparing them. The data validation provided by InVEST is also very useful for projects that don’t have enough resources to develop this independently.
NatCap wants to encourage growth of the broader open-source and scientific community around InVEST. Plugins provide a chance for others in the community to share and test innovations in modeling and analysis without NatCap itself being a bottleneck, and a way of developing customized workflows for different use cases, again without being constrained by the limited capacity of the NatCap software team.
How did we design it?
Because we started from scratch, we were able to design a framework that would be flexible to support many different use cases, including ones we haven’t thought of yet – that’s kind of the whole point! And we wanted to keep it simple and easy to make use of.
InVEST models are written in Python, which is a very popular programming language. InVEST already has a Python API (an interface that allows software components to interact with each other) that is used by some of our more advanced users. So we decided that a plugin would be a Python package. This is a very flexible design that allows the plugin to do pretty much anything, and it should be accessible to anyone with some Python programming experience.
And fortunately for anyone who has a model already written in a language other than Python, the plugin can simply “wrap” that existing tool. No need to rewrite it!
What do we have planned for the future?
- A plugin registry where people can share plugins they’ve created and discover plugins created by others
- Additional plugin features that will be developed and prioritized according to feedback we receive
- A growing open-source ecosystem services modeling community where external contributors participate in developing plugins and InVEST itself
Example plugins
The following are some examples of plugins maintained by the NatCap team:
See below for more details on plugins and why they might be useful to model developers! The following can also be found in the Plugin Developer’s Guide.
What is a plugin?
Conceptually, an InVEST plugin is a model that maps and quantifies ecosystem services. Like the core InVEST models, it takes in data of various formats (usually including some geospatial data), processes that data, and produces output files that contain the results. Unlike the core models, a plugin is not “official,” i.e., not reviewed or maintained by NatCap. Plugins may be developed, used, and distributed totally independently of the natcap/invest repo and the Natural Capital Project.
In a technical sense, an InVEST plugin is a Python package that conforms to the natcap.invest plugin API. This makes it possible to run the plugin from the InVEST Workbench and the invest command line tool. The plugin can execute any arbitrary code when it runs. Commonly the ecosystem services model logic will be implemented in the Python package, but it could also invoke another software tool - for example, if your model is already implemented in another language, you could develop the plugin as a Python wrapper for it.
Why make a plugin?
A plugin can be run in the InVEST Workbench, which provides a graphical interface where a user can enter the model inputs, run the model, watch its progress, and access the results. All the necessary information to display the model in the workbench is pulled from the plugin Python package - no frontend development needed. This is handy when resources are too limited to develop a separate GUI for a project. It is a major benefit for developers to be able to focus on their model and not worry about maintaining a desktop application or distributing it across multiple operating systems.
The data validation component of InVEST is also very useful for projects that don’t have enough resources to develop this independently. The plugin API requires that data inputs are rigorously specified. Before running a model, InVEST validates that the provided data meets all of the requirements, and provides helpful feedback if it does not. This prevents a lot of trouble with invalid data.
Even if resources were unlimited, we think there is value in having a shared interface for ecosystem services models. Seeing different ecosystem service models, or different versions of the same model, side-by-side in the workbench facilitates running them together and comparing them.
The plugin API is a useful framework in which to think of developing a model. This framework is helpful when tackling the task of turning a “model” (which may exist in the form of mathematical equations, scripts, or other software) into a well-documented, reusable, distributable software tool. Implementing the plugin API requires attention to many details that are easily overlooked when writing a basic script. Going through the process of developing a model into a plugin will help to catch bugs and identify assumptions that may exist in your math or your code.
Emily Soth is a software developer at the Stanford-based Natural Capital Project. She led the development of the new plugins feature along with Software Team Lead Doug Denu. Elana Kimbrell is director of communications at NatCap.
The Natural Capital Project is based out of the Woods Institute for the Environment in the Stanford Doerr School of Sustainability and the Department of Biology in the Stanford School of Humanities and Sciences.
Media contact: Elana Kimbrell, elanak@stanford.edu