Skip to content

Problem Running visualize_imagery_over_time and API key not work for tiles API #245

@ivanSantos16

Description

@ivanSantos16

Hi,

First of all, thanks a lot for this amazing job.
I was trying to use one of your notebooks but without success. Running Visualize Imagery Over Time Notebook was very tricky.


First Problem:

asyncio_problem


To solve the problem I just remove the await expression (but this removes the asynchronous request operation and this is not what you expect)

async with Session() as sess:
    cl = DataClient(sess)
    items = cl.search(name='imagery_over_time',search_filter=combined_filter, item_types=item_types)
    item_list = [i async for i in items]

Second Problem:

The URL generated from your get_tile_urls function is not proper. When we do requests to that URL we receive HTML 400 Code meaning the server cannot or will not process the request due to something that is perceived to be a client error (for example, malformed request syntax, invalid request message framing, or deceptive request routing).
links_not_proper


I fixed the function to have a proper URL this way:

def get_tile_urls(lon, lat, item_list, limit=5, zoom=15,):
    """Get webtile urls for given coordinates, zoom, and matching filters.
    Args:
        lat: latitude float
        lon: longitude float
        zoom: zoom level int (usually between 1 and 15)
        limit: max number of ids to return
    Returns:
        tiles: json response and links to view tiles
    """
    item_list = item_list[:limit]
    tile = mercantile.tile(lon, lat, zoom)
    tile_url_template = 'https://tiles0.planet.com/data/v1/{item_type}/{item_id}/{z}/{x}/{y}.png?api_key={api_key}'
    # return [tile_url_template.format(item_type=item_types, item_id=i, x=tile.x, y=tile.y, z=zoom, api_key=API_KEY) for i in item_list]
    return [tile_url_template.format(item_type=item_types[0], item_id=i['id'], x=tile.x, y=tile.y, z=zoom, api_key=API_KEY) for i in item_list]

Third Problem:

Fixing the problem I receive No Permission response:
with_proper_links

Seems that my Trial API key only works for API orders.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions