Generate Renderer (Map Service\Layer)

Description

generateRenderer operation is performed on a layer / table resource. This operation groups data using the supplied classificationDef (classification definition) and an optional where clause. The result is a renderer object. Use baseSymbol and colorRamp to define the symbols assigned to each class. If the operation is performned on a table, the result is a renderer object containing the data classes and no symbols.

You can provide arguments to the generateRenderer operation as query parameters defined in the parameters table below.

NoteNote:

When generating a class breaks renderer map server uses maxSampleSize configuration property set on the map service to determine the number of records to sample. In rare cases these classes might not include the minimum or maximum value in the data.

Request Parameters

Parameter

Details

f

Description: The response format. The default response format is html.

Values: html | json

classificationDef

Description: The definition using which the parameter is generated.

NoteNote:

Use either one of ClassBreaks or UniqueValue classification definition.

Syntax: classificationDef = classification definition

Example:

//classBreaks classification definition
classificationDef = {
  "type": "classBreaksDef",
  "classificationField": "POP2010",
  "classificationMethod": "esriClassifyNaturalBreaks",
  "breakCount": 5,
  "normalizationType": "esriNormalizeByField",
  "normalizationField": "Area"
}

//uniqueValue classification definition with symbology
classificationDef = {
  "type": "uniqueValueDef",
  "uniqueValueFields": ["Type", "AdminClass"],
  "fieldDelimiter": ",",
  "baseSymbol":
  {
    "type": "esriSLS",
    "style": "esriSLSSolid",
    "width": 2
  },
  "colorRamp":
  {
    "type": "algorithmic",
    "fromColor": [115,76,0,255],
    "toColor": [255,25,86,255],
    "algorithm": "esriHSVAlgorithm"
  }
}

where

Description: A where clause for which the data needs to be classified. Any legal SQL where clause operation on the fields in the layer/table is allowed.

Example:

where = POP2000 > 350000

gdbVersion

Description: GeoDatabase version to query. This parameter applies only if hasVersionedData property of the service and isDataVersioned property of the layer(s) queried are true. If this is not specified, query will apply to published map's version.

Syntax: gdbVersion=<geodatabase version>

Example: gdbVersion=sde.USER1

Example Usage

Example 1: Generate Renderer using a unique value classification definition, when baseSymbol is missing then map server would assign an appropriate baseSymbol:

http://sampleserver6.arcgisonline.com/arcgis/rest/services/Census/MapServer/3/generateRenderer?classificationDef={"type":"uniqueValueDef","uniqueValueFields":["sub_region"],"fieldDelimiter": ", ", "colorRamp":{"type":"algorithmic","fromColor":[115,76,0,255],"toColor":[255,25,86,255],"algorithm": "esriHSVAlgorithm"}}&where=&gdbVersion=&f=pjson

Example 2: Generate Renderer using a class breaks classification definition:

http://sampleserver6.arcgisonline.com/arcgis/rest/services/Census/MapServer/3/generateRenderer?classificationDef={"breakCount":5, "type":"classBreaksDef","classificationField":"pop2007","classificationMethod":"esriClassifyQuantile","baseSymbol":{"type":"esriSMS","style":"esriSMSSquare","color":[56,125,221,255],"size":10.5,"angle":23,"xOffset":-10,"yOffset":null,"outline":null}}&where=&gdbVersion=&f=pjson

JSON Response Syntax (when classificationDef type is uniqueValueDef)

{
  "type" : "uniqueValue",
  "field1" : "<field1>",
  "field2" : "<field2>",
  "field3" : "<field3>",
  "fieldDelimiter" : "<fieldDelimiter>",
  "defaultSymbol" :  <symbol>,
  "defaultLabel" : "<defaultLabel>",
  "uniqueValueInfos" : [
    {
      "value" : "<value1>",
      "count" : "<number of features with value1>",
      "label" : "<label1>",
      "description" : "<description1>",
      "symbol" :  <symbol1>
    },
    {
      "value" : "<value2>",
      "count" : "<number of features with value2>",
      "label" : "<label2>",
      "description" : "<description2>",
      "symbol" :  <symbol2>
    }
  ]
}

