Skip to content

Commit

Permalink
Add initial docs for lantmateriet
Browse files Browse the repository at this point in the history
  • Loading branch information
mgcth committed May 5, 2024
1 parent 9cb11e8 commit 0334bb6
Show file tree
Hide file tree
Showing 4 changed files with 134 additions and 5 deletions.
57 changes: 57 additions & 0 deletions docs/api.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# API

The provided API functionality is currently limited in this package.
Users can

- list the order information
- list available files in the order
- download a selected file from the order

## Prerequisites

### API token

In order to access the API a token must be generated from
[here](https://apimanager.lantmateriet.se){target="\_blank"} and
set as en environment variable

```bash
export LANTMATERIET_API_TOKEN=...
```

so it can be read from Python as

```python
import os

os.environ["LANTMATERIET_API_TOKEN"]
```

### Order id

An order must also be placed through
[geotorget](https://geotorget.lantmateriet.se){target="\_blank"}
and the order id acquired which is a unique id of the form

```bash
11a2ab333-1234-12ab-12a3-1a2bce3d45ef
```

## Usage

Example usage of the API client

```python
from lantmateriet.api import Lantmateriet

client = Lantmateriet("11a2ab333-1234-12ab-12a3-1a2bce3d45ef", "save_path")

client.order
# show order information

client.available_files
# show available filed for download in order

client.download("file.zip")
# download and extract zip file to save_path
```
33 changes: 33 additions & 0 deletions docs/cli.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# CLI

When you install ifk-lantmateriet a CLI application is also
installed which can be invoked as

```bash
ifk-lantmateriet --help
```

It is mainly provided to simplify automated worekflows, e.g.
to download and extract data periodically.

## Prerequisites

In order to use the CLI an API token is necessary, see [API](api.md) page.

## Usage

### Download all

Example of downloading data to a folder called `save_path`

```bash
ifk-lantmateriet download-all 11a2ab333-1234-12ab-12a3-1a2bce3d45ef save_path
```

### Extract all

Example of extracting located in a folder called `save_path`

```bash
ifk-lantmateriet extract-all save_path
```
38 changes: 37 additions & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,39 @@
# Welcome to ifk-lantmateriet

Docs for ifk-lantmateriet.
ifk-lantmateriet is a python package to work with geo data
from Lantmäteriet (The Swedish Mapping, Cadastral and Land
Registration Authority). The main goal of the package is
to provide reusable components for building maps.
To this end, the package currently provides

- an API client to fetch subscribed data
- a CLI interface for workflow automation
- vector data manipulation

## Install

ifk-lantmateriet can be installed as

```bash
pip install ifk-lantmateriet
```

For the latest build, install from GitHub

```bash
pip install git+https://github.com/Ingenjorsarbete-For-Klimatet/ifk-lantmateriet.git@main
```

## Guide to Lantmäteriet

Data from Lantmäteriet can be downloaded through
[geotorget](https://geotorget.lantmateriet.se){target="\_blank"}.
Possible orders are

- single
- subscribed

Both single and subscribed orders can be downloaded diretly from geotroget, but
only subscribed orders can be downloaded multiple times. Lantmäteriet's API site
can be found [here](https://apimanager.lantmateriet.se){target="\_blank"}.
Accounts are needed for both sites.
11 changes: 7 additions & 4 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ site_url: https://ingenjorsarbete-for-klimatet.github.io/ifk-lantmateriet/
repo_name: Ingenjorsarbete-For-Klimatet/ifk-lantmateriet

nav:
- Home: index.md
- Home: index.md
- API: api.md
- CLI: cli.md

watch:
- src
- src

theme:
name: material
Expand All @@ -26,10 +28,11 @@ theme:
- navigation.tabs

plugins:
- search
- mkdocstrings
- search
- mkdocstrings

markdown_extensions:
- attr_list
- pymdownx.highlight:
anchor_linenums: true
- pymdownx.inlinehilite
Expand Down

0 comments on commit 0334bb6

Please sign in to comment.