Python Adam API
Project description
Installation
Versioning
- adamapi==1.0.1 , This package works only with ADAMCORE 1.
- adamapi==2.0.1r1, This pachage works only with ADAMCORE 2. (ADAMCORE 2 in development phase)
Requirements
sudo apt-get install python3-venv python3-gdal gdal-bin
Install with pip
VENVNAME="adamapi"
python3 -m venv "${VENVNAME}"
PYTHONVERSION=$(ls ${VENVNAME}/lib/)
source "${VENVNAME}/bin/activate";
python3 -m pip install --upgrade pip;
pip install adamapi==2.0.1r1
ln -s "/usr/lib/python3/dist-packages/osgeo" "${VENVNAME}/lib/${PYTHONVERSION}/site-packages/osgeo"
API DEFINITIONS
This document briefly describe the ADMAPI functionalities.
A more complete and interactive documentation are provided through a predefined jupyter notebook (LINK to notebook TBP).
The ADAMAPI library is divided in 4 modules:
- Auth --> the authorization module
- Datasets --> to retrieve available datasets
- Search --> to get image lists, polygons, tiles and other metadata
- GetData --> to retrieve tiff data
1 - Auth
This module takes care of user authentication.
Without instancing an object of this module other components will not works.
Authentication is based on the ADAMAPI_KEY, a key that uniquelly identify a user in the ADAM-CORE endpoint.
Class contructor and parameters
from adamapi import Auth
a = Auth()
Parameters:
position/keyword | mandatory | type | default | description |
---|---|---|---|---|
Public methods and parameters
- .setKey() --> To setup the ADAMAPI_KEY
Parameters:
position/keyword | mandatory | type | default | description |
---|---|---|---|---|
0 | True | str | The ADAMAPI_KEY |
- .setAdamCore() --> To setup the url of the ADAM-CORE endpoint
Parameters:
position/keyword | mandatory | type | default | description |
---|---|---|---|---|
0 | True | str | The url like https://explorer.adamplatform.eu |
- .authorize() --> to instanciate an auth object
Parameters:
position/keyword | mandatory | type | default | description |
---|---|---|---|---|
1.1 - ADAMAPI_KEY retrieval
To get the ADAMAPI_KEY access the refence ADAM portal and:
- Select the "user icon" on the top right
- Click on the "USERNAME" and open the "User Management" popup
- Click on the "Api Key" to display your key
*Command-line ADAMAPI_KEY retrieval TBP*
1.2 - ADAMAPI_KEY setup
There are three method to setup the ADAMAPI_KEY and the ADAM-CORE Instance:
- use the method setKey() and setAdamCore()
from adamapi import Auth
a = Auth()
a.setKey('bdjmgBl02muSHSG0a4XhyZBjXXQ')
a.setAdamCore('https://explorer.adamplatform.eu')
- Export two envars like
#open a Terminal and type:
export ADAMAPI_KEY='bdjmgBl02muSHSG0a4XhyZBjXXQ'
export ADAMAPI_URL='https://explorer.adamplatform.eu'
- create a file called .adamapirc in the user home directory with the following content
key=bdjmgBl02muSHSG0a4XhyZBjXXQ
url=https://explorer.adamplatform.eu
1.3 - Examples
After ADAMAPI_KEY has been setted up, an auth instance can be created with:
from adamapi import Auth
a = Auth()
a.authorize()
2 - Datasets
This module provides datasets discovery functionality.
Class contructor and parameters
from adamapi import Datasets
datasets = Datasets( a )
Parameters:
position/keyword | mandatory | type | default | description |
---|---|---|---|---|
0 | True | Auth instance | The ADAMAPI authorized instance obtained in the previous section |
Public methods and parameters
- .getDatasets() --> To retrieve datasets list and metadata
Parameters:
position/keyword | mandatory | type | default | description |
---|---|---|---|---|
0 | False | str | The datasetId. | |
page | False | numeric | 0 | Indicats a specific page |
maxRecords | False | numeric | 10 | Max number of results in output. |
2.1 Examples
This module can be used in 2 different ways.
- To list all available datasets:
datasets = Datasets(a)
print(datasets.getDatasets())
- To get detailed information about a specific dataset
datasets = Datasets(a)
print( datasets.getDatasets( '{{ID:DATASET}}' , page=0 , maxRecords=10 ) )
3 - Search
This module provides discovery functionality through the products available on the ADAM instance.
Class contructor and parameters
from adamapi import Search
search = Search( a )
Parameters:
position/keyword | mandatory | type | default | description |
---|---|---|---|---|
0 | True | Auth instance | The ADAMAPI authorized instance obtained in section 1-Auth |
Public methods and parameters
- .getProducts() --> To retrieve datasets list and metadata
Parameters:
position/keyword | mandatory | type | default | description |
---|---|---|---|---|
0 | True | str | The datasetId. | |
outputAttributes | False | array of str | list of attributes desired on the output dictionary. If not set all the attributes will be returned | |
maxRecords | False | int | 10 | number of records |
startIndex | False | int | 0 | starting record index |
startDate | False | str or datetime | the start date | |
completionDate | False | str or datetime | the end date |
3.1 Examples
search=Search(a)
mongo_search=search.getProducts('{{ID:DATASET}}',maxRecords=1,startIndex=0,outputAttributes=['productId'])
4 - getData
This module provides data access of raster .
Class contructor and parameters
from adamapi import GetData
data=GetData(a)
Parameters:
position/keyword | mandatory | type | default | description |
---|---|---|---|---|
0 | True | Auth Instance | The ADAMAPI authorized instance obtained in the section 1-Auth |
Public methods and parameters
- .getData() --> To retrieve rasters in different encodings (tif, png, gif, png_preview)
Parameters:
position/keyword | mandatory | type | default | description |
---|---|---|---|---|
0 | True | str | The datasetId | |
1 | True | str | The productId | |
outputFname | False | str | {{productId}} | output filename pattern. if not set, the product id is the filename |
4.1 Examples
data=GetData(a)
image=data.getData('{{ID:DATASET}}','{{productId}}')
#or
image=data.getData('{{ID:DATASET}}','{{productId}}',outputFname="adamapi/test_get_data")
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for adamapi-2.0.1.post1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d81920ce34f77d49ba40fdd1b235e0c6a097eb13a8fcabf27922f131640ee69f |
|
MD5 | d8e8cdf1cb465d2546b27633e986ac28 |
|
BLAKE2b-256 | 2bf9e84a28f63d231bc4aa85be5ed016cd4a306d06d35f657413b8666177229b |