JSON Response Example (when classificationDef type is uniqueValueDef)

{
 "type": "uniqueValue",
 "field1": "sub_region",
 "field2": "",
 "field3": "",
 "fieldDelimiter": ", ",
 "defaultSymbol": {
  "type": "esriSFS",
  "style": "esriSFSSolid",
  "color": [
   110,
   110,
   110,
   255
  ],
  "outline": {
   "type": "esriSLS",
   "style": "esriSLSSolid",
   "color": [
    0,
    0,
    0,
    255
   ],
   "width": 1
  }
 },
 "defaultLabel": "\u003call other values\u003e",
 "uniqueValueInfos": [
  {
   "value": "East North Central",
   "count": 5,
   "label": "East North Central",
   "description": "",
   "symbol": {
    "type": "esriSFS",
    "style": "esriSFSSolid",
    "outline": {
     "type": "esriSLS",
     "style": "esriSLSSolid",
     "color": [
      0,
      0,
      0,
      255
     ],
     "width": 1
    },
    "color": [
     115,
     77,
     0,
     255
    ]
   }
  },
  {
   "value": "East South Central",
   "count": 4,
   "label": "East South Central",
   "description": "",
   "symbol": {
    "type": "esriSFS",
    "style": "esriSFSSolid",
    "outline": {
     "type": "esriSLS",
     "style": "esriSLSSolid",
     "color": [
      0,
      0,
      0,
      255
     ],
     "width": 1
    },
    "color": [
     92,
     130,
     3,
     255
    ]
   }
  },
  {
   "value": "Middle Atlantic",
   "count": 3,
   "label": "Middle Atlantic",
   "description": "",
   "symbol": {
    "type": "esriSFS",
    "style": "esriSFSSolid",
    "outline": {
     "type": "esriSLS",
     "style": "esriSLSSolid",
     "color": [
      0,
      0,
      0,
      255
     ],
     "width": 1
    },
    "color": [
     14,
     148,
     4,
     255
    ]
   }
  },
  {
   "value": "Mountain",
   "count": 8,
   "label": "Mountain",
   "description": "",
   "symbol": {
    "type": "esriSFS",
    "style": "esriSFSSolid",
    "outline": {
     "type": "esriSLS",
     "style": "esriSLSSolid",
     "color": [
      0,
      0,
      0,
      255
     ],
     "width": 1
    },
    "color": [
     7,
     166,
     97,
     255
    ]
   }
  },
  {
   "value": "New England",
   "count": 6,
   "label": "New England",
   "description": "",
   "symbol": {
    "type": "esriSFS",
    "style": "esriSFSSolid",
    "outline": {
     "type": "esriSLS",
     "style": "esriSLSSolid",
     "color": [
      0,
      0,
      0,
      255
     ],
     "width": 1
    },
    "color": [
     9,
     149,
     184,
     255
    ]
   }
  },
  {
   "value": "Pacific",
   "count": 5,
   "label": "Pacific",
   "description": "",
   "symbol": {
    "type": "esriSFS",
    "style": "esriSFSSolid",
    "outline": {
     "type": "esriSLS",
     "style": "esriSLSSolid",
     "color": [
      0,
      0,
      0,
      255
     ],
     "width": 1
    },
    "color": [
     14,
     45,
     201,
     255
    ]
   }
  },
  {
   "value": "South Atlantic",
   "count": 9,
   "label": "South Atlantic",
   "description": "",
   "symbol": {
    "type": "esriSFS",
    "style": "esriSFSSolid",
    "outline": {
     "type": "esriSLS",
     "style": "esriSLSSolid",
     "color": [
      0,
      0,
      0,
      255
     ],
     "width": 1
    },
    "color": [
     112,
     18,
     219,
     255
    ]
   }
  },
  {
   "value": "West North Central",
   "count": 7,
   "label": "West North Central",
   "description": "",
   "symbol": {
    "type": "esriSFS",
    "style": "esriSFSSolid",
    "outline": {
     "type": "esriSLS",
     "style": "esriSLSSolid",
     "color": [
      0,
      0,
      0,
      255
     ],
     "width": 1
    },
    "color": [
     237,
     21,
     216,
     255
    ]
   }
  },
  {
   "value": "West South Central",
   "count": 4,
   "label": "West South Central",
   "description": "",
   "symbol": {
    "type": "esriSFS",
    "style": "esriSFSSolid",
    "outline": {
     "type": "esriSLS",
     "style": "esriSLSSolid",
     "color": [
      0,
      0,
      0,
      255
     ],
     "width": 1
    },
    "color": [
     255,
     25,
     87,
     255
    ]
   }
  }
 ]
}

