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:
from descarteslabs.vector import Table, TableOptions, models, properties as p
import json
import geopandas as gpd
import ipyleaflet
Next, we can create a Vector Table by executing the following Python code:
class CustomModel(models.PolygonBaseModel):
name: str
table = Table.create(product_id="my-favourite-shapes", name="My favourite shapes", description="This is just one of my favorite shapes", model=CustomModel)
This product will contain only the most appealing shapes. Vector Tables consist of features, which themselves consist of a geometry and attributes. Let's create a feature that contains a triangle geometry, and give it a name by adding a property:
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 Vector table we just created by executing the following Python code:
gdf = gpd.GeoDataFrame.from_features(geojson["features"], crs="EPSG:4326")
table.add(gdf)
We can retrieve this feature by querying the product in a few different ways. First, by its name:
table.options.property_filter = p.name == "The coldest lake"
gdf = table.collect()
...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
table.reset_options()
table.options.aoi = aoi
gdf = table.collect()
Since, in this case, our feature has a geometry, we can also visualise it on a map! Let's do this now, using 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
table.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
File details
Details for the file descarteslabs_vector-0.2.0.tar.gz
.
File metadata
- Download URL: descarteslabs_vector-0.2.0.tar.gz
- Upload date:
- Size: 21.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9efc62a60e5494af263d0c872d739c76d02437e31385a5085cbd0122d54b77a0 |
|
MD5 | e522854f0cc493e111522f73a0f75326 |
|
BLAKE2b-256 | 52d22d625620e4e237f2b94e4459d8932d6463dff7bce564216e263e6380f048 |
File details
Details for the file descarteslabs_vector-0.2.0-py3-none-any.whl
.
File metadata
- Download URL: descarteslabs_vector-0.2.0-py3-none-any.whl
- Upload date:
- Size: 25.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a9ebbaed520210267e5b018e4b6655c6dc3ea2fed0d72ce13716b7d4f4f1d82f |
|
MD5 | f90f3582e7d95062f20068d79d8b23da |
|
BLAKE2b-256 | c5831b05763456c08bcccfe0caf5214ca33fa01e407e8454c52f17912f86062d |