An extract analysis resulting in a new item that contains exported census block features in KML format.
An extract analysis is the process of selecting and exporting features from one or more feature collections or layers that satisfy a SQL and/or spatial expression. The analysis can export features to CSV, KML, file geodatabase, or Shapefile format. To execute the analysis, use the spatial analysis service and the Extract Data
operation.
More info Multi-file formats are stored in a zip file.
Real-world examples of this analysis include the following:
Exporting all, or a subset of the data,for further analysis using tools such as spreadsheets or ArcGIS Pro. Creating a backup of the data and generate reports. Preparing and loading the data into other systems. The general steps to extracting features are as follows:
Review the parameters for the Extract Data
operation. Determine if you would like the results as a feature collection (dynamic) or hosted feature layer (stored). Send a request to get the spatial analysis service URL. Execute a job request with the following URL and parameters: URL: https: //< YOUR_ ANALYSIS_ SERVICE>/arcgis/rest/services/tasks/GPServer/Extract Data/submit Job
Parameters:input Layers
: The feature collection(s) or hosted feature layer(s) from which you want to extract features.clip
: If you want the data extracted from within the extent.data Format
: The type of file you want (CSV, Shapefile, KML, FileGeoDatabase).output Name
: A string representing the name of the hosted feature layer to reutrn with the results. Check the status . Get the output layer results . To see examples using ArcGIS API for Python, ArcGIS REST JS, and the ArcGIS REST API, go to Examples below.
The item will appear in the My contents page in ArcGIS Online.
URL request
Use dark colors for code blocks Copy
1
https : //<YOUR_ANALYSIS_SERVICE>/arcgis/rest/services/tasks/GPServer/ExtractData/submitJob?<parameters>
Required parameters Name Description Examples f
The format of the data returned. f=json
f=pjson
token
An OAuth 2.0 access token . Learn how to get an access token in Security and authentication . token=< ACCESS_ TOKEN>
input Layers
The point, polyline, or polygon features that will be extracted. [{"url":"https: //services3.arcgis.com/GVgb Jbqm8h XASVYi/arcgis/rest/services/Find_ Locations_ i n_ SF_ Neighborhoods/Feature Server/0"}]
Key parameters Name Description Examples data Format
The default file format is CSV. KML
, File G e o Database
, CSV
, Shapefile
clip
Define whether the data should be extracted from within the extent. true
extent
The area used to extract the input features. [{"url":"https: //services3.arcgis.com/GVgb Jbqm8h XASVYi/arcgis/rest/services/Portland_ boundary/Feature Server/0"}]
output Name
A string representing the name of the hosted feature layer to return with the results. NOTE : If you do not include this parameter, the results are returned as a feature collection (JSON). {"service Properties": {"name": "< SERVICE_ NAME>"}}
Code examples Export all data as CSV This example uses the Extract Data
operation to extract traffic crash incidents in San Francisco. The input Layers
value is the Traffic Crashes hosted feature layer and the Data Format
value is set to export the features as CSV.
Extract features represent traffic crashes in CVS format.
APIs ArcGIS API for Python ArcGIS API for Python ArcGIS REST JS
Expand
Use dark colors for code blocks Copy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
traffic_crashes = "https://services3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/Traffic_Crashes/FeatureServer/0"
neighborhoods = "https://services3.arcgis.com/GVgbJbqm8hXASVYi/ArcGIS/rest/services/SF_Neighborhoods/FeatureServer/0"
results = extract_data(
input_layers=[traffic_crashes],
extent= neighborhoods,
clip= False ,
data_format= "CSV" , # default
output_name={ "title" : "Extract data results" } #Creates a new item.
)
Service requests 1. Get the analysis service URL 2. Submit job 3. Check job status 4. Get results
Request HTTP HTTP cURL
Use dark colors for code blocks Copy
1
2
3
4
5
POST arcgis.com/sharing/rest/portals/self HTTP/ 1.1
Content- Type : application/x-www-form-urlencoded
&f = json
&token = <ACCESS_TOKEN>
Response (JSON)
Use dark colors for code blocks Copy
1
2
3
4
5
6
7
8
9
10
11
{
"helperServices" : {
// Other parameters
"analysis" : {
"url" : "https://<YOUR_ANALYSIS_SERVICE>/arcgis/rest/services/tasks/GPServer"
},
"geoenrichment" : {
"url" : "https://geoenrich.arcgis.com/arcgis/rest/services/World/GeoenrichmentServer"
}
}
}
Request HTTP HTTP cURL
Use dark colors for code blocks Copy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
POST <YOUR_ANALYSIS_SERVICE>/arcgis/rest/services/tasks/GPServer/ExtractData/submitJob HTTP/ 1.1
Content- Type : application/x-www-form-urlencoded
f = json
&token = <ACCESS_TOKEN>
&inputLayers = [ { "url" : "https://services3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/Traffic_Crashes/FeatureServer/0" } ]
&clip = false
&dataFormat = CSV
&extent = { "url" : "https://services3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/SF_Neighborhoods/FeatureServer/0" }
&outputName = { "itemProperties" : { "title" : "Extract data results" } }
Response (JSON)
Use dark colors for code blocks Copy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
{
"jobId" : "<JOB_ID>" ,
"jobStatus" : "esriJobSubmitted" ,
"results" : {},
"inputs" : {},
"messages" : []
}
Request HTTP HTTP cURL
Use dark colors for code blocks Copy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
POST <YOUR_ANALYSIS_SERVICE>/arcgis/rest/services/tasks/GPServer/ExtractData/job/<JOB_ID> HTTP/ 1.1
Content- Type : application/x-www-form-urlencoded
f = json
&token = <ACCESS_TOKEN>
Response (JSON)
Use dark colors for code blocks Copy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// Executing job
{
"jobId" : "<JOB_ID>" ,
"jobStatus" : "esriJobExecuting" ,
"results" : {},
"inputs" : {},
"messages" : []
}
// Job succeeded
{
"jobId" : "<JOB_ID>" ,
"jobStatus" : "esriJobSucceeded" ,
"results" : { "contentID" : { "paramUrl" : "results/contentID" }},
"inputs" : {},
"messages" : []
}
Request HTTP HTTP cURL
Use dark colors for code blocks Copy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
POST <YOUR_ANALYSIS_SERVICE>/arcgis/rest/services/tasks/GPServer/ExtractData/jobs/<JOB_ID>/results/contentID HTTP/ 1.1
Content- Type : application/x-www-form-urlencoded
f = json
&token = <ACCESS_TOKEN>
&returnType = data
Response (JSON)
Use dark colors for code blocks Copy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
{
"paramName" : "contentID" ,
"dataType" : "GPString" ,
"value" : {
"url" : "<SERVICE_URL>" ,
"itemId" : "<ITEM_ID>"
}
}
Export a subset of data as CSV This example uses the Extract Data
operation to clip instances of graffiti within three neighborhoods of San Francisco and export them as CSV. The input Layers
is the Graffiti cases within SF and the Extent
is the Census blocks in three neighborhoods hosted feature layers. The clip
parameter is set to true
so that only those features that intersect the boundary layer are exported.
Clip features within a boundary to export in CVS format.
APIs ArcGIS API for Python ArcGIS API for Python ArcGIS REST JS
Expand
Use dark colors for code blocks Copy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
graffiti = "https://services3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/Graffiti_cases_within_SF/FeatureServer/0"
three_neighborhoods = "https://services3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/Census_blocks_in_three_neighborhoods_SF/FeatureServer/0"
results = extract_data(
input_layers=[graffiti],
extent= three_neighborhoods,
clip= True ,
data_format= "CSV" , # default
output_name={ "title" : "Extract data results" } #Creates a new item.
)
Service requests 1. Get the analysis service URL 2. Submit job 3. Check job status 4. Get results
Request HTTP HTTP cURL
Use dark colors for code blocks Copy
1
2
3
4
5
POST arcgis.com/sharing/rest/portals/self HTTP/ 1.1
Content- Type : application/x-www-form-urlencoded
&f = json
&token = <ACCESS_TOKEN>
Response (JSON)
Use dark colors for code blocks Copy
1
2
3
4
5
6
7
8
9
10
11
{
"helperServices" : {
// Other parameters
"analysis" : {
"url" : "https://<YOUR_ANALYSIS_SERVICE>/arcgis/rest/services/tasks/GPServer"
},
"geoenrichment" : {
"url" : "https://geoenrich.arcgis.com/arcgis/rest/services/World/GeoenrichmentServer"
}
}
}
Request HTTP HTTP cURL
Use dark colors for code blocks Copy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
POST <YOUR_ANALYSIS_SERVICE>/arcgis/rest/services/tasks/GPServer/ExtractData/submitJob HTTP/ 1.1
Content- Type : application/x-www-form-urlencoded
f = json
&token = <ACCESS_TOKEN>
&inputLayers = [ { "url" : "https://services3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/Graffiti_cases_within_SF/FeatureServer/0" } ]
&clip = true
&dataFormat = CSV
&extent = { "url" : "https://services3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/Census_blocks_in_three_neighborhoods_SF/FeatureServer/0" }
&outputName = { "itemProperties" : { "title" : "Extract data results" } }
Response (JSON)
Use dark colors for code blocks Copy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
{
"jobId" : "<JOB_ID>" ,
"jobStatus" : "esriJobSubmitted" ,
"results" : {},
"inputs" : {},
"messages" : []
}
Request HTTP HTTP cURL
Use dark colors for code blocks Copy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
POST <YOUR_ANALYSIS_SERVICE>/arcgis/rest/services/tasks/GPServer/ExtractData/job/<JOB_ID> HTTP/ 1.1
Content- Type : application/x-www-form-urlencoded
f = json
&token = <ACCESS_TOKEN>
Response (JSON)
Use dark colors for code blocks Copy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// Executing job
{
"jobId" : "<JOB_ID>" ,
"jobStatus" : "esriJobExecuting" ,
"results" : {},
"inputs" : {},
"messages" : []
}
// Job succeeded
{
"jobId" : "<JOB_ID>" ,
"jobStatus" : "esriJobSucceeded" ,
"results" : { "contentID" : { "paramUrl" : "results/contentID" }},
"inputs" : {},
"messages" : []
}
Request HTTP HTTP cURL
Use dark colors for code blocks Copy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
POST <YOUR_ANALYSIS_SERVICE>/arcgis/rest/services/tasks/GPServer/ExtractData/jobs/<JOB_ID>/results/contentID HTTP/ 1.1
Content- Type : application/x-www-form-urlencoded
f = json
&token = <ACCESS_TOKEN>
&returnType = data
Response (JSON)
Use dark colors for code blocks Copy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
{
"paramName" : "contentID" ,
"dataType" : "GPString" ,
"value" : {
"url" : "<SERVICE_URL>" ,
"itemId" : "<ITEM_ID>"
}
}
Tutorials Learn how to perform related analyses interactively with Map Viewer and programmatically with ArcGIS API for Python, ArcGIS REST JS, and ArcGIS REST API.
Services Process spatial datasets to discover relationships and patterns.
API support Full support Partial support No support