JSON Response Syntax (when classificationDeftype is classBreaksDef)

{
  "type" : "classBreaks",
  "field" : "<field>",
  "classificationMethod" : "<classification method>", 
  "normalizationType" : "<esriNormalizeByField | esriNormalizeByLog | esriNormalizeByPercentOfTotal>",
  "normalizationField" : "<normalization field>", //when normalizationType is esriNormalizeByField
  "normalizationTotal" : <total value>, //when normalizationType is esriNormalizeByPercentOfTotal
  "minValue" : <minValue>,
  "classBreakInfos" : [
    {
      "classMinValue" : <classMinValue1>, //optional
      "classMaxValue" : <classMaxValue1>,
      "label" : "<label1>",
      "description" : "<description1>",
      "symbol" :  <symbol1>
    },
    {
      "classMinValue" : <classMinValue2>,
      "classMaxValue" : <classMaxValue2>,
      "label" : "<label2>",
      "description" : "<description2>",
      "symbol" :  <symbol2>
    }
  ]
}

JSON Response Example (when classificationDeftype is classBreaksDef)

{
 "type": "classBreaks",
 "field": "pop2007",
 "minValue": 523174,
 "classBreakInfos": [
  {
   "classMaxValue": 1352536,
   "label": "523174 - 1352536",
   "description": "",
   "symbol": {
    "type": "esriSMS",
    "style": "esriSMSSquare",
    "size": 10.5,
    "angle": 23,
    "xoffset": -10,
    "yoffset": 0,
    "color": [
     0,
     255,
     0,
     255
    ]
   }
  },
  {
   "classMaxValue": 2969306,
   "label": "1352537 - 2969306",
   "description": "",
   "symbol": {
    "type": "esriSMS",
    "style": "esriSMSSquare",
    "size": 10.5,
    "angle": 23,
    "xoffset": -10,
    "yoffset": 0,
    "color": [
     0,
     255,
     128,
     255
    ]
   }
  },
  {
   "classMaxValue": 5360578,
   "label": "2969307 - 5360578",
   "description": "",
   "symbol": {
    "type": "esriSMS",
    "style": "esriSMSSquare",
    "size": 10.5,
    "angle": 23,
    "xoffset": -10,
    "yoffset": 0,
    "color": [
     0,
     255,
     255,
     255
    ]
   }
  },
  {
   "classMaxValue": 8891611,
   "label": "5360579 - 8891611",
   "description": "",
   "symbol": {
    "type": "esriSMS",
    "style": "esriSMSSquare",
    "size": 10.5,
    "angle": 23,
    "xoffset": -10,
    "yoffset": 0,
    "color": [
     0,
     128,
     255,
     255
    ]
   }
  },
  {
   "classMaxValue": 37483448,
   "label": "8891612 - 37483448",
   "description": "",
   "symbol": {
    "type": "esriSMS",
    "style": "esriSMSSquare",
    "size": 10.5,
    "angle": 23,
    "xoffset": -10,
    "yoffset": 0,
    "color": [
     0,
     0,
     255,
     255
    ]
   }
  }
 ]
}