Select to view content in your preferred language

Updating hosted image layers on ArcGIS Online

568
1
Jump to solution
10-29-2024 12:48 PM
Labels (1)
jmpmcmanus
Occasional Contributor

I have an ArcGIS Online dashboard map app, that includes an image layer. The image is of a hurricane storm surge and I would like to update that image when new data is produced, in the same way images are updated in ArcGIS live atlas of the world. I would like to do this using ArcGIS API for Python (AAFP) if possible.

Is there a good tutorial or documentation on how to do this?

I understand a tiled Image Layers can not be update, but must be deleted and then replaced. I've attempted to do this but found that I cannot add a new image with the same name because the image service still exists.

RuntimeError: An Image Service by this name already exists: output_test_imagery_layer

I have not found a way to delete the image service on ArcGIS Online. I did find documentation on how to do it in ArcGIS Enterprise, but those methods were not accessible in ArcGIS Online.

Also, I have not found a way to delete a tile image layer using AAFP. The delete_image method I did find required a image collection, as in the case of a dynamic image layer.

I looked into using Dynamic Image Layer, but found that type of image could only be made accessible at the organization level, not the public level. The dashboard map app is accessible by the public so that is a problem, unless there is a work around.

Thanks

Jim

0 Kudos
1 Solution

Accepted Solutions
jmpmcmanus
Occasional Contributor

Purva from ESRI help pointed me to the following doc which helped:

https://developers.arcgis.com/python/latest/guide/managing-your-content/#:~:text=directory%5CIMAGE_N...

After logging in using the API the following works for deleting a tiled image

search = gis.content.search('NAME_OF_TILE_IMAGE', max_items=-1)
for item in search:
    if item.title == 'NAME_OF_TILE_IMAGE':
        itemID = item.id

item_for_deletion = gis.content.get(itemID)
item_for_deletion.protect(enable = False)
item_for_deletion.delete(permanent=True)

To load a new image the following works

input_raster_path = r"/PATH/TO/IMAGE/NAME_OF_TILES_IMAGE.tif"
single_image_layer = copy_raster(input_raster=input_raster_path,output_name="NAME_OF_TILES_IMAGE",gis=gis)
single_image_layer.protect(enable = True)

Jim

 

 

View solution in original post

0 Kudos
1 Reply
jmpmcmanus
Occasional Contributor

Purva from ESRI help pointed me to the following doc which helped:

https://developers.arcgis.com/python/latest/guide/managing-your-content/#:~:text=directory%5CIMAGE_N...

After logging in using the API the following works for deleting a tiled image

search = gis.content.search('NAME_OF_TILE_IMAGE', max_items=-1)
for item in search:
    if item.title == 'NAME_OF_TILE_IMAGE':
        itemID = item.id

item_for_deletion = gis.content.get(itemID)
item_for_deletion.protect(enable = False)
item_for_deletion.delete(permanent=True)

To load a new image the following works

input_raster_path = r"/PATH/TO/IMAGE/NAME_OF_TILES_IMAGE.tif"
single_image_layer = copy_raster(input_raster=input_raster_path,output_name="NAME_OF_TILES_IMAGE",gis=gis)
single_image_layer.protect(enable = True)

Jim

 

 

0 Kudos