60 million fields and 27 crops. How we made the OneSoil Map
A month ago we launched the interactive OneSoil Map that provides information about every field in the USA and Europe. Since then numerous media have published articles about the map and we have received hundreds of emails with questions and offers. On Product Hunt, OneSoil map has collected almost 1,500 upvotes; this is unprecedented for an AgTech product. The development of the map took 2 months and now we are ready to reveal the whole process.
What is the OneSoil Map
Like all of the OneSoil products, the interactive map runs on machine learning algorithms and satellite imagery. It contains information on 60 million fields and 27 crops in 44 countries across Europe and the USA. All data is provided for three years. Using the map, one can explore national and regional trends, as well as check the development of a specific field. For example, you can find out how much land was planted with corn in the United States in 2016 (49.1 million hectares) or which Belgium region has the largest amount of wheat fields (Wallonia).
With the map, you can also find out information about an individual field: its size, culture, chart of plant development, and a field score. This measure is calculated by the NDVI index, climatic indicators, and relative field productivity. At any time, you can see how your beet field is doing or check what area your neighbor has planted with legumes last year. In addition to all this, the map is simply beautiful. We added a button called “random beautiful fields”: it transports you between 35+ places around the world, each resembling a piece of abstract art.
The idea of creating such a map appeared in July. We needed a tool that would allow us to demonstrate all our technological capabilities. In August, the whole team began to develop the OneSoil Map more closely.
Data: to collect, to process, to compress
For the OneSoil Map, we used photos shot by the Sentinel-2 satellite of the European Union’s Copernicus programme. A total of 250 Tb of data was processed for Europe and the USA. At the first stage, we preprocessed images: we cleaned the clouds, shadows, snow, and compressed the data down to 50 Tb. Then we started to search for field boundaries and classify cultures with our machine learning algorithms. At the output, we received about 250 Gb of vector maps with field geometries and cultures.
All this data was then transferred to our back-end developer Evgeny Voronets. “For processing data and calculating statistics, I used the PostgreSQL database with the PostGIS extension. After exporting the original vector data, I received a database with about 180 million records on field geometry and another billion of records of additional attribute information for three years”, says Zhenya. Using this amount of data, we calculated statistics, ratings, and determined the popularity of cultures in different regions of the world. All this information is displayed in the left column and hovers on the OneSoil Map.
We wanted to calculate and display agronomic indicators across the field quickly, as well as visualize plant development over the season. For this, we used our own approach to caching and compressing satellite data. This made it possible to reduce the size of the data storage by 100−200 times and obtain field information within 1 second.
We also added a field score to this version of the OneSoil Map. This measure allows you to quickly evaluate a field rating. “Field score is the first step towards yield forecasting, which our team is currently working on, — explains Data Scientist Alexander Kalinovsky. — The map was made in a short period of time, so we had to invent a lot of original solutions “on the go”. But we use all of the findings when we work on our main product, the OneSoil platform.”
Map: to select the format and to prepare the data
In order to visualize the data, we eventually used Mapbox. In general, there are two approaches to creating a map; we tried both. The first is to create a raster map. “In this case, we divide the map into squares, which we then render into pictures and store on the server. The browser loads several images and moves them when the user explores the map,” says front-end developer Dmitriy Kabak. This approach allows you to display all the fields, without the need to filter anything. The end result is beautiful but such a map is static. Plus, raster images weigh quite a lot.
The second approach is to create a vector map. “The browser loads vector data and animates it on the client side. This is how modern Google and Yandex maps work. The data weighs less than the pictures, and allows you to change the design of any element,” explains Dima. The Mapbox service allows creating such a map. In particular, their Mapbox GL library is an open source tool for displaying maps on the web. Amongst other things, Mapbox provides paid data storage service. You can manually upload your data to their servers, and Mapbox will quickly distribute information, ensuring accurate map operation. This is a significant part of the work, and due to the fact that Mapbox takes on this function, our task was significantly simplified.
When working with vector data, you have to remember about a specific constraint: the more information you want to display on the map, the slower everything will work. To solve this problem, we used a Mapbox utility called Tippecanoe. “Based on the algorithms we chose, it determines which fields would be visible and which would not at a certain zoom. Then it would remove invisible vector objects from the layer,” explains Zhenya. In total, Tippecanoe has more than 20 filtering algorithms. We tried them all and selected a couple of basic ones.
At the next step, we compressed the data to 50 gigabytes using Mapbox mbtiles technology, and then uploaded it to the company’s servers. The OneSoil Map has been further accelerated by the use of the Next JS framework, which performs server-side rendering of the page. Most applications in the modern world are rendered entirely on the client side so that when you open a window in your browser, an empty HTML page and a script that loads all the information are displayed. “Next JS framework does everything on the server, and this makes the work of the application faster for the client,” explains Dima.
Map: to visualize data and to come up with a “magic button” the night before the release
According to product designer Ivan Uvarov, Mapbox was quite a discovery for him. “It simplified the task because I was able to visualize the data without the need for a front-end developer,” he explains. It may seem that it is easy to color the fields in the Mapbox interface, but there are a lot of nuances. “We have 27 crops, and choosing colors for them was not easy. Contrasting colors are needed for popular cultures, for less popular ones — less contrasting, and they should all be clearly visible on different zooms,” Vanya explains. There are a lot of nested pages and hovers in the OneSoil Map, and according to the designer, the most difficult part was to come up with the transition logic for different levels. “As if I had a lot of puzzles that needed to be put together into one single picture,” he recalls.
The night before the launch, we realized that for a user it’s interesting to explore the map and the statistics, but there is no urge to share it with others. Therefore, we decided to add the “random beautiful fields” button, which switches users between different places on the planet. The whole team searched for beautiful places, we drew a button in an hour and added it straight away. In the morning we tested it — and launched the OneSoil Map. “It seems to me that this very function gave us all the coverage. Otherwise, no one would have paid attention to the fact that the fields are similar to abstract works of art,” says Ivan. This feature was appreciated by the Russian designer Artemy Lebedev. After he had posted about the OneSoil Map in his social networks, a bunch of new users decided to check out our map. At the peak of attendance, the map was simultaneously explored by 1,300 people. Never underestimate the power of last-minute decisions!
We added yet another function to the OneSoil Map after the release. We knew that sometimes field and crop recognition isn’t precise enough, so feedback from the users allows us to improve our algorithms. When farmers began to report errors in crop recognition (“I grow sunflower on the field, and you indicate corn here”), we added a button that sends us notifications about false recognition. We collect this information and will use it to improve the accuracy of our crop recognition models.
Wrap up
During development, the OneSoil Map concept changed a lot. At first, we planned to make a simple visualization of fields and cultures around the world. The final product turned out to be much more complex: there are dozens of statistics, ratings, and view modes. After the release, we received hundreds of emails from investors, funds and scientific researchers. Also, we will use the found technological solutions, such as the Next JS framework and the Tippecanoe utility, in further work on the OneSoil platform.
We are the first ones to map all the fields in the USA and Europe covering the last three years. “The data we received is unique. We already know more about fields than any other company or state. The statistics we obtain with machine learning algorithms are often more accurate than the ones that are collected manually. We made the first step towards the automatic recognition of fields globally. Achieving this is our plan for the near future,” sums up Alexander Yakovlev, Head of Product.
Thank you for reading! If you haven’t already, check out OneSoil Map.
First time hearing about OneSoil? Visit our website, let’s get acquainted! 😃