Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs/initial #35

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
strobba marked this conversation as resolved.
Show resolved Hide resolved
set as an 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"}
strobba marked this conversation as resolved.
Show resolved Hide resolved
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
```
34 changes: 34 additions & 0 deletions docs/cli.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# 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 `sourch_path` to
a folder called `target_path`

```bash
ifk-lantmateriet extract-all sourch_path target_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"}.
strobba marked this conversation as resolved.
Show resolved Hide resolved
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"}.
strobba marked this conversation as resolved.
Show resolved Hide resolved
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
Loading