UrbanCCD-UChicago / aot-client-py

The Official Python Client to the Array of Things API
https://api.arrayofthings.org/
Other
6 stars 2 forks source link

Filtering on Latitude and Longitude #9

Open ani8897 opened 4 years ago

ani8897 commented 4 years ago

I am trying to filter nodes in a specific region. The following code in Python does not do the job. What am I missing here, or is it a bug in the endpoint?

import geojson
from geojson import Feature, Polygon
from aot_client import F, AotClient

crs_dict = {
    "type": "name", 
    "properties": {
        "name": "EPSG:4326"
    }
}

client, f= AotClient(), F()

poly = [[(-87.613686,41.867541),(-87.442550,41.622690), (-87.710244, 41.851536), (-87.717186,41.894986), (-87.613686,41.867541)]]
region_of_interest = Feature(geometry=Polygon(poly, crs=crs_dict))
print(region_of_interest)

f &= ('location', 'within', region_of_interest)
response = client.list_nodes(filters=f)
print(response.data)