Get asset-data from rest-api

Hello!

I am exploring the possibility of using Cesium Ion and Amazon S3 to store 3D files like GeoTIFF and LAZ data. My plan is to display these files in 3D and also use the REST API to fetch terrain data stored as assets in a Python script for geospatial analysis.

I attempted to implement this using the following code:

python

def fetch_tile(asset_id, access_token):
    headers = {
        'Authorization': f'Bearer {CESIUM_ION_ACCESS_TOKEN}'
    }
    url = f'{BASE_URL}/{CESIUM_ION_ASSET_ID}/endpoint'
    
    response = requests.get(url, headers=headers)
    if response.status_code != 200:
        raise Exception(f'Failed to fetch tile: {response.text}')
    
    r = response.json()
    url = r['url']
    access_token = r['accessToken']
    
    headers = {
        'Authorization': f'Bearer {access_token}'
    }
    
    response = requests.get(url, headers=headers)
    response.raise_for_status()
    return BytesIO(response.content)

However, I am encountering a 404 Client Error: Not Found for URL when I run this code. Is it possible to fetch data from Cesium Ion and read it inside a Python script using Geopandas for geospatial analysis? If so, could you provide guidance on how to correct my approach?

Thank you!

Hi,

You should be able to query our API to load tiles. Is there a specific asset you are trying to load? I would make sure the asset has been added to your assets and the API token you are using has read access for tilesets.

The asset is uploaded on Ion, so there is no issue with getting the new geotiff data/terrain data into the Cesium viewer in my frontend/JS code. The problem arises with my Python backend, where I want to perform some calculations using the terrain data. For this, I need an API to access the tile data and conduct the calculations. One workaround is to use S3 for automatic uploading and fetching of the data, but it would be better to download the terrain directly from the API. The data type is Terrain, and the API documentation for the REST API is available here:

Hi,

I apologize for any confusion here. Can you please let me know what type of calculations you are trying to run on the terrain tiles and what tile data you need? Do these calculations require you to load a tile directly rather than reaching out to the REST API to get the endpoint for the root tile?

The python script you have shared should be able to load terrain tilesets that you have access to. Could you provide me with an example asset id where you are seeing issues?

Thanks,
Ankit