No project description provided
Project description
Vector ⥂
"Vector! That's me, 'cause I'm committing crimes with both direction and magnitude. Oh, yeah!" — "Vector", Despicable Me
Vector is a catalog for vector data. It enables users to store, query, and display vector data — which includes everything from fault lines to thermal anomalies to material spectra.
Formal documentation for this library is available under the Descartes Labs API Documentation. Below is a very simple example to get you started with uploading and querying data to and from Vector.
To start using the Vector client, first import it:
import descarteslabs.vector
Next, we can create a vector product by executing the following Python code:
product = vector.Table.create(
"my-favourite-shapes", # ID for the table
"My favourite shapes" # Name for the table
)
This product will contain only the most appealing shapes. Products consist of features, which themselves consist of a geometry and properties. Features are encoded as GeoJSON.
Let's create a feature that contains a triangle geometry, and give it a name by adding a property:
import json
geojson = {
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {
"name": "The coldest lake"
},
"geometry": {
"coordinates": [
[
[
-110.40972704675957,
54.464841702835145
],
[
-109.69305293767921,
54.41100418392534
],
[
-110.00659786040178,
54.75020711805794
],
[
-110.40972704675957,
54.464841702835145
]
]
],
"type": "Polygon"
}
}
]
}
...and then add it to the product we just created by executing the following Python code:
product.add(feature_collection)
We can retrieve this feature by querying the product in a few different ways. First, by its name:
p = vector.property_filtering.Properties()
product.query(
property_filter=(p.name == "The coldest lake"),
)
...and second, by an AOI which intersects with the geometry of our feature. The AOI is defined as a GeoJSON geometry:
# Define the AOI...
aoi = {
"coordinates": [
[
[
-110.7588318166646,
54.941440389459956
],
[
-110.7588318166646,
54.14613049153121
],
[
-109.34594259898329,
54.14613049153121
],
[
-109.34594259898329,
54.941440389459956
],
[
-110.7588318166646,
54.941440389459956
]
]
],
"type": "Polygon"
}
# ...and query the product
product.query(
aoi=aoi,
)
Since, in this case, our feature has a geometry, we can also visualise it on a map! Let's do this now, using ipyleaflet
:
import ipyleaflet
# Instantiate and configure the ipyleaflet Map
m = ipyleaflet.Map()
m.center = 54.549829, -110.060936
m.zoom = 9
# Display the map
display(m)
# Visualize the vector tile layer on the map
product.visualize("My favourite shapes", m)
Which should yield the feature we just created, outlining the coldest lake on Earth:
The Vector service also provides for more advanced product and feature management and querying. You can read more about what can be done with Vector in the Descartes Labs API Documentation.
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 descarteslabs_vector-0.1.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8c21816a61ef7d9321d960f6e090f70b6d3835f07cb824c751904e64d5658f99 |
|
MD5 | cf1292ddb8e910199c18880fc3b7ba74 |
|
BLAKE2b-256 | da11085ba0887ea7107a078242568d6c256364b5527a55f6539d5bf5eda5069a |
Hashes for descarteslabs_vector-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6f7fd1373443edde80d871a3ab7ce135334ec854224be4de779ab44747698259 |
|
MD5 | b4a9d37c5d621924ef95a7a7157350a9 |
|
BLAKE2b-256 | 17397ed0147cce114b687a3a8424172410ff2dc70129b36f98ef6662f7abc391 |