Generic selectors
Exact matches only
Search in title
Search in content
Post Type Selectors
podcast
Filter by Categories
Galleries
Print Category 1
Print Category 2
Uncategorized

How to use STAC plugin to add Satellite Imagery to your QGIS Project

How to use the STAC API Browser plugin to add Satellite Imagery to your QGIS Project

What is the STAC API Browser

What would you do if you wanted to search, assess and download cloud-hosted satellite data from your local environment? This happens to many people more often as most data and processing resources are being outsourced to cloud service providers allowing you to work with large volumes of data. 

If your data provider supports the STAC API then you are in luck because you can use the STAC API Browser plugin from your QGIS desktop application. It allows you to browse the STAC API items and also add the STAC API assets to the QGIS environment as a layer. You might be wondering what STAC is!

If you have used the REST API before then you have interacted with a bigger portion of what STAC API provides as it follows the same model. What is unique to STAC API is that the search endpoint is more of an action than a resource as is in REST APIs.

This behavior enables you to explore different resources without having to know each endpoint. According to the official documentation STAC(Spatial Temporal Asset Catalog) is a family of specifications that aims to standardize the way we structure and query spatial asset metadata. Spatial asset in this case refers to any file that stores information about the earth  while metadata is the data that gives information about other data. 

How to Instal STAC API Browser plugin in QGIS.

The assumption here is that you have worked with QGIS, but if you are new to it listen to this podcast to refresh your understanding of the software https://mapscaping.com/podcast/qgis-an-opensource-geospatial-project/ .

Through the QGIS plugin repository, you can easily have the STAC API Browser on your QGIS Desktop application. From QGIS click on plugins on the toolbar then on the dropdown select manage and install plugins. This will bring up the plugins dialogue, search the name of your plugin on the search box and then click install. That is it now you have your plugin ready to use. 

Launching STAC API plugin and Searching for your data.

Now that you have your plugin installed, to open it go to the Web Menu on the toolbar and it should be listed as one of the items, click to open. Let’s walk through how you can use it to add imagery to QGIS. To browse and query spatial data from a specific data provider you need to add STAC API service connection that connects specifically to your provider.  We will use Sentinel imagery 10m resolution spatial imagery provided by the European Space Agency.

Connecting to your data provider’s STAC API.

We can access the Sentinel Imagery through the Microsoft planetary computer API which comes as the default connection for the plugin.

Refer to this blog post to understand more about Microsoft Planetary Computer and Google Earth Engine

To change to another provider click the New Connection button, add the required details and click ok to save the connection.

 To see all the spatial data provided by the current connection click on the fetch collections. What you get is in Cloud Optimized Geotiff format which is tailored for efficient workflows on the cloud. It only streams the portion of the data you need hence improving processing time.

Not sure what “Cloud Native” in a geospatial context? listen to this podcast episode!

Cloud Optimized Geotiff does this by leveraging the ability of clients issuing ​HTTP GET range requests to ask for just the parts of a file they need. On top of this, it still provides you with functionalities to run raster analysis like any other raster formatted data. Read more on Cloud Optimized Geotiff in this blog post.

Using Search filters to get the Data you need.

To get your specific data search using the Filter collection bar. We will use Sentinel-2 level 2A. To use a particular search filter such as the date of image acquisition you have to check its corresponding box. With the filter by date box checked, let’s get the most recent sentinel data by specifying the start and end date to be the last month.

Sentinel Data comes in tiles that cover large areas (100km x100km) which might exceed the boundaries of your area of interest while other times your area of interest takes up more than one tile. In such a case, you would have to download the whole tile or sometimes more than one tile and then clip them to your area of interest, which takes up a lot of time and processing resources.

This is where STAC querying comes in. To start with, have your area of interest boundary shapefile loaded on your QGIS environment.  Then with the extent(current user-defined)box checked, by clicking on the compute by layer button, it will fetch all the tiles that intersect with your area of interest.

Using the STAC query tool under the advanced filter group you can query data based on metadata of the assets such as the percentage cloud cover. STAC query tool defines the standards for doing this, this is useful as the metadata is stored in different formats and fields therefore standardization is important. For instance, to get tiles whose cloud cover is less than ten percent we will use the query below:

(“eo:cloudcover”{“lt”:10})

According to the plugin’s official user manual, on the advanced filter group; the available filter languages are based on the supported STAC API filter languages, when STAC_QUERY is used then filter input will be treated as a STAC QUERY. If CQL_JSON is selected then the filter will be used as a CQL_FILTER.

After you have specified all the filters that you want to be used to query the data click on the results button and you will see a list of all the datasets that fit your search criteria. From here you can select the one you see best as it comes with some metadata like the date the image was taken.

Adding and downloading the dataset to your QGIS project.

While still at the results menu, after selecting an asset (remember asset in this context refers to a file containing spatial data), click on the view asset button which will open the asset dialogue with an option to download or add each layer contained by the asset to the QGIS canvas. 

Note that satellite imagery comes in various bands together with some metadata so only select the bands that you will be using in your project. Select the bands you want to use for your analysis and create a mosaic from the bands. For Instance, you can select only the RGB bands. 

There is the option to use the data from the server without downloading it to your machine but anytime you run a process it will be sending a fetch request to the API.Alternatively, you can download them depending on your use case. To create a mosaic of your datasets without first downloading the bands use the build virtual raster GDAL tool on QGIS  and the clip the image using clip raster lay by mask layer.

Now you have your satellite image on your project on which you can do your analysis.

Find more resources here:

  1. STAC Github repository https://github.com/radiantearth/stac-api-spec
  2. STAC API Browser user guide https://stac-utils.github.io/qgis-stac-plugin/user-guide/
  3. https://mapscaping.com/microsofts-planetary-computer-vs-google-earth-engine-a-compare-and-contrast/

Recommened Podcast Episodes