Jekyll2023-08-20T00:24:45+00:00https://kb.gg/feed.xmlKevin BoothThoughts, updates, and ramblings of a software engineer and geographer living in Central Texas.QGIS STAC Browser: Past, Present, and Future2019-06-26T00:00:00+00:002019-06-26T00:00:00+00:00https://kb.gg/blog/2019/06/26/qgis-stac-browser<blockquote>
<p>The SpatioTemporal Asset Catalog (STAC) specification provides a common language to describe a range of geospatial information, so it can more easily be indexed and discovered.
A ‘spatiotemporal asset’ is any file that represents information about the earth captured in a certain space and time.</p>
</blockquote>
<p><em>- <a href="https://stacspec.org">SpatioTemporal Asset Catalog Specification</a></em></p>
<h2 id="past">Past</h2>
<p>Earlier this year I started looking for ways to download large quantities of Landsat scenes for my thesis research.
Ideally, there would be an API I could utilize to search for scenes which are within my study areas and study periods.
I quickly found out that such an API doesn’t exist and my only alternative would be to write a script to interact with the <a href="https://earthexplorer.usgs.gov/">EarthExplorer</a> site (far from ideal).</p>
<p>At first I conceded defeat but then I ran into one of <a href="https://twitter.com/opencholmes">Chris Holmes’</a> <a href="https://medium.com/radiant-earth-insights/the-potential-of-spatiotemporal-asset-catalogs-a9323927dc8a">blog posts</a> describing work on a new specification called SpatioTemporal Asset Catalogs.
Immediately I saw the incredible potential in standardizing the way we access spatiotemporal assets.
Imagine being an imagery provider and not having to spend time reinventing the wheel when you want open access to your imagery.
Imagine not having to learn how to navigate a new website for every different source of imagery you want to access.
Imagine being able to automate analysis by building pipelines on top of a standard API.
The possibilities this standard enables really change the way we do geospatial analysis.</p>
<p>I jumped right in and started learning about the spec and introuced myself to the community.
At the time I joined in there was a lot of progress on static catalogs and work on the dynamic catalog API was starting to mature.
There was one thing that hadn’t really been worked on yet and that was tools to interact with the dynamic catalog APIs and download assets.
I asked around and there wasn’t a QGIS plugin started yet so I got to work.</p>
<h2 id="present">Present</h2>
<p>My goal for the QGIS plugin is to have an EarthExplorer-like experience but instead of only being able to search for assets from one provider (USGS in the case of EarthExplorer), you can search and download assets from any provider which provides a STAC API.
I just released version 1.0.0 of the <a href="https://plugins.qgis.org/plugins/stac_browser/">plugin</a> which has just enough functionality to do the basic tasks: search for and download assets.
Although the functionality is very basic it already creates a much better user experience than traditional interfaces.
Below are some comparisons of the flow for searching for and downloading a truecolor Landsat image for a study area in EarthExplorer and in the QGIS STAC Browser plugin.</p>
<h3 id="earthexplorer-2-minutes-and-52-seconds">EarthExplorer (2 Minutes and 52 Seconds)</h3>
<video width="100%" controls="" autoplay="" loop="">
<source src="/assets/stac/comparison_ee.mp4" type="video/mp4" />
Video could not be loaded
</video>
<h3 id="qgis-stac-browser-37-seconds">QGIS STAC Browser (37 Seconds)</h3>
<video width="100%" controls="" autoplay="" loop="">
<source src="/assets/stac/comparison_stac.mp4" type="video/mp4" />
Video could not be loaded
</video>
<h2 id="future">Future</h2>
<p>There’s still a lot of work to be done on this project.
Below is an incomplete list of just a few things which I’d like to get added to the plugin.</p>
<ul>
<li>Add filtering of scenes based on properties</li>
<li>Allow adding APIs which require some sort of authentication</li>
<li>Create a better experience for selecting bands/assets to download</li>
<li>Add unit testing to the codebase</li>
<li>Create documentation</li>
</ul>
<p>If you have any suggestions for new features or find any bugs please create an issue on our <a href="https://github.com/kbgg/qgis-stac-browser">github</a>.
I’m also always looking for new contributors so if you’d like to get started just shoot me an email at <a href="mailto:kevin@kb.gg">kevin@kb.gg</a>.
I’m looking forward to seeing all the cool things everyone does with this plugin!</p>
<p>- Kevin</p>The SpatioTemporal Asset Catalog (STAC) specification provides a common language to describe a range of geospatial information, so it can more easily be indexed and discovered. A ‘spatiotemporal asset’ is any file that represents information about the earth captured in a certain space and time.Vineyard Health after the 2017 California Wildfires2018-05-01T00:00:00+00:002018-05-01T00:00:00+00:00https://kb.gg/blog/2018/05/01/napa-valley-wildfires<blockquote>
<p>This post is adapted from a poster submitted for an undergraduate remote sensing course.</p>
</blockquote>
<h3 id="background">Background</h3>
<p>In 2017 wildfires in California burned around 1.2 million acres of land and destroyed more than 10,800 structures<sup id="fnref:1" role="doc-noteref"><a href="#fn:1" class="footnote" rel="footnote">1</a></sup>.
In October 2017 the Atlas and Nuns wildfires burned on both sides of Napa Valley and blanketed the vineyards within the valley in smoke.
The Napa Valley region is known worldwide for the wine it produces and contributes more than $50 billion anually to the US economy<sup id="fnref:2" role="doc-noteref"><a href="#fn:2" class="footnote" rel="footnote">2</a></sup>.
In my analysis, I attempt to determine if the smoke covering the region had a significant impact on the health of vineyards in the region with qualitative and quantitative measures.
In my qualitatitve measure, I will graph the average NDVI over the observed time period which should highlight any obvious trends.
For my quantitative measure, I will test if there is a statistically significant difference between the most recent measurements (April 2018) and measurements in the same month of other observed years.</p>
<h3 id="study-area">Study Area</h3>
<p>I am termining if there is a significant effect within the Napa Valley American Viticultural Area (AVA).
I selected eight sub-AVAs within the Napa Valley AVA to study and within those sub-AVAs I am observing ten randomly selected vineyards.
The sub-AVAs I am studying are Calistoga, Los Carneros, Oak Knoll, Oakville, Rutherford, Saint Helena, Stags Leap, and Yountville.</p>
<p><img src="/assets/napa_valley/study_area.png" alt="Study Area" /></p>
<h3 id="materials-and-methods">Materials and Methods</h3>
<table style="border: 0">
<tr>
<td style="border: 0; width: 125px; text-align: center"><img src="/assets/napa_valley/scene_search.png" style="width: 100px;" /></td>
<td style="border: 0">
<h4>Search for Scenes</h4>
I created a geojson file containing a polygon of the Napa Valley area.
I searched the Planet API with this polygon as my geometry bounds and RapidEye OrthTiles as my product.
I then stored the IDs of all scenes acquired between January 1st, 2013 and April 30th, 2018.
</td>
</tr>
<tr style="background-color: #ffffff00;">
<td style="border: 0; width: 125px; text-align: center;"><img src="/assets/napa_valley/next.png" style="height: 40px;" /></td>
</tr>
<tr>
<td style="border: 0; width: 125px; text-align: center"><img src="/assets/napa_valley/download_scenes.png" style="width: 100px;" /></td>
<td style="border: 0">
<h4>Download Clipped Scenes</h4>
First, I filtered all the searhed results to only contain scenes where the entire Napa Valley area is within the scene.
Next, I created a Python script to automatically request scenes clipped to each of the vineyards I am observing and download them to a directory.
</td>
</tr>
<tr style="background-color: #ffffff00;">
<td style="border: 0; width: 125px; text-align: center;"><img src="/assets/napa_valley/next.png" style="height: 40px;" /></td>
</tr>
<tr>
<td style="border: 0; width: 125px; text-align: center"><img src="/assets/napa_valley/filter_scenes.png" style="width: 100px;" /></td>
<td style="border: 0">
<h4>Filter out Cloudy Scenes</h4>
For each vineyard, I create a reference scene by calculating the average brightness of each pixel of all the scenes I have downloaded for every band.
I then compare every downloaded scene to this refernce scene and discard any scenes where more than five percent of pixels are outside of two standard deviations of their corresponding reference pixel.
</td>
</tr>
<tr style="background-color: #ffffff00;">
<td style="border: 0; width: 125px; text-align: center;"><img src="/assets/napa_valley/next.png" style="height: 40px;" /></td>
</tr>
<tr>
<td style="border: 0; width: 125px; text-align: center"><img src="/assets/napa_valley/calculate_scenes.png" style="width: 100px;" /></td>
<td style="border: 0">
<h4>Calculate Average NDVI</h4>
I created a Python script to calculate the average NDVI of all pixels in a scene for every scene I have downloaded.
I then output the results to a CSV file.
</td>
</tr>
<tr style="background-color: #ffffff00;">
<td style="border: 0; width: 125px; text-align: center;"><img src="/assets/napa_valley/next.png" style="height: 40px;" /></td>
</tr>
<tr>
<td style="border: 0; width: 125px; text-align: center"><img src="/assets/napa_valley/analyze_scenes.png" style="width: 100px;" /></td>
<td style="border: 0">
<h4>Analyze Results</h4>
Utilizing another Python script I wrote, I find which vineyards I have observations for in April of all years in my time range of 2013 to 2018.
For each year I then put every observed NDVI value in its corresponding group.
I then calculated if there was a significant difference between groups using a one-way balanced ANOVA test.
</td>
</tr>
</table>
<h3 id="results">Results</h3>
<p>With p < 0.05, 4 degrees of freedom in the numerator, and 45 degrees of freedom in the denominator I calculated the f-ratio to be 0.646 and the critical value to be 2.09.
The f-ratio does not exceed the critical value so we fail to reject the null hypothesis.</p>
<p><img src="/assets/napa_valley/chart_1.png" alt="Results Chart 1" />
<img src="/assets/napa_valley/chart_2.png" alt="Results Chart 2" /></p>
<h3 id="conclusions">Conclusions</h3>
<p>The analysis shows that there is not a significant difference of the health of vineyards in the region after the 2017 California wildfire season.
When analyzing the results there does appear to be abnormal dips and peaks in NDVI between November 2013 and March 2014 and in November of 2016.
The cause of these anomalies is unknown and warrants further examination.</p>
<h3 id="references">References</h3>
<div class="footnotes" role="doc-endnotes">
<ol>
<li id="fn:1" role="doc-endnote">
<p><a href="https://www.washingtonpost.com/graphics/2017/national/california-wildfires-comparison/?utm_term=.88abc5932c39">The grim scope of 2017’s California wildfire season is now clear. The danger’s not over.</a> <a href="#fnref:1" class="reversefootnote" role="doc-backlink">↩</a></p>
</li>
<li id="fn:2" role="doc-endnote">
<p><a href="https://napavintners.com/press/press_release_detail.asp?ID_News=3621116">Economic Impact of Napa’s Wine Industry more than $13 Billion to Napa County</a> <a href="#fnref:2" class="reversefootnote" role="doc-backlink">↩</a></p>
</li>
</ol>
</div>This post is adapted from a poster submitted for an undergraduate remote sensing course.