I have requested a raster file from an API (HERE Map Image API v3), and the response comes in the fashion of (I guess) base64 data.
I would like to have a way to transform such data and store it in proper folders.
Any idea?
Regards.
I have requested a raster file from an API (HERE Map Image API v3), and the response comes in the fashion of (I guess) base64 data.
I would like to have a way to transform such data and store it in proper folders.
Any idea?
Regards.
Two transformers to look at will be the TextDecoder (can decoded the base64) and the AttributeFileWriter which can write the contents of an attribute to a file
Two transformers to look at will be the TextDecoder (can decoded the base64) and the AttributeFileWriter which can write the contents of an attribute to a file
Hi
import fme
import fmeobjects
class FeatureProcessor(object):
def __init__(self):
pass
def input(self, feature: fmeobjects.FMEFeature):
# Retrieve the _response_body attribute from the feature
response_body = feature.getAttribute('_response_body')
# Assuming response_body contains binary data for the raster
# Convert the binary data to a raster file
# This example saves the raster to a temporary file. Adjust the path as necessary.
raster_file_path = r'YOURFILEPATH\raster.tif'
with open(raster_file_path, 'wb') as file:
file.write(response_body)
# Optionally, set the path of the raster file as an attribute to the feature
feature.setAttribute('rasterFilePath', raster_file_path)
# Output the feature
self.pyoutput(feature)
This helped to convert my api _responsebody input data and then stored it into the specific path.
Sharing it to newbies in the future to have a nice way to solve this issue.
Regards!
Nice job