ArcGIS for Desktop

  • Documentation
  • Pricing
  • Support

  • My Profile
  • Help
  • Sign Out
ArcGIS for Desktop

ArcGIS Online

The mapping platform for your organization

ArcGIS for Desktop

A complete professional GIS

ArcGIS for Server

GIS in your enterprise

ArcGIS for Developers

Tools to build location-aware apps

ArcGIS Solutions

Free template maps and apps for your industry

ArcGIS Marketplace

Get apps and data for your organization

  • Documentation
  • Pricing
  • Support
Esri
  • Sign In
user
  • My Profile
  • Sign Out

ArcGIS Help

  • Home
  • Get Started
  • Map
  • Analyze
  • Manage Data
  • Tools
  • More...

Creating classes

Available with Spatial Analyst license.

  • Classes created with a fixed number of inputs
  • Classes created with Python lists or list of lists
  • Classes created from a series of classes within a list
  • Default arguments

To use classes for input parameters for geoprocessing tools, you must first create them. Once instantiated, you can access their properties and query or modify the objects. The easiest way to learn how to create the various class objects is to see examples of them being created using different input types.

Tip:

The documentation for each class contains a scripting example of how each can be defined and used in a tool parameter.

  • An overview of Spatial Analyst classes

Classes created with a fixed number of inputs

  • The following are examples of creating a variety of classes from a fixed number of input:
    # Creating a neighborhood class and assigning it to a variable
    neighborhood = NbrRectangle(10, 10, "CELL") 
    
    outFocalStats = FocalStatistics(inRas, neighborhood, "MINORITY")
    
    # Creating the Kriging model to be used
    kModelOrdinary = KrigingModelOrdinary("CIRCULAR", 2000, 2.6, 542, 0)
    
    # Creating a radius class and assigning it to a variable
    kRadius = RadiusFixed(20000, 1) 
    
    outKriging = Kriging(inFeatures, field, kModelOrdinary, cellSize, 
                         kRadius, outVarRaster)
    

Classes created with Python lists or list of lists

  • Below is an example of creating a class from a list for use in the Topo to Raster tool:
    # Create classes as input for TopoToRaster
    myTopoPtElev = TopoPointElevation([["spots.shp", "spot_meter"], 
                                       ["spots2.shp", "elev"]]) 
    myTopoContour = TopoContour([["contours.shp", "spot_meter"]]) 
    myTopoBoundary = TopoBoundary(["boundary.shp"]) 
    myTopoLake = TopoLake(["lakes.shp"])
    myTopoSink = TopoSink([["sink1.shp", "elevation"], ["sink2.shp", "NONE"]]) 
    myTopoStream = TopoStream(["streams.shp"])
    
    # Applying the tool
    outTopoToRaster = TopoToRaster([myTopoPtElev, myTopoContour, myTopoBoundary, 
                                    myTopoLake, myTopoSink, myTopoStream])
    
  • Below is an example of creating a class from a list for use in the Reclassify tool:
    # The RemapValue class has a usage of: 
    #   RemapRange(startValue, endValue, newValue)
    RemapTable = RemapValue([[1, 5], [2, 8], [3, 1], [4, 10]])
    
    # Run the tool 
    outReclass = Reclassify("inRas", RemapTable)
    

Classes created from a series of classes within a list

  • Below is an example of creating classes from a series of Point classes within a list, for use in the a raster cell extraction:
    # Identify the points to be extracted by creating a list
    #   of Point objects.
    PointsToExtract = [Point(0, 5), Point(15, 175), Point(225, 450)] 
    
    # Run the tool
    Outraster = ExtractByPoints(PointsToExtract)
    

Default arguments

  • Certain arguments are optional and are defined by {} (brace or curly brackets) in the usage. For example, the syntax for the wedge neighbourhood class is as follows:
    NbrWedge({radius}, {startAngle}, {endAngle}, {units})
    
  • If an optional argument is not specified, a default value will be used.
    # The circle neighborhood will default to
    #   a radius of 3 and units of CELL
    circle = NbrCircle()
    
  • Optional arguments can be specified using either an empty quote, "" or "#", denoting the value is to be skipped and the default value is desired.

Related Topics

  • An overview of using Spatial Analyst classes
  • Querying classes
  • Changing arguments within classes
Feedback on this topic?

ArcGIS for Desktop

  • Home
  • Documentation
  • Pricing
  • Support

ArcGIS Platform

  • ArcGIS Online
  • ArcGIS for Desktop
  • ArcGIS for Server
  • ArcGIS for Developers
  • ArcGIS Solutions
  • ArcGIS Marketplace

About Esri

  • About Us
  • Careers
  • Insiders Blog
  • User Conference
  • Developer Summit
Esri
© Copyright 2016 Environmental Systems Research Institute, Inc. | Privacy | Legal