Skip to main content

The official Python fsai_data_sdk library for accessing Foresight Data Portal

Project description

Foresight Data Portal for Python

Installation

$ pip install --upgrade fsai_data_sdk

Usage

Get Data

Get data at a specific location

    import fsai_data_sdk as DatasetService

    dataset_service = DatasetService(API_KEY, SECRET_KEY)
    datasets = dataset_service.get_data_at(lng=-122.1598309, lat=37.4358347, radius=2000, layers=["SEMANTIC_2D", "DYNAMIC_OBJECTS"])
    print(len(datasets))
    sample_dataset = datasets[0]
    print(sample_dataset)
    print(sample_dataset.layers.semantic_2d.get())
    print(sample_dataset.layers.dynamic_objects[0].get())

The get_data_at function returns a list of Dataset. Each Dataset object contains the data layers:

  • semantic_2d: a DataGetter object to get the semantic 2d json data of the area.
  • dynamic_objects: a list of DataGetter object to get the array of dynamic_object.

DataGetter class

Because the data layers are normally large, they can't be returned directly in the getting data calls. The SDK wrap the data layer in the DataGetter class which provides a get function to fetch the data and return the actual data of the layer.

Parsing data

    import fsai_data_sdk as DatasetService
    from fsai.services.data_object.DynamicObjectData import DynamicObjectData
    from fsai.services.data_object.Semantic2DData import semantic_2d_data_from_dict


    dataset_service = DatasetService(API_KEY, SECRET_KEY)
    datasets = dataset_service.get_data_at(lng=-122.1598309, lat=37.4358347, radius=2000, layers=["SEMANTIC_2D", "DYNAMIC_OBJECTS"])
    print(len(datasets))
    sample_dataset = datasets[0]


    # DYNAMIC OBJECT
    "Get raw JSON data"
    dynamic_object_json_data = sample_dataset.layers.dynamic_objects[0].get()

    "Get parsed data objects"
    dynamic_object_data = DynamicObjectData.from_json(dynamic_object_json_data)
    for object in dynamic_object_data.collections[0].objects:
        print(object.get_moving_distance())

    # SEMANTIC MAP
    "Get semantic map apollo open drive JSON data"
    semantic_2d_data = sample_dataset.layers.semantic_2d.get()
    "Get parsed data objects"
    semantic_object = semantic_2d_data_from_dict(semantic_2d_data)
    # empty to get sum length
    total_length = 0
    # loop through all the roads and compute the total length
    for road in semantic_object.road:
        total_length = total_length + road.attributes.length
    print('\n')
    print(total_length)

See also

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fsai_data_sdk-1.0.4.tar.gz (11.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fsai_data_sdk-1.0.4-py3-none-any.whl (20.9 kB view details)

Uploaded Python 3

File details

Details for the file fsai_data_sdk-1.0.4.tar.gz.

File metadata

  • Download URL: fsai_data_sdk-1.0.4.tar.gz
  • Upload date:
  • Size: 11.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.1

File hashes

Hashes for fsai_data_sdk-1.0.4.tar.gz
Algorithm Hash digest
SHA256 23ab7473ae96ed18b84a400d121eedaac0688194c2969ed41f6cf1b2898c305a
MD5 32daa982c03ed7c8eccfe3235bce7ed6
BLAKE2b-256 7d958c65c53cd2b0840e77b19a551c3103ed608ba80370995648bcfd5c32c650

See more details on using hashes here.

File details

Details for the file fsai_data_sdk-1.0.4-py3-none-any.whl.

File metadata

  • Download URL: fsai_data_sdk-1.0.4-py3-none-any.whl
  • Upload date:
  • Size: 20.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.1

File hashes

Hashes for fsai_data_sdk-1.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 288345b4d6d7e956818ae9a44e5615e7ed78c07709f673958a9571e90ebf2e6b
MD5 a27cd13075a2de089e625ba9d2800290
BLAKE2b-256 205c87b622ad3e9973ad5061d1620c102bb4ff951dc6a150721ecda6705ebe94

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page