我正在使用 Maps Engine API 批量加载栅格。我有将栅格作为数据源上传的代码,但我看不出如何将该数据源添加到现有图层中。
如果我创建一个新层,我可以指定要包含的数据源列表。我要添加很多栅格,所以我需要能够添加到已经存在的图层。
这是我到目前为止的一段代码:
fileupload = {
"projectId": id,
"name": "Test API Upload - Name",
"description": "Test API Upload - Description",
"files": filenames,
"draftAccessList": "Map Editors",
"attribution": "Copyright My Copyright",
"tags": ["testAPIUpload"],
"maskType": "autoMask",
"rasterType": "image"
}
rasters = service.rasters()
request = rasters.upload(body=fileupload)
response = request.execute()
try:
rasterUploadId = str(response['id'])
for name in raster_files:
print "Waiting for 2 seconds"
time.sleep(2)
try:
freq = rasters.files().insert(id=rasterUploadId,
filename=name,
media_body=name)
print "Calling insert request"
freq.execute()
print "Finished uploading %s" % name
except Exception:
print "Unable to insert '%s'" % name
except KeyError:
print "Error uploading raster files"
print response
现在我已经上传了栅格,如何将它们添加到已经存在的图层中?
谢谢,
本