Python SDK Overview
The Python SDK is available as a PyPI package. The code can be found on GitHub. The gisapi-sdk
package is a standalone SDK library that contains the GISAPIClient
. After installing the package, you can import the SDK into your Python project and start building with the geospatial data discovery API from GISAPI.io.
Installation
Installing the SDK can be done using the package installer for Python (PIP) or by cloning the GitHub repository using git.
PIP Install
To install the GISAPI-SDK, simply enter the following command in your terminal of choice:
pip install gisapi-sdk
Git the Source Code
You can directly download the source code using git and add it to your project with the following command:
git clone https://github.com/OmniverseXYZ/gisapi-sdk-python.git
Getting Started
The SDK was designed to be simple and easy to use. Keep in mind that the underlying API and this SDK are still considered to be in the Alpha stage of development and changes may be made without warning. These docs will stay updated with the latest specifications.
Importing into your Project
Add this line of code to the top of your Python file in your project:
from gisapi import client
Instantiate the GISAPIClient Class
You must instantiate the GISAPIClient
class to begin. Do this by creating a variable for the class. This only needs to be done once. The class variable can be reused for subsequent operations. In the following examples and throughout this documentation we will be using the variable name api
to represent the class.
api = client.GISAPIClient()
Getting Geospatial Data Results
These methods will return raw JSON objects with up to 200 results. If that is good enough for you then start parsing and using it in your applications. However the SDK does contain some function to help with parsing explained in further sections.
Custom Query Search Results
To get query search results use the following code and pass your search query in as a string:
search_results = api.search_data("Search Query")
You can use this search_results
object with the parsing functions explained below.
Category Results
To get category results use the following code and pass the desired category in as a string:
category_results = api.get_data_by_category("Category")
Available Categories
- Other
- Administrative
- Infrastructure and Urban
- Nature and Environment
- Recreation
- Climate and Weather
- Disaster and Emergency
- Education and Research
- Cultural and Historical
- Health and Medicine
- Agriculture and Farming
- Points of Interest
Built in Results Parsing
There are a couple of built in parsing functions that can return cleaned data objects.
Layer Details
Instead of returning all of the metadata use the parse_layer_details
function to create a list of dictionaries with the following structure:
layer_detail = {
"category": item["CATEGORY"],
"crs": item["CRS"],
"url": item["URL"],
"layer": item["LAYER"],
"type": item["TYPE"],
"host": item["HOSTURL"],
}
To use this function pass a search_results
object into the parse_layer_details
function.
layer_details_list = api.parse_layer_details(search_results)
Layer URLs
If you do not want the metadata and just want the URL of the layer you can use the get_layer_urls
function to return a list of just layer URLs. Just pass a search_results
object into the get_layer_urls
function like this:
layer_urls = api.get_layer_urls(search_results)
Host URLs
To get a list of host URLs with no duplicates use the get_host_urls
functions by passing in a search_results
object like this:
host_urls = api.get_host_urls(search_results)