# ArcGIS

> Live ArcGIS feature queries, server summaries and raster sampling from service URLs worldwide

This page includes setup, release pins, credentials, hosting and verification evidence. [JSON alternative](https://query.farm/products/orchard/api/v1/connectors/arcgis.json) contains the same setup facts for structured readers; choose one format.

## Runtime and release

Use DuckDB or Haybarn **2.0.1** with **VGI protocol 3.4**.
Catalog alias: `arcgis`. Release: [v0.7.0](https://github.com/Query-farm/vgi-arcgis/releases/tag/v0.7.0). Metadata generated: 2026-12-01T18:22:16+00:00.

## Choose where it runs

- On your machine: use an installation method below. No Query Farm account is required for local execution.
- Self-host: follow [the connector deployment instructions](https://github.com/Query-farm/vgi-arcgis) and [connection guide](https://query.farm/vgi/connect-to-a-worker/). Use your real endpoint and its authentication settings.
- Query Farm hosted: [create a deployment](https://auth.queryfarm.cloud/console/new?worker=arcgis). Hosting has a $10 monthly minimum per organization; usage and license fees may apply. Copy the deployment-specific ATTACH from the console.

## Service credentials and prerequisites

Public ArcGIS services need no credentials; add them only for token-secured services.

Secret parameter required flags describe the upstream declaration; they do not override the service-level mode above. Keep secrets in environment variables or the deployment secret store. SQL values in angle brackets are placeholders, not automatic environment lookups. Native DuckDB and Haybarn 2.0.1 do not provide a SQL getenv() function, even when worker-supplied snippets mention it. Read environment variables in your application and pass credential values through client parameter bindings (for example, Python con.execute("CREATE SECRET stripe (TYPE stripe, api_key ?)", [os.environ["STRIPE_API_KEY"]]) after attaching the connector. Omit unused optional parameters and keep real values out of saved SQL and logs.

After installing VGI and attaching the connector, create the required secrets using your own values. Replace placeholders and omit unused optional parameters from the templates below.

### arcgis

Credentials for token-secured ArcGIS REST services (ArcGIS Server, ArcGIS Enterprise and ArcGIS Online) read by arcgis_query: a pre-generated ArcGIS token, an ArcGIS username and password, or an ArcGIS OAuth app's client_id and client_secret. Give it a SCOPE (a URL prefix such as 'https://host/arcgis/rest/services/') so it is only sent to that server; the longest matching scope wins.
[Credential instructions](https://developers.arcgis.com/documentation/security-and-authentication/)

```json
[
  {
    "name": "token",
    "type": "VARCHAR",
    "required": false,
    "redact": true,
    "description": "A pre-generated ArcGIS token (from the server's generateToken page, or an ArcGIS Online API key), sent as the token parameter as is. Generate it with client=requestip, or with referer https://github.com/Query-farm/vgi-arcgis. It is not renewed when it expires."
  },
  {
    "name": "username",
    "type": "VARCHAR",
    "required": false,
    "redact": false,
    "description": "ArcGIS Server, ArcGIS Enterprise or ArcGIS Online user name; exchanged with password for a token at the server's token service (authInfo.tokenServicesUrl of <server>/rest/info)."
  },
  {
    "name": "password",
    "type": "VARCHAR",
    "required": false,
    "redact": true,
    "description": "Password of username. Sent only to the server's token service, over HTTPS."
  },
  {
    "name": "client_id",
    "type": "VARCHAR",
    "required": false,
    "redact": false,
    "description": "Client ID of an ArcGIS OAuth application (ArcGIS Online or an ArcGIS Enterprise portal: Content > the app item > Settings), used with client_secret for the client-credentials flow."
  },
  {
    "name": "client_secret",
    "type": "VARCHAR",
    "required": false,
    "redact": true,
    "description": "Client secret of the OAuth application named by client_id. Sent only to the portal's oauth2/token endpoint, over HTTPS."
  }
]
```

```sql
CREATE SECRET arcgis (
    TYPE arcgis,
    token         '<ARCGIS_TOKEN>',  -- secret
    username      '<username>',
    password      '<ARCGIS_PASSWORD>',  -- secret
    client_id     '<client_id>',
    client_secret '<ARCGIS_CLIENT_SECRET>'  -- secret
);
```

ATTACH options (exact declarations; omitted defaults are unknown):

```json
[
  {
    "name": "url",
    "type": "VARCHAR",
    "description": "ArcGIS REST URL to expose as tables: a services directory (.../arcgis/rest/services or a folder), a service (.../FeatureServer or .../MapServer) or a single layer (.../FeatureServer/0); or an ArcGIS Hub / Open Data site (https://<site>, one schema per service in its catalog) or one of its dataset pages (https://<site>/datasets/<id>, resolved to the REST layer or service). Omit it to use the ArcGIS query, summary and imagery functions without catalog views.",
    "required": false,
    "default": null
  },
  {
    "name": "precision",
    "type": "INTEGER",
    "description": "Decimal places kept in returned coordinates (ArcGIS geometryPrecision), 0-15. 7 is about 1 cm in longitude/latitude.",
    "required": false,
    "default": "7"
  },
  {
    "name": "token",
    "type": "VARCHAR",
    "description": "A pre-generated ArcGIS token for token-secured services, sent as the token parameter on requests to the ATTACH url's server only (credentials require url). Not renewed: when it expires, attach again. Pass it as token getenv('ARCGIS_TOKEN') to keep it out of the SQL text.",
    "required": false,
    "default": null
  },
  {
    "name": "username",
    "type": "VARCHAR",
    "description": "ArcGIS Server, ArcGIS Enterprise or ArcGIS Online user name. With password, the worker generates tokens at the server's token service (from <server>/rest/info) and renews them before they expire.",
    "required": false,
    "default": null
  },
  {
    "name": "password",
    "type": "VARCHAR",
    "description": "Password for username, sent only to the server's token service over HTTPS. Pass it as password getenv('ARCGIS_PASSWORD').",
    "required": false,
    "default": null
  },
  {
    "name": "client_id",
    "type": "VARCHAR",
    "description": "Client ID of an ArcGIS OAuth application (ArcGIS Online or an ArcGIS Enterprise portal). With client_secret, the worker gets app tokens with the OAuth client-credentials flow and renews them.",
    "required": false,
    "default": null
  },
  {
    "name": "client_secret",
    "type": "VARCHAR",
    "description": "Client secret of the OAuth application named by client_id, sent only to the portal's oauth2/token endpoint over HTTPS. Pass it as client_secret getenv('ARCGIS_CLIENT_SECRET').",
    "required": false,
    "default": null
  }
]
```

## Install the extension

In stock DuckDB:

```sql
SET allow_extension_repositories = 'allowed';

CREATE EXTENSION REPOSITORY IF NOT EXISTS query_farm
    WITH PREFIX 'https://duckdb-extensions.query.farm';

INSTALL vgi FROM query_farm;
LOAD vgi FROM query_farm;
```

In Haybarn:

```sql
INSTALL vgi FROM community;
LOAD vgi;
```

## Attach the connector

The local recipes below pin the catalog release for repeatability. A public demo endpoint follows its deployed release.

### From GitHub

Attach the release directly

Uses the verified release each time you attach the connector.

```sql
ATTACH 'arcgis' AS arcgis (
  TYPE vgi,
  LOCATION 'github-auto://Query-farm/vgi-arcgis@v0.7.0'
);
```

### Docker

Attach the signed image

Needs Docker, Podman or another OCI runtime. The extension runs the container and talks to it over stdio.

```sql
ATTACH 'arcgis' AS arcgis (
  TYPE vgi,
  LOCATION 'oci://ghcr.io/query-farm/vgi-arcgis:0.7.0'
);
```

## Count the parcels in Covington, Virginia (FIPS 51580); the filter runs on the ArcGIS server

Service credentials required for this example: not declared by this example; check the connector requirements above.

```sql
SELECT LOCALITY, count(*) AS parcels FROM arcgis.main.arcgis_query('https://vginmaps.vdem.virginia.gov/arcgis/rest/services/VA_Base_Layers/VA_Parcels/FeatureServer/0') WHERE FIPS = '51580' GROUP BY ALL
```

- [arcgis.main.arcgis_query — table_function](https://query.farm/products/orchard/connectors/arcgis/objects/table_function.bWFpbg.YXJjZ2lzX3F1ZXJ5.md): exact declaration for this example.

Execution evidence: **captured_result**.

```json
{
  "status": "captured_result",
  "capturedAt": "2026-12-01T06:12:39+00:00",
  "engineVersion": "2.0.1",
  "protocolVersion": "3.4.0",
  "releaseTag": "v0.7.0",
  "sample": {
    "columns": [
      "LOCALITY",
      "parcels"
    ],
    "types": [
      "VARCHAR",
      "BIGINT"
    ],
    "rows": [
      [
        "Covington City",
        5811
      ]
    ],
    "more": false
  }
}
```

## Connector reference

### ArcGIS REST services in DuckDB

Government agencies, utilities and organizations worldwide publish their GIS data as ArcGIS REST services. This worker reads them live, from whatever service URL you give it: there is no built-in list of agencies, and no data is copied or cached apart from layer metadata.

## Two ways in

Call a function with a layer URL when you already know the layer. The functions read features, count or summarize them on the server (so a ten-million-parcel layer is never downloaded to answer a count), or sample ImageServer pixel values such as elevation at a batch of points.

Attach with a `url` option when you want to browse. A services directory (`.../arcgis/rest/services`) becomes one schema per service with one view per layer; a single service (`.../FeatureServer`) becomes one view per layer in `main`; a layer (`.../FeatureServer/0`) becomes one view. An ArcGIS Hub or Open Data site (such as `https://gis.data.ca.gov`) works like a services directory, and a Hub dataset page (`.../datasets/<itemId>_0`) resolves to the REST layer behind it.

```sql
ATTACH 'arcgis' AS va (TYPE vgi, LOCATION 'github-auto://Query-farm/vgi-arcgis@v0.6.1',
  url 'https://vginmaps.vdem.virginia.gov/arcgis/rest/services/VA_Base_Layers/VA_Admin_Boundaries/FeatureServer');
SHOW ALL TABLES;
```

## Geometry and filters

Attribute fields arrive as typed columns and feature geometry as a WGS84 `GEOMETRY` column, rounded to `precision` decimals (default 7, about 1 cm). Simple filters (numeric comparisons, string equality and `IN`, `IS NULL`, prefix matches) and spatial filters against a constant (`geometry && <box>`, `ST_Intersects`, `ST_Within`, ...) are sent to the ArcGIS server, and every filter is also applied exactly in the worker, so results never depend on how much the server understood. Pages are fetched automatically.

## Secured services

Public services need no credentials. For token-secured ones, either ATTACH with the secret options `token`, `username` + `password`, or `client_id` + `client_secret` (redacted from `duckdb_databases()` and sent only to the ATTACH `url`'s server), or create an `arcgis` secret scoped to a URL prefix for the functions. Generated tokens are renewed automatically; `getenv()` keeps a credential out of the SQL text:

```sql
CREATE SECRET gis_token (TYPE arcgis, TOKEN getenv('ARCGIS_TOKEN'),
  SCOPE 'https://gis.example.gov/arcgis/rest/services/');
```

## Sources

Every query goes live to the ArcGIS server named by the URL you supply, through the public ArcGIS REST API:

- Feature scans, counts and statistics use [Query (Feature Service/Layer)](https://developers.arcgis.com/rest/services-reference/enterprise/query-feature-service-layer/) and [Query (Map Service/Layer)](https://developers.arcgis.com/rest/services-reference/enterprise/query-map-service-layer/).
- Services directories are walked through the [Services Directory root](https://developers.arcgis.com/rest/services-reference/enterprise/catalog/).
- Imagery sampling uses [Get Samples](https://developers.arcgis.com/rest/services-reference/enterprise/get-samples/) on an ImageServer.
- ArcGIS Hub sites and dataset pages are resolved through the [Hub API](https://hub.arcgis.com/api/v3/).
- Secured services: [Generate Token](https://developers.arcgis.com/rest/services-reference/enterprise/generate-token/), the portal [/token](https://developers.arcgis.com/rest/users-groups-and-items/token/) OAuth endpoint, and Esri's [security and authentication guide](https://developers.arcgis.com/documentation/security-and-authentication/).

## Find the exact SQL object

[Browse 4 object declarations](https://query.farm/products/orchard/api/v1/connectors/arcgis/objects.json) or [search within this connector](https://query.farm/products/orchard/api/v1/search.json?kind=object&connector=arcgis&q=arcgis).

Follow one format of each needed object for complete argument types, defaults, named flags, return columns and examples. Existing links above can replace another search. For questions about hosting, credentials or supported operations, stop once the documentation answers the question; SQL and unrelated object lookups are unnecessary.

## Verification and interpretation

- Missing, null, or undeclared metadata means unknown; do not invent defaults, credential scope, platform support or endpoint URLs.
- Search is keyword retrieval, not proof of a capability. Read the exact object declaration before generating SQL.
- A table and a table function can have the same name. Preserve parentheses and use the matching overload and schema.
- Service credentials, external data availability and deployment authentication are separate requirements.
- Catalog verification records the harvest environment. It is not proof that every query or current live API call succeeds. Only an example with captured_result has a saved result for that exact SQL.

```json
{
  "generatedAt": "2026-12-01T18:22:16+00:00",
  "repository": "https://github.com/Query-farm/vgi-arcgis",
  "harvest": {
    "status": "ok",
    "method": "github-auto",
    "error": null,
    "vgi_version": "9773130dde"
  },
  "catalogVerification": {
    "verified": true,
    "status": "passed",
    "total": 1,
    "passed": 1,
    "failed": 0,
    "needs_credentials": 0,
    "location": "github-auto://Query-farm/vgi-arcgis@v0.7.0",
    "transport": "github-auto",
    "environment": {
      "vgi_extension_version": "9773130dde",
      "haybarn_version": "2.0.1rc3",
      "engine_version": "v2.0.1",
      "python": "3.12.4",
      "platform": "darwin_arm64",
      "protocol_version": "3.4.0"
    },
    "checked_at": "2026-12-01T06:09:55+00:00"
  },
  "interpretation": "Catalog verification records the harvest environment. It is not proof that every query or current live API call succeeds. Only an example with captured_result has a saved result for that exact SQL."
}
```
