Download OGC GeoPackage from Hosted ArcGIS Feature Services

1139
0
07-29-2020 09:09 AM
AdamMartin
Esri Contributor
3 0 1,139

We have previously written about Geopackage support in ArcGIS Pro 2.6, but a lesser known fact is that ArcGIS Online* also allows exporting Esri services as OGC GeoPackages

 

This "hidden feature" is not currently exposed in the Item Page user interface for "Export Data"...or available in ArcGIS Server or Enterprise.

 

However, it is exposed by ArcGIS Online within the Create Replica REST API service endpoint. This feature allows Hosted Feature/Raster and Vector Tile Service layers to be exported as GeoPackages.

 

If you are navigating in the Browser, you can just go to Create Replica Operation as part of the Feature Service HTML user interface. 

 

 

How to Download a GeoPackage

 

In order to get this Create Replica API endpoint, you first need to Enable Syncing on the Feature Service. You can get to this in the Item Page, going to the Settings tab..

...scroll down

  

 

Then go to the Service URL, for example:  https://services.arcgis.com/XTtANUDT8Va4DLwI/arcgis/rest/services/Territorial_Authority_2019_Clipped... 

 

Set the key @@Parameters as follows:

  • Layers : 0 (or whichever layer you want to download)
  • returnAttachments : false
  • async : true
  • syncModel : none
  • syncDirection: download
  • DataFormat : GPKG

 

Export Geopackages from Hosted Services

 

Then 'create Replica" will initiate the creation the GeoPackage download file and provide a Status URL at the bottom of the page.

 

 

Click the statusURL, and at this Status URL, once the processing is complete, you will receive the "Results URL" as per below.

 

Finally, click the Results URL and the file will download locally. Then open it up wherever GeoPackages are supported.

 

From ArcGIS Pro, just Add Data and navigate to the downloaded file.

 

...and, voila!

 

Of course, given these are API calls, these steps can be set up programmatically as part of a regular ETL workflow, e.g. scheduling an ArcGIS Notebook to run and use the ArcGIS API for Python or scheduling a job to run using a workbench created in the no-code ArcGIS Data Interoperability Extension and use the HTTPCaller transformer.

 

Here's the download Geopackage example REST API call: 

(POST) https://services8.arcgis.com/QQGMu3AgoCvivmaQ/ArcGIS/rest/services/Nashville_Bldg_Permits/FeatureSer...

 

If the item is public just substitute the relevant parts of your item's Service URL. If the item is private you'll also need to generate and append a 'token' at the end of this string.

 

If you are not a developer, this URL won't work by just putting it in a browser because it requires an HTTP POST method, and browsers follow GET method by default, so you'll have to use some tool like Postman.

 

Happy downloading!

 

#geopackage#arcgis-online#arcgis-enterprise

 

*‌ Updated August 19, 2021. The original post incorrectly stated that ArcGIS Enterprise also supported the Create Replica API for GeoPackage exports. However, currently only Hosted Feature Services in ArcGIS Online supports this functionality.

About the Author
Product Manager, Strategy and Outreach, Open Platform