An image service (also called a hosted imagery layer) enables storage, delivery, processing, analysis, and sharing of raster imagery via REST endpoints and APIs. Clients—whether web, desktop, or mobile—can request imagery by spatial extent, apply raster functions, perform analytics, or fetch tiles. The image service can dynamically mosaic multiple images, execute on‑the‑fly processing, and expose tailored capabilities depending on how it is configured.
The URL for an image service layer hosted in ArcGIS Online typically resembles the following pattern:
https
Register a GIS
Authentication will be required when saving an image service to ArcGIS Online.
GeoAnalytics Engine supports authentication by registering a GIS (i.e. a connection to ArcGIS Online)
with the register) function.
The default GIS in register is ArcGIS Online. The following example shows
registering ArcGIS Online as a GIS with a username and password for a built-in account.
import geoanalytics
geoanalytics.register_gis("myGIS", username="User", password="p@ssw0rd")Each GIS name can only be registered once. To remove a GIS, use the unregister function as shown in the
following example.
import geoanalytics
geoanalytics.unregister_gis("myGIS")Read from image services
GeoAnalytics Engine supports loading data from image services into a Spark DataFrame for use with any operations supported on a DataFrame in GeoAnalytics Engine or Spark.
The following example shows the Python syntax for loading an image service into a Spark DataFrame, where URL is the
URL to an image service.
spark.read.format("image-service").option().load(URL)Below is a table of options that GeoAnalytics Engine supports when loading an image service with Spark Data.
| DataFrameReader option | Example | Description |
|---|---|---|
gis | .option("gis", "my | Reference to a registered GIS. Required for secured image services if token is not provided. |
token | .option("token", "my | ArcGIS Online or portal token. Required for secured image services if gis is not provided. |
extent | .option("extent", ""0, -10, 10, -5"") | Filters the image service layer by the spatial extent specified using the format ". Values should be defined in the same units as the spatial reference of the image layer. |
bands | .option("bands", 2) | Filters the image service layer by reading only the specified bands. |
tile | .option("tile | Defines the number of columns in each raster tile. The default is 1024. |
tile | .option("tile | Defines the number of rows in each raster tile. The default is 1024. |
sr | .option("sr", 4326) | Spatial reference in which the image service layer will be projected into. |
When loading a public image service layer, you can pass the URL without options gis or token:
spark.read.format("image-service").load(URL)When loading a secured image service layer, a GIS connection or token will be required. For example:
import geoanalytics
geoanalytics.register_gis("myGIS", username="User", password="p@ssw0rd")
spark.read.format("image-service").option("gis", "myGIS").load(URL)Write to image services
GeoAnalytics Engine extends Spark and supports saving data in image services. You can serve and share image services over the internet. You can also access, visualize, or edit the published image services in an ArcGIS Online portal.
The following script shows the Python syntax of saving image services that GeoAnalytics Engine currently supports:
df.write.format("image-service").option().save()Below is a table of options and modes that GeoAnalytics Engine supports when saving an image service with
Spark Data.
| DataFrameWriter option | Example | Description |
|---|---|---|
gis | .option("gis", "my | Reference to a registered GIS. |
service | .option("service | The name of the image service that will be created if writing to a new image service. |
path | .option("path", "new | Alternative method for specifying the service. |
field | .option("field | The raster column to write. If not specified the first raster column found in the data frame will be used. |
wait | .option("wait | If true the write operation will wait for the image service to be fully published before returning. If false the operation will return as soon as the image files are uploaded and the image service creation job has been submitted. The default is true. |
When saving an image service, a registered GIS is required. Below is an example of registering a GIS and saving an image service.
import geoanalytics
geoanalytics.register_gis("myGIS", username="User", password="p@ssw0rd")
df = spark.read.format("raster").load(data_path)
df.write.format("image-service") \
.option("gis", "myGIS") \
.option("serviceName", "raster_output") \
.save()Usage notes
- A registered GIS is required when saving an image service.
- When writing to an image service, the
promotionpolicy is applied. This policy converts the raster to the next largest pixel type and assigns the largest possible value of the new type as theNovalue. For instance, if a raster dataset with a Float32 pixel type is written to an image service, the resulting image service will have a pixel type of Float64. If the input raster dataset already has a pixel type of Float64, no conversion will occur, and the largest value of Float64 will be used as theData Nocell value.Data - Writing a Spark DataFrame with a raster column lacking spatial references may result in an empty image service. If the column contains a mix of spatially referenced and unreferenced raster records, only those with spatial references will be included in output image service.
- When working with large image services and planning to perform a spatial transformation, it is recommended to specify
the
sr(spatial reference) option directly in the image service read operation, rather than applying theRfunction after reading the image. This approach is preferred because reading large image services typically involves tiling, and performing the transformation afterward can introduce slight gaps or missing pixels at tile boundaries. By specifying the desired spatial reference during the read, you ensure that the transformation is handled efficiently and accurately, minimizing the risk of data loss or visual artifacts.T. Transform - Image services are loaded as value rasters by default when reading.