Add attributes to Image Collections

3503
17
Jump to solution
02-24-2022 02:09 PM
MichaelWen_Timmons
Occasional Contributor

Is there a way to add attributes to an Image Collection? 

The goal is to have the Owner and the CreateDate to be associated with each image in the collection.

Thanks.

17 Replies
AlessioDi_Lorenzo1
Occasional Contributor

Hi @JeffreySwain,

I have done what you said:

  • create mosaic dataset
  • populate with rasters (time series of temperature data in tiff format)
  • added the "Timeref" field to the mosaic dataset and populate it with date values (YYYY/MM/DD)
  • Time enabled the mosaic dataset properties in ArcGIS Pro, checking the Time option and selecting my Timeref field
  • Uploaded on AGOL using Python API (as an IMAGE_COLLECTION)

Result: the Timeref field is not in the attribute table of my Hosted Dynamic Imagery Layer and the collection is not time enabled.


What's wrong in the above steps?

I tried also uploading the MDs with ArcGIS Pro (using the "Create Hosted Imagery" button, in the Imagery tab) but nothing changed. Same thing if I create a Tiled Imagery Layer, although I need the "GetSamples" functionality.

The goal is to host the timeseries on AGOL, feed it with new data every month using Python API and use it through  JS applicationsPython code to upload MD on AGOLPython code to upload MD on AGOLMD with its attribute table (added Timeref field)MD with its attribute table (added Timeref field)MD properties (Time enabled)MD properties (Time enabled) No Timeref field in the AGOL collectionNo Timeref field in the AGOL collection

JeffreySwain
Esri Regular Contributor

Ok so the field will not appeared or it is not time enabled. You should enable the time enable the mosaic dataset. 

JeffreySwain_0-1740156375766.png

Subsequent addition to the imagery layer should catch these updates. I would recommend staying with Image Server if possible as this is a perfect Image Server workflow. Imagery layers in ArcGIS Online for dynamic image collections can be updated via the Python API as a find and replace. 

I will give this a try and see if I can get it working. The other option would be to create a multidimensional tiled imagery layer, but then you would have to currently replace the tiled imagery layer. So you would create a mosaic dataset to upload the new images and then recreate the imagery layer once the new one is added. 

0 Kudos
DRynne
by
Emerging Contributor

Hi Jeff,

I'm keen to publish a time enabled mosaic in much the same way, although when I use the "Create Hosted Imagery Layer" tool in Pro, it appears to stage the upload, then hangs with 'Pending' for the Output layers. 

It appears to upload when I have overviews, but then I can only see the overview and no source images. I don't want overviews because I want to show individually time enabled images.

I think this bug is relevant: BUG-000157589 for ArcGIS Pro

But it fails if the mosaic uses tiffs or rasters in a geodatabase, so I'm not sure how to get around it.

Do you have any advice?

0 Kudos
JeffreySwain
Esri Regular Contributor

That seems as if there is a problem with the upload process. If you want to upload the time enabled imagery layer, perhaps look at this workflow to use a tiled imagery layer. 

Create a multidimensional mosaic dataset and host an multidimensional imagery layer

Here is an example of the output from a different area. 

Lake Mead Time Series Tiled Imagery Layer

You can then manipulate the imagery layer or animate it with the Multidimensional slider. 

0 Kudos
DRynne
by
Emerging Contributor

Hi Jeff, thanks for the reply, I believe an image collection is the right format for my use case since I want users to be able to review the specific source image in the collection. 

For context I have a project where we are collecting drone imagery across a large area. I want to compile a mosaic of these images, where each image has a date field so we can use the time slider and see the progress of the project throughout the site.

I have a demo of this functionality working in ArcGIS Pro, which works quite nicely with a time attribute. I have used the publish_hosted_imagery_collection in the same way as Alessio, however I am similarly seeing that the additional attributes I have included have been dropped. I also have found that it has not brought across the footprints that I had defined in the mosaic dataset. Is that expected functionality?

I get the impression that Image Server would be a better fit however my organisation does not yet have enterprise.

0 Kudos
JeffreySwain
Esri Regular Contributor

I understand why Dynamic layer as an image collection is the choice, just wanted to offer the other if you plan on sharing it outside your organization, which you can't with a dynamic and if you are simply showing different dates, then the multidimensional tiled imagery layer fits the bill. With the Mulitdimensional slider and the same in Pro, you can access all the dates or even animate them. 

JeffreySwain_0-1740408392016.png

Can you elaborate which types of fields are dropped? because for my tests I can still see the dates and other text fields that are added. What types of fields are you adding that are being dropped?

0 Kudos
DRynne
by
Emerging Contributor

I have added a text field and a date field, however I'm realising it appears that there is a separate issue with the documentation which means the existing mosaic dataset was never used.

I used publish_hosted_imagery_collection like so:

 

PublishImageryLayer = publish_hosted_imagery_layer(input_data=input_rasters,
                                     output_name=output_name,
                                     layer_configuration="IMAGE_COLLECTION",
                                     raster_type_name="Raster Dataset",
                                     source_mosaic_dataset=Mosaic_dataset_path,
                                     context={"upload_properties":{"displayProgress":True}},
                                     gis=gis) 

 

When this publishes, I see in console comments about 'creating an empty mosaic dataset'.

 

Transfer input images: [REDACTED URLs]

Transfer to Hosted folder: [REDACTED]

Finished creating empty mosaic dataset.

Create empty image collection successfully.

Preparing image collection table schema.

Ingesting data to image collection.

Finished ingesting data to image collection.

Set mosaic dataset default properties.

Adding key metadata to image collection...

Getting image service info…

I noticed that the documentation (arcgis.raster.utils module | ArcGIS API for Python) has conflicting definitions, under the function it says "source_mosaic=None", but the parameters in the documentation calls it "source_mosaic_dataset". "source_mosaic_dataset" is also used in example 3 of the example notebook Create Imagery Layer with ArcGIS Online (publish_hosted_imagery_layer edition) - Overview, and it has the console output similar to above about creating an empty mosaic dataset. I think this is a mistake in the documentation. The create_image_collection function uses source_mosaic_dataset as the parameter name so potentially a typo?

So, I replaced source_mosaic_dataset with source_mosaic, which now fails more directly but in a different way with this as the error:

Failed to transfer uploaded mosaic dataset, or missing mosaic dataset workspace.
Failed to repair data paths for uploaded mosaic dataset.
Create new image collection failed.
Failed script CreateImageCollection...
Failed to execute (CreateImageCollection).
Failed at Tuesday, February 25, 2025 6:51:51 AM (Elapsed Time: 19.07 seconds)
Failed.
CreateImageCollection GP Job: [REDACTED] failed: Job failed.

create_image_collection fails for me in the same way (I understand publish_hosted_imagery_layer is calling create_image_collection under the hood)

Do you have any pointers as to what might be causing the mosaic dataset to fail the upload?

0 Kudos
AlessioDiLorenzo
Regular Contributor

Hi @JeffreySwain and all the community.

I've abandoned the idea of using ArcGIS Image for ArcGIS Online for two reasons:

  • I need to customize the mosaic dataset, which doesn’t seem possible, even though it should have been.

  • The dynamic image services, which are the true equivalent of on-premises image services and would allow me to migrate my applications without having to rewrite the code, have very high storage costs in terms of credits for my organization. I wasn’t fully aware of these costs until I nearly ran out of credits after forgetting a test on my account.

While issue #2 could potentially be solved by upgrading the account, I don’t see any solution for issue #1. For our case, migrating image service management to the cloud will have to wait.