Updating an image service with new raster data is a common workflow in ArcGIS. In ArcGIS Online, only a dynamic imagery layer with the image collection layer configuration for an image service supports the removal of old images and addition of new ones. An image service powered by a tiled imagery layer does not support this workflow, and needs to be replaced entirely if an update is needed. As for image services in ArcGIS Enterprise, the updating an image service workflow is fully supported without any limitation.
How to update an image service
The general steps for preparing raster data:
1. Get the raster data
There are two types of data sources to create an image service: your own raster data and data hosted in ArcGIS.
Data Source | Description |
---|---|
Your data | For example: GEOTIFF, PNG. See supported raster input formats. |
ArcGIS Online | Provides a platform for users to host and share their own raster data that can then be accessed and used for visualization and analysis purposes. |
ArcGIS Hub | Contains many imagery layers from various sources that you can use in your applications. Some of the raster data can be obtained from the original sources and hosted in your ArcGIS Online organization. |
ArcGIS Living Atlas | A collection of geographic information that includes a raster data. You can access and visualize raster data in your maps and apps. |
2. Optimize raster data
There are data preparation toolbox tools available in ArcGIS Pro to optimize your raster data before creating an image service:
Tool | Description |
---|---|
Building pyramids and statistics | Building pyramids enhances raster display performance. Calculating statistics aids raster data display. All raster formats are processed. Learn more in Build Pyramids And Statistics (Data Management). |
Calculate statistics | Create important statistical information like minimum, maximum, mean, and standard deviation values are generated for your raster data. This statistical information is important for tasks like applying contrast stretches and classifying the raster data. Learn more in Calculate statistics |
3. Find the image service
To access an image service, you can use the service URL or item ID. To find this information, you need to go to the hosted imagery layer item page for the dataset in your portal.
The steps to find and access layers are:
- Log in to your portal with your ArcGIS account.
- In My Content, find your hosted imagery layer (item).
- In the hosted imagery layer item page, find the service URL or item ID.
Service URL
To access the hosted imagery layer in the service directly, use the URL for the layer:
https://{host}/{organizationID}/ArcGIS/rest/services/{serviceName}/ImageServer
Item ID
To access the layer and service through an item, use the portal URL and item ID.
https://{organizationURL}/sharing/rest/content/items/{hostedLayerItemId}
4. Update the image service
The general steps for adding new rasters to an image service are:
- Specifiy the path to the new raster files.
- Iterate through each file and add them to the existing image collection.
- Update the item.
Code examples
Add new raster data to an image service
Below is an example that demonstrates how to add new raster data to an existing image service:
# Specify the new raster data you want to add
new_raster_paths = [
r"C:\path\to\raster1.tif",
r"C:\path\to\raster2.tif",
r"C:\path\to\raster3.tif"
]
# Add the new rasters to the image service
image_collection = image_service.layers[0]
for raster_path in new_raster_paths:
image_collection.add_rasters([raster_path])
# Publish the updated image service
image_service.update(item_properties={
"title": image_service_name,
"tags": "updated image service"
})
Delete raster data in an image service
Below is an example that demonstrates how to delete raster data from an existing image service:
# Delete the specified rasters from the image service
image_collection = image_service.layers[0]
for raster_name in rasters_to_delete:
image_collection.delete_rasters([raster_name])
# Publish the updated image service
image_service.update(item_properties={
"title": image_service_name,
"tags": "updated image service"
})
Replace existing raster data in an image service with new raster data
Below is an example that demonstrates how to replace existing raster data in an image service with new raster data:
# Specify the new raster data you want to add
new_raster_paths = [
r"C:\path\to\new_raster1.tif",
r"C:\path\to\new_raster2.tif",
r"C:\path\to\new_raster3.tif"
]
# Specify the rasters you want to replace
rasters_to_replace = [
"old_raster1.tif",
"old_raster2.tif",
"old_raster3.tif"
]
# Replace the existing rasters with the new ones
image_collection = image_service.layers[0]
for i, raster_to_replace in enumerate(rasters_to_replace):
image_collection.delete_rasters([raster_to_replace])
image_collection.add_rasters([new_raster_paths[i]])
Services
Feature service
Add, update, delete, and query feature data.
Vector tile service
Store and access vector tile data.
Map tile service
Store and access map tile data.
Image service
Store and access imagery and raster data.
API support
Use data management tools or Client APIs to create, manage, and access data services. The table below outlines the level of support for each API.
- 1. Use portal class and direct REST API requests
- 2. Access via ArcGIS REST JS
- 3. Requires manually setting styles for renderers