Skip to main content

Hello!


When ordering VHR data from third parties it can happen that, despite a relatively low cloud cover, the actual AOI is (partially) clouded.

I was wondering if it is possible to see a preview of PlanetScope data before the actual order is placed.

For SPOT and Pleiades data we have been mainly using GeoStore. Are you aware of anything similar for PlanetScope images and/or do you offer or plan to offer a preview-service?


Best regards,

Emanuele

Hi,


previewing products/items before ordering will be supported at some point in the future. In the mean time and in the case of PlanetScope, you can download previews from Planet API directly because you already have your Planet API key.


If you inspect the response of a search request to the Sentinel Hub API /api/v1/dataimport/search endpoint, you can find something like:


{
'features': [
{
'_links': {
'_self': '...',
'assets': '...',
'thumbnail': 'https://tiles.planet.com/data/v1/item-types/PSScene4Band/items/20190427_093732_22_105d/thumb'},
...
}

You can download previews in PNG format directly from the “thumbnail” URL, but you have to provide your Planet API key. For the above example:


curl -H "Authorization: api-key <your-Planet-API-key>" https://api.planet.com/data/v1/item-types/PSScene4Band/items/20190427_093732_22_105d/assets/ > preview.png

Best regards,

Marjan.


Hello Marjan,


thanks a lot, I will try that!


Best regards,

Emanuele


I had a similar problem. This script checks that the entire AOI is inside of the scene and if so, downloads the preview and converts it into a geotiff so that you can check how the AOI looks. It works out as ~ 50 m GSD so not great, but it should give you a better idea of whether it is worth ordering the data. I switch over to using R to plot the AOI cropped out of the geotiff, but if anyone has a way to do it in python, please share.


import requests
from pandas.io.json import json_normalize
from shapely.geometry import shape
import rasterio
from PIL import Image

aoi_poly = shape(boundary['geometry'])

search_response = requests.post(search_url, headers=sen_headers, json=search_request)
search_response.raise_for_status()
search_results = search_response.json()
scenes = json_normalize(search_results['features'])

for i in range(len(scenes)):
#checks that the entire AOI is within the scene
scene_poly = shape(search_results['features'][i]['geometry'])
scene_bounds = scene_poly.bounds
complete = aoi_poly.within(scene_poly)
if complete == True:
preview_req = requests.get(scenes.iloc[i]['_links.thumbnail']+'?api_key=<APIKEY>&width=512')
preview_name = 'preview_'+scenes.iloc[i]['id']+'.png'
with open(preview_name , 'wb') as f:
f.write(preview_req.content)

#crops white space in the 512 x 512 tile off
img = Image.open(preview_name)
bbox = img.getbbox()
img2 = img.crop(bbox)
img2.save(preview_name.replace('.png','_crop.png'))

width = bbox[2] - bbox[0]
height = bbox[3] - bbox[1]

#transforms data into geotiff
dataset = rasterio.open(preview_name.replace('.png','_crop.png'), 'r')
bands = [1, 2, 3]
data = dataset.read(bands)
transform = rasterio.transform.from_bounds(scene_bounds[0], scene_bounds[1], scene_bounds[2], scene_bounds[3], width, height)
crs = {'init': 'epsg:4326'}

with rasterio.open(preview_name.replace('.png','_reproj.tiff'), 'w', driver='GTiff',width=width, height=height, count=3, dtype=data.dtype, nodata=0,transform=transform, crs=crs) as dst:
dst.write(data, indexes=bands)

Hello @msterk,


I am finally back to searching for VHR data. I tried to use the command as you suggested:


curl -H "Authorization: api-key xxxxxxxxxxxx" https://api.planet.com/data/v1/item-types/PSScene4Band/items/20190427_093732_22_105d/assets/ > preview.png

The output in the cell is:


  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
Dload Upload Total Spent Left Speed
100 13812 0 13812 0 0 42238 0 --:--:-- --:--:-- --:--:-- 42238

Unfortunately, the preview seems to be unreadable.


Screenshot from 2020-11-26 15-56-03


Do you have an idea of causes that?


Best,

Emanuele


Hi,


the URL you are using is the “assets” link, which returns JSON metadata. Please use the “thumbnail” URL, which should be something like https://tiles.planet.com/.../thumb.


Best regards,

Marjan.


Hi,


we have added a new thumbnail endpoint (https://docs.sentinel-hub.com/api/latest/reference/#operation/dataImport_getProductThumbnail), which lets you preview products before ordering.


Please note that this is just a scaled down, non-georeferenced image of the whole product and is thus not intersected with the AOI of your search/order, because that is all that can be obtained from the PlanetScope API. The above suggestion by Simon to approximate the bounds of the product may work for a visual check, but is not reliable or accurate enough to implement it within the service.


Best regards,

Marjan.


Reply