diff --git a/docs/api.md b/docs/api.md new file mode 100644 index 0000000..99864cb --- /dev/null +++ b/docs/api.md @@ -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 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"} +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 +``` diff --git a/docs/cli.md b/docs/cli.md new file mode 100644 index 0000000..386c3ec --- /dev/null +++ b/docs/cli.md @@ -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 +``` diff --git a/docs/index.md b/docs/index.md index 9824d2b..23a0683 100644 --- a/docs/index.md +++ b/docs/index.md @@ -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. diff --git a/mkdocs.yml b/mkdocs.yml index 59ab8bb..297fbf6 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -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 @@ -26,10 +28,11 @@ theme: - navigation.tabs plugins: -- search -- mkdocstrings + - search + - mkdocstrings markdown_extensions: + - attr_list - pymdownx.highlight: anchor_linenums: true - pymdownx.inlinehilite