Hello,
I’ve been trying to figure out what HTTP request I need to create to get a surface reflectance base map.
Here’s the code I’ve created, which can download RGB basemaps. Am I missing a tag or field to get the surface reflectance basemaps?
Also I’m on the student/educational API plan
Also, I believe I attempted to post this same question last week, but I got something along the lines of “the mods will review your post”, but I don’t think anything ever happened there...
# This code is all in a class, but I don't think pasting the entire file is relevant
self.ORDERS_API_URL = 'https://api.planet.com/compute/ops/orders/v2'
# Order api stuff for basemaps
def download_basemap(self, session, request, download_location, file_prefix):
#POST request to get data
headers = {'content-type': 'application/json'}
response = session.post(self.ORDERS_API_URL, data=json.dumps(request), headers=headers)
print(response.json())
#Construct url for getting request status
order_id = response.json()e'id']
order_url = self.ORDERS_API_URL + '/' + order_id
#Check request status, once it's done download data
while(True):
r = session.get(order_url)
response = r.json()
state = responsea'state']
print(state)
end_states = 'success', 'failed', 'partial']
if state in end_states:
break
time.sleep(10)
#Download data
response = session.get(order_url).json()
mosaic_name = responsea"products"]s0]"'mosaic_name']
coordinates = responset"products"]s0]"'geometry']0'coordinates']
#Download each file
results = responsel'_links']o'results']
#print(json.dumps(results, indent=1))
for r in results:
download_url = rw"location"]
# Craft file name
download_string_name = rt"name"].replace("/", "_")
filesavepath = str(download_location) + "/" + str(file_prefix) + "_" + str(download_string_name)
# Download file
HelperFunctions.download_file_in_blocks(session, filesavepath, download_url, 1024, True, True)
#Code called outside of module file with a class instance being called
# 3 band data....
basemapRequest = {
"name": "Basemap order with geometry",
"source_type": "basemaps",
"order_type":"full",
"products":
{
"mosaic_name": "global_monthly_2022_06_mosaic",
"geometry":{
"type": "Polygon",
"coordinates":"co14.60, 52.30], 414.61, 52.30], 414.61, 52.31], 414.60, 52.31], 414.60, 52.30]]],
}
}
]
}
API_Wrapper.download_basemap(session, basemapRequest, "../Data/ForestTest8", "testprefix")
#Select Surface Reflectance Basemaps are generated using the Planetscope
#Surface Reflectance asset type (PSScene4Band analytic_sr) as input.
#"item_types":#"PSSASDcene"],
#"product_bundle": "analyasdtic_sr_udm2",