Analyze

Description

The Analyze call helps a client analyze a CSV or Excel file (.xlsx, .xls) prior to publishing or generating features using the Publish or Generate operation, respectively.

Analyze returns information about the file including the fields present as well as sample records. Analyze attempts to detect the presence of location fields that may be present as either X,Y fields or address fields.

Analyze packages its result so that publishParameters within the JSON response contains information that can be passed back to the server in a subsequent call to Publish or Generate. The publishParameters subobject contains properties that describe the resulting layer after publishing, including its fields, the desired renderer, and so on. Analyze will suggest defaults for the renderer.

In a typical workflow, the client will present portions of the Analyze results to the user for editing before making the call to Publish or Generate.

If the file to be analyzed currently exists in the portal as an item, callers can pass in its itemId. Callers can also directly post the file. In this case, the request must be a multipart post request pursuant to IETF RFC1867. The third option for text files is to pass the text in as the value of the text parameter.

Request Parameters

Parameter

Details

f

The output format is JSON.

itemid

The ID of the item to be analyzed.

Example: id=345313e619df46f387f9ededbe15ac56

file

The file to be analyzed.

Example: file=mystreets.csv

text

The text in the file to be analyzed.

Example: text=<text_in_file>

filetype

The type of input file.

Values: csv | excel

Example: fileType=csv

analyzeParameters

A JSON object that provides geocoding information

Example: analyzeParameters:{"sourceLocale":"en"}

Analyze Parameters JSON object

The analyzeParameters JSON object used to analyze a CSV or Excel file are described below.

Parameter

Details

sourcelocale

The locale used for the geocoding service source.

geocodeServiceUrl

The URL of the geocoding service that supports batch geocoding.

NoteNote:

ArcGIS for Portal 10.3 supports configuring multiple geocoding services. If the client application requires a specific locator, the URL of this service should be specified in this parameter.

locationType

Indicates the type of spatial information stored in the dataset.

Values for CSV: coordinates | address | lookup | none

Values for Excel: coordinates | address | none

sourcecountry

The two character country code associated with the geocoding service, default is "world".

sourcecountryhint

If first time analyzing, the hint is used. If source country is already specified than sourcecountry is used.

A sample analyzeParameters JSON object for a CSV or Excel is as follows:

{
   "enableGlobalGeocoding": true,
   "sourceLocale":"en",
   "geocodeServiceUrl": "https://<server>/sharing/rest/services/World/GeocodeServer",
   "locationType": "address",
   "sourceCountry":"",
   "sourceCountryHint":"world"
}

Example Usage for CSV

http://www.arcgis.com/sharing/rest/content/features/analyze
itemid=345313e619df46f387f9ededbe15ac56
filetype=csv

JSON Response Example

{
   "fileSize": 921,
   "fileUrl": "http://www.arcgis.com/sharing/rest/content/items/345313e619df46f387f9ededbe15ac56/data?token=",
   "publishParameters":{
      "type": "csv",
	    	"name": "data",
		    "sourceUrl": "",
		    "locationType": "address",
		    "maxRecordCount": 1000,
		    "geocodeServiceUrl": "http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer",
	    	"sourceCountry": "us",
		    "sourceLocale": "en",
		    "addressFields": {
		       	"Address": "Street",
		       	"City": "City",
			       "Region": "State",
			       "Postal": "Zip"
	        	},
		   "standardizedFieldNames": {
		  	     "Address": "Street",
			       "City": "City",
			       "Region": "State",
			       "Postal": "ZIP",
			       "PostalExt": "ZIP4",
			       "CountryCode": "Country"
		        },
		   "columnDelimiter": ",",
      ....
   },
   "records":[
      {
        "attributes": {
			       "Name": "ESRI-California",
			       "Street": "380 New York Street",
		       	"City": "Redlands",
			       "State": "CA",
		       	"Zip": "92373-8100"
		       }
     	}, {
		        "attributes": {
			       "Name": "ESRI-Denver",
			       "Street": "One International Court",
			       "City": "Broomfield",
			       "State": "CO",
			       "Zip": "80021-3200"
		       }
	    },
     ...     
    ]
  }

Example Usage for Excel

http://www.arcgis.com/sharing/rest/content/features/analyze
itemid=a48f99193139447ba64b721450fb00bd
filetype=excel

JSON Response Example

{
   "fileUrl": "http://www.arcgis.com/sharing/rest/content/items/a48f99193139447ba64b721450fb00bd/data?token=",
   "publishParameters":{
      "type": "excel",
		    "name": "data",
		    "sourceUrl": "",
		    "maxRecordCount": 2000,
		    "sourceSR": {
		   	   "wkid": 4326,
			      "latestWkid": 4326
		       },
		    "targetSR": {
			      "wkid": 102100,
			      "latestWkid": 3857
		       },
	    	"editorTrackingInfo": {
			      "enableEditorTracking": false,
			      "enableOwnershipAccessControl": false,
			      "allowOthersToQuery": true,
			      "allowOthersToUpdate": true,
			      "allowOthersToDelete": false,
			      "allowAnonymousToUpdate": true,
			      "allowAnonymousToDelete": true
		       },
		    "hasAttachments": false,
		    "capabilities": "Create,Delete,Query,Update,Editing",
      ....
   },
   "records": null,
  }

For a complete description of publishParameters, see Publish Item.

10/6/2017