Skip to content

Client

imageserver_export.client

An async client: describe a service, and export an area of it to a GeoTIFF.

Give it your httpx.AsyncClient and timeouts, proxies and pooling stay yours; give it none and it opens (and closes) its own. Network errors and 429/5xx are retried retries times with exponential backoff.

To route every request through your own HTTP layer (a shared retry policy, a cache, a rate limiter), pass send: an async (method, url, **kwargs) -> httpx.Response. The client then uses it for every call and does no retrying of its own.

Export dataclass

What an export wrote.

skipped tiles were filled with nodata without a request (skip_empty); reused tiles came from an earlier run (resume).

ImageServer

One ImageServer (https://…/arcgis/rest/services/<name>/ImageServer).

aclose async

aclose() -> None

Close the HTTP client if this instance opened it.

info async

info() -> ServiceInfo

The service description: pixel type, size, extent, largest image.

attribute_table async

attribute_table() -> list[dict[str, Any]]

The raster attribute table: what each pixel value means.

export async

export(grid: Grid, dest: Path, *, pixel_type: str = 'U8', interpolation: Interpolation = 'RSP_NearestNeighbor', dtype: str = 'uint8', nodata: float | None = 255, valid_range: tuple[float, float] | None = None, tile_px: int = DEFAULT_TILE_PX, concurrency: int = 3, on_tile: Callable[[int, int], None] | None = None, tags: Mapping[str, str] | None = None, skip_empty: bool = False, resume: bool = False) -> Export

grid of this service as a GeoTIFF at dest, written atomically.

Tiles are requested concurrency at a time and pasted as they arrive; on_tile(done, total) reports progress. valid_range counts the valid pixels (e.g. (0, 100) for a percentage layer that uses 254 and 255 as sentinels); without it, every pixel that is not nodata counts.

The file records where it came from as GeoTIFF metadata: source (the service URL), interpolation, pixel_type, valid_range, created (UTC), software and valid_px. tags adds to them, or overrides them.

skip_empty first asks for one overview of the grid, tile_px // 64 times coarser, and sends no request for a tile with no valid overview pixel on it or next to it: such tiles are filled with nodata. Most of a coastal country's box is sea, so this saves most requests; but a feature smaller than an overview pixel and surrounded by no data (a rock off the coast) can be missed, which is why it is off by default.

resume keeps every checked tile in <dest>.tiles/, named after its request: a run that fails keeps them, and the next run with the same arguments reuses them instead of asking again. The directory is deleted once the GeoTIFF is whole.

list_services async

list_services(folder_url: str, client: AsyncClient | None = None) -> list[str]

The ImageServer names in a folder (…/rest/services/<folder>).