Skip To Content

Querying classes

Available with Spatial Analyst license.

You may want to identify an individual argument that was used in a parameter and, based on that value, perform a specific set of functions. The following sections provide the rules for querying the different arguments for Spatial Analyst classes.

Classes created with a fixed number of inputs

  • To query the value of an argument in a class object, you can access the property of the object.
    circle = NbrCircle(5, "CELL")
    # varRadius will be assigned the radius property (which is 5)
    varRadius = circle.radius
  • You can easily inspect the value of an object or an object property.
    >>> circle = NbrCircle(5, "CELL")
    >>> print(circle)
    Circle 5 Cell
    >>> print(circle.radius)

Classes created from lists or list of list

  • To view the entire remap table, you can use the Python print function.
    >>> remap = RemapValue([[1, 11], [2, 12], [3, 13]])
    >>> print(remap)
    1 11; 2 12; 3 13
    >>> print(remap.remapTable)
    [[1, 11], [2, 12], [3, 13]]
  • To query an individual entry in the list for class objects that are created from lists within lists, identify the list the entry is in and address the location of the entry in that list.
    >>> remap = RemapValue([[1, 11], [2, 12], [3, 13]])
    >>> print(remap.remapTable[1][1])

Classes created from a series of classes within a list

  • To query an individual x- or y-coordinate or the x,y coordinates of a point within a list for a class object that was created from a series of classes within a list, access the property of the individual class in the input series.
    >>> points = [Point(0, 5), Point(15, 175), Point(225, 450)]
    >>> # The following statement queries the x value of the second input point
    >>> xvalue = points[1].X
    >>> print(xvalue)

Determining type

  • To determine the type of a class object, the Python type function can be used.
    >>> neighborhood = NbrCircle(5, "CELL")
    >>> neighType = type(neighborhood)
    >>> print(neighType)
    <class ''>
  • To compare types, the Python isinstance function can be used.
    circle = NbrCircle(5, "CELL")
    # The general format is: isinstance(AnyObject, AnyClass)
    # In the following statement, val will be assigned True
    val = isinstance(circle, NbrCircle) 
    # In the following statement, val will be assigned False
    val = isinstance(circle, NbrRectangle)

Related topics