Using Raster Files
Description
SpaceSense API allows you tu upload Raster images like .tif and proccess them like it would proccess a field.
If you already know how to use the API you can checkout the API documention
Upload a Raster file
To upload a raster file to the SpaceSense API you need to generate an upload link.
To get a link to upload your file you will need your Identification token referred to as __myToken__
in those examples.
in This example we're uploading a file called DeFilippo_index_cvi.tif
and you can get file here
curl --request POST https://spacesense-api.ew.r.appspot.com/raster_images/upload/DeFilippo_index_cvi.tif?token=__myToken__
#import requests
import requests
# Sends a post request using your identification Token and the Json previously built
r = requests.post('https://spacesense-api.ew.r.appspot.com/raster_images/upload/DeFilippo_index_cvi.tif?token=' + __myToken__)
The API response will be a json containing an URL like this :
{
"url": "https://storage.googleapis.com/api-service-storage/xfarm/raster_images/DeFilippo_index_cvi.tif?X-Goog-Algorithm=GOOG4-RSA-SHA256&X-Goog-Credential=483104852596-compute%40developer.gserviceaccount.com%2F20200922%2Fauto%2Fstorage%2Fgoog4_request&X-Goog-Date=20200922T121746Z&X-Goog-Expires=900&X-Goog-SignedHeaders=content-type%3Bhost&X-Goog-Signature=1fab89973a682dee7d0b3320e74debb3a4ef331a78f547ebc24b3f9a8463685664a0a7231892f425fb1eb58a31ecdf5d08569f3cab52dcdc2309ee280ce48febb8f337654807351efac9333afa1f6a74b284c02eede589d381250dde985503c14231b75aac805c742a072f5170f554011031b2faa08088ec3bcac6c2df24990ba4c03526a4f8f6f7e2606e068475644484e3602126a85a5bb86925adec2c9ee57a793cebf0e6812c5ed4aea9a542584dde09fa2a380fd7d482cbf1ec28f33405303e3c7043ce52ae8422dcc31b795d97e392b8794adcf21229c7147c1725304a49a37136183f2414ac7bb145ab85b64aa505361ff9a634248707b3a0558646fb"
}
This is a link you can use to upload the file
use this link to upload the files like so :
curl -X PUT -H 'Content-Type: application/octet-stream' --upload-file {full file path} {url}
# in this case :
curl -X PUT -H 'Content-Type: application/octet-stream' --upload-file '/home/drone-image/DeFilippo_index_cvi.tif' 'https://storage.googleapis.com/api-service-storage/xfarm/raster_images/DeFilippo_index_cvi.tif?X-Goog-Algorithm=GOOG4-RSA-SHA256&X-Goog-Credential=483104852596-compute%40developer.gserviceaccount.com%2F20200922%2Fauto%2Fstorage%2Fgoog4_request&X-Goog-Date=20200922T121746Z&X-Goog-Expires=900&X-Goog-SignedHeaders=content-type%3Bhost&X-Goog-Signature=1fab89973a682dee7d0b3320e74debb3a4ef331a78f547ebc24b3f9a8463685664a0a7231892f425fb1eb58a31ecdf5d08569f3cab52dcdc2309ee280ce48febb8f337654807351efac9333afa1f6a74b284c02eede589d381250dde985503c14231b75aac805c742a072f5170f554011031b2faa08088ec3bcac6c2df24990ba4c03526a4f8f6f7e2606e068475644484e3602126a85a5bb86925adec2c9ee57a793cebf0e6812c5ed4aea9a542584dde09fa2a380fd7d482cbf1ec28f33405303e3c7043ce52ae8422dcc31b795d97e392b8794adcf21229c7147c1725304a49a37136183f2414ac7bb145ab85b64aa505361ff9a634248707b3a0558646fb'
#import requests
import requests
url = "https://storage.googleapis.com/api-service-storage/xfarm/raster_images/DeFilippo_index_cvi.tif?X-Goog-Algorithm=GOOG4-RSA-SHA256&X-Goog-Credential=483104852596-compute%40developer.gserviceaccount.com%2F20200922%2Fauto%2Fstorage%2Fgoog4_request&X-Goog-Date=20200922T121746Z&X-Goog-Expires=900&X-Goog-SignedHeaders=content-type%3Bhost&X-Goog-Signature=1fab89973a682dee7d0b3320e74debb3a4ef331a78f547ebc24b3f9a8463685664a0a7231892f425fb1eb58a31ecdf5d08569f3cab52dcdc2309ee280ce48febb8f337654807351efac9333afa1f6a74b284c02eede589d381250dde985503c14231b75aac805c742a072f5170f554011031b2faa08088ec3bcac6c2df24990ba4c03526a4f8f6f7e2606e068475644484e3602126a85a5bb86925adec2c9ee57a793cebf0e6812c5ed4aea9a542584dde09fa2a380fd7d482cbf1ec28f33405303e3c7043ce52ae8422dcc31b795d97e392b8794adcf21229c7147c1725304a49a37136183f2414ac7bb145ab85b64aa505361ff9a634248707b3a0558646fb"
headers = "Content-type: application/octet-stream"
path_file = "/home/drone-image/DeFilippo_index_cvi.tif"
r = requests.put(url, headers=headers, data=open(path_file,'r').read())
Get processed files results
Once the files are processed by the server, new files will be created containing the results.
To get the result files you will need your Identification token referred to as __myToken__
in those examples.
You will also need the file name referred to as __fileName__
in those examples.
# Download the Image as a png file
curl --request GET https://spacesense-api.ew.r.appspot.com/raster_images/get_processed/DeFilippo_index_ndwi.tifimage?token=__myToken__ --output result.png
# Download the Json as a Json file
curl --request GET https://spacesense-api.ew.r.appspot.com/raster_images/get_processed/DeFilippo_index_ndwi.tifjson?token=__myToken__ --output result.json
#import requests
import requests
r = requests.get('https://spacesense-api.ew.r.appspot.com/raster_images/get_processed/DeFilippo_index_ndwi.tif/image?token=' + __myToken__)
r = requests.get('https://spacesense-api.ew.r.appspot.com/raster_images/get_processed/DeFilippo_index_ndwi.tif/json?token=' + __myToken__)