FRAMES | NO FRAMES |
Aggregates data from a point layer (e.g. customer layer) to a polygon layer (e.g. trade area).
Availability: Business Analyst Server 10.0 SP1.
TaskResultOutput SummarizePoints ( SummarizePointsParameters Parameters, esriReportFormat ReportFormat, RenderingParameters RenderingParameters, TaskOutputType[] OutputTypes, esriFolderItem OutputAnalysisItem, esriFolderItem OutputReportItem );
Parameter | Description |
---|---|
Parameters | Configuration options for analysis. Type SummarizePointsParameters. |
ReportFormat | This parameter should be null. This parameter is deprecated. |
RenderingParameters | Configuration options for rendering output when GetMapImage option is specified in the OutputTypes parameter. Type RenderingParameters. |
OutputTypes | Array of task output options. Options for this method include rendering output image (GetMapImage), creating a feature layer for subsequent analysis (GetFeatureClass), and creating a report (GetReport). Type TaskOutputType[]. |
OutputAnalysisItem | (Optional
parameter — can be null). Configuration options for storing the output feature layer in the repository. This will enable viewing and working with the output result in subsequent tasks. Type esriFolderItem. |
OutputReportItem | (Optional
parameter — can be null). Configuration options for storing the output report in the repository. This will enable viewing and working with the output result in subsequent tasks. Type esriFolderItem. |
Variable of type TaskResultOutput
This method allows you to take point data (e.g. customer data) in Business Analyst along with any associated volumetric data and sum that data up to any boundary layer (e.g. Census Tracts). For example, if you needed to see the distribution of the sales data associated with your customer points across the ZIP Codes in your market, this endpoint would allow you to see total sales associated with each ZIP Code of your interest. It would perform this function by automatically selecting all the points which fall into each ZIP Code and then summing up the selected fields to each ZIP Code boundary.
The example below aggregates points to a custom trade area and generates a report.
C# |
// Instantiate the BAServerHelper class to access analysis methods BAServerHelper baServerHelper = new BAServerHelper(); baServerHelper.ActiveDatasetID = "USA_ESRI"; // Optional parameter baServerHelper.IsFullErrorMessage = true; // Default is false // You can specify below a domain of your local Business Analyst Server. //baServerHelper.BAServerDomain = "esri.com"; // If a domain name is specified, a local server name in output URLs is replaced with the // fully-addressable server name so people and machines outside the domain of your local // Business Analyst Server instance can access these URLs. RenderingParameters imageOptions; TaskOutputType[] outputOptions; esriFolderItem outputLayer; esriFolderItem outputReport; // ========= STEP 1: Create a record set by store addresses RecordSetByAddress[] storeAddresses = new RecordSetByAddress[2]; storeAddresses[0] = new RecordSetByAddress(); storeAddresses[0].Name = "location1"; storeAddresses[0].Description = "Downtown Location"; storeAddresses[0].StoreID = "1"; storeAddresses[0].Address = "1401 Kettner Blvd."; storeAddresses[0].City = "San Diego"; storeAddresses[0].State = "CA"; storeAddresses[0].ZIP = "92101"; storeAddresses[1] = new RecordSetByAddress(); storeAddresses[1].Name = "location2"; storeAddresses[1].Description = "Clairemont Location"; storeAddresses[1].StoreID = "2"; storeAddresses[1].Address = "5407 Balboa Ave."; storeAddresses[1].City = "San Diego"; storeAddresses[1].State = "CA"; storeAddresses[1].ZIP = "92111"; TaskResultOutput storeRecordSetResult = baServerHelper.CreateRecordSetByAddresses(storeAddresses, esriFolderType.esriFolderStoreLayers); TableData tableData = new TableData(); tableData.RecordSet = storeRecordSetResult.RecordSet; GeocodeData geocodeData = new GeocodeData(); geocodeData.Table = tableData; // ========= STEP 2: Geocode the record set with stores CustomerStoreSetupByGeocodeTableParameters geocodeParameters = new CustomerStoreSetupByGeocodeTableParameters(); // Set specific analysis parameters geocodeParameters.GeocodeCustomers = false; geocodeParameters.GeocodeData = geocodeData; geocodeParameters.NameField = "NAME"; geocodeParameters.StoreIDField = "STORE_ID"; // Set other parameters imageOptions = null; outputOptions = new TaskOutputType[] { TaskOutputType.GetFeatureClass }; // In general, a non-null esriFolderItem is specified to save a newly-created // item to the server-side repository or to reference an existing item in it. outputLayer = new esriFolderItem(); outputLayer.folderType = esriFolderType.esriFolderStoreLayers; outputLayer.itemName = "storeLayer_SummarizePoints"; outputLayer.workspaceName = "Default Workspace"; outputLayer.projectName = "Default Project"; TaskResultOutput storeGeocodeResult = baServerHelper.CustomerStoreSetupByGeocodeTable(geocodeParameters, imageOptions, outputOptions, outputLayer); PointLayer storeLayer = new PointLayer(); storeLayer.RecordSet = storeGeocodeResult.RecordSet; // ========= STEP 3: Create simple rings around stores SimpleRingsParameters simpleRingsParameters = new SimpleRingsParameters(); // Set specific analysis parameters simpleRingsParameters.DistanceUnits = esriUnits.esriMiles; simpleRingsParameters.Radii = new double[] { 1, 3, 5 }; simpleRingsParameters.StoreIDField = "STORE_ID"; simpleRingsParameters.Stores = storeLayer; // Set other parameters imageOptions = null; outputOptions = new TaskOutputType[] { TaskOutputType.GetFeatureClass }; outputReport = null; // In general, a non-null esriFolderItem is specified to save a newly-created // item to the server-side repository or to reference an existing item in it. outputLayer = new esriFolderItem(); outputLayer.folderType = esriFolderType.esriFolderTradeAreas; outputLayer.itemName = "tradeArea_SummarizePoints"; outputLayer.workspaceName = "Default Workspace"; outputLayer.projectName = "Default Project"; TaskResultOutput simpleRingsResult = baServerHelper.SimpleRings(simpleRingsParameters, imageOptions, outputOptions, outputLayer, outputReport); DataLayer boundaryLayer = new DataLayer(); boundaryLayer.RecordSet = simpleRingsResult.RecordSet; // ========= STEP 4: Geocode the record set with customers // --------- Prepare the table for geocoding RecordSet table = new RecordSet(); // Create table fields string[] fieldNames = new string[] { "CUST_ID", "NAME", "ADDRESS", "CITY", "STATE", "ZIP", "STORE_ID", "SALES" }; table.Fields = new Fields(); table.Fields.FieldArray = new Field[fieldNames.Length]; for (int i = 0; i < fieldNames.Length; i++) { Field field = new Field(); field.Name = fieldNames[i]; field.Type = esriFieldType.esriFieldTypeString; table.Fields.FieldArray[i] = field; } // The last field is numeric table.Fields.FieldArray[fieldNames.Length - 1].Type = esriFieldType.esriFieldTypeInteger; // Create table records table.Records = new Record[7]; table.Records[0] = new Record(); table.Records[0].Values = new object[] { "1", "customer1", "5080 Newport Ave.", "San Diego", "CA", "92107", "1", 12343 }; table.Records[1] = new Record(); table.Records[1].Values = new object[] { "2", "customer2", "1250 Prospect St.", "La Jolla", "CA", "92037", "1", 10008 }; table.Records[2] = new Record(); table.Records[2].Values = new object[] { "3", "customer3", "1762 Garnet Ave.", "San Diego", "CA", "92109", "1", 3200 }; table.Records[3] = new Record(); table.Records[3].Values = new object[] { "4", "customer4", "1240 W. Morena Blvd.", "San Diego", "CA", "92111", "2", 15802 }; table.Records[4] = new Record(); table.Records[4].Values = new object[] { "5", "customer5", "6393 Balboa Ave.", "San Diego", "CA", "92111", "2", 4750 }; table.Records[5] = new Record(); table.Records[5].Values = new object[] { "6", "customer6", "5735 La Jolla Blvd.", "La Jolla", "CA", "92037", "2", 4459 }; table.Records[6] = new Record(); table.Records[6].Values = new object[] { "7", "customer7", "3254 Governor Dr.", "San Diego", "CA", "92122", "1", 25443 }; tableData = new TableData(); tableData.RecordSet = table; // Specify geocode data geocodeData = new GeocodeData(); geocodeData.Table = tableData; // --------- Geocode the table geocodeParameters = new CustomerStoreSetupByGeocodeTableParameters(); // Set specific analysis parameters geocodeParameters.GeocodeCustomers = true; geocodeParameters.GeocodeData = geocodeData; geocodeParameters.LinkField = "STORE_ID"; geocodeParameters.NameField = "NAME"; // Set other parameters imageOptions = null; outputOptions = new TaskOutputType[] { TaskOutputType.GetFeatureClass }; // In general, a non-null esriFolderItem is specified to save a newly-created // item to the server-side repository or to reference an existing item in it. outputLayer = new esriFolderItem(); outputLayer.folderType = esriFolderType.esriFolderCustomerLayers; outputLayer.itemName = "customerLayer_SummarizePoints"; outputLayer.workspaceName = "Default Workspace"; outputLayer.projectName = "Default Project"; TaskResultOutput customerGeocodeResult = baServerHelper.CustomerStoreSetupByGeocodeTable(geocodeParameters, imageOptions, outputOptions, outputLayer); PointLayer customerLayer = new PointLayer(); customerLayer.RecordSet = customerGeocodeResult.RecordSet; // ========= STEP 6: Execute the analysis SummarizePointsParameters parameters = new SummarizePointsParameters(); // Set specific analysis parameters parameters.AreaDescField = "AREA_DESC"; parameters.Boundaries = boundaryLayer; parameters.PointLayer = customerLayer; parameters.AdditionalFields = new string[] { "SALES" }; // Set report options ReportOptions reportOptions = new ReportOptions(); reportOptions.ReportFormat = "PDF"; reportOptions.ReportHeader = new KeyValue[1]; reportOptions.ReportHeader[0] = new KeyValue(); reportOptions.ReportHeader[0].Key = "subtitle"; reportOptions.ReportHeader[0].Value = "Summarize Points Report for customers and rings around stores"; parameters.StandardReportOptions = reportOptions; // Set other parameters imageOptions = null; outputOptions = new TaskOutputType[] { TaskOutputType.GetReport }; outputLayer = null; outputReport = null; TaskResultOutput result = baServerHelper.SummarizePoints(parameters, imageOptions, outputOptions, outputLayer, outputReport); string reportURL = result.Reports[0].ReportURL; |