Skip to content

Terradue/DotNetStac

Repository files navigation

DotNetStac

.Net library for working with Spatio Temporal Asset Catalogs (STAC)

Build Status NuGet codecov Gitter License Binder

DotNetStac helps you to work with STAC (catalog, collection, item)

In a nutshell, the library allows serialization/desrialization of STAC JSON documents (using Newtonsoft.JSON) to typed object modeling STAC objects with properties represented in enhanced objects such as geometries, time stamp/period/span, numerical values and many more via STAC extension plugins engine. Stac Item object is based on GeoJSON.Net feature.

Features

Getting Started

Install package

$ dotnet add package DotNetStac

Deserialize and validate your first catalog

using Stac;
using Stac.Schemas;
using System;
using System.Net;
using Newtonsoft.Json.Schema;

var webc = new WebClient();
Uri catalogUri = new Uri("https://raw.githubusercontent.com/radiantearth/stac-spec/master/examples/catalog.json");
StacValidator stacValidator = new StacValidator(new JSchemaUrlResolver());

// StacConvert.Deserialize is the helper to start loading any STAC document
var json = webc.DownloadString(catalogUri);
bool valid = stacValidator.ValidateJson(json);
StacCatalog catalog = StacConvert.Deserialize<StacCatalog>(json);

Console.Out.WriteLine(catalog.Id + ": " + catalog.Description + (valid ? " [VALID]" : "[INVALID]"));
Console.Out.WriteLine(catalog.StacVersion);

Learn more

A dedicated notebook is available to get started with all DotNetStac features. If you want to play directly with the notebook, you can Binder

Documentation

An API documentation site is available at https://terradue.github.io/DotNetStac.

Developing

To ensure development libraries are installed, restore all dependencies

> dotnet restore src

Unit Tests

Unit tests are in the src/DotNetStac.Test folder. To run unit tests:

> dotnet test src