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?
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:
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)
% 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.
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.
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.