CreateQuadTrees

Title  Create Quadtrees

Description

Creates quadtrees from a collection of input features.

Usage

          
Quadtree generation is controlled by specifying Maximum Vertices and/or Maximum depth:
  • Vertices - The quadtree will be subdivided if it contains more than the maximum number of vertices.
  • Vertices & Depth - Same as above, except it will stop subdividing beyond maximum depth.
  • Depth - Quadtrees are subdivided maximum depth times.

License

Basic

Syntax

CreateQuadTrees (in_features, out_features, {count}, {depth}, {create_empty}, {create_square})

Parameter Explanation Data Type
in_features Dialog Reference

The input features to partition.

GPFeatureLayer
out_features Dialog Reference

The output polygon feature class.

DEFeatureClass
count (Optional) Dialog Reference

The maximum number of feature vertices that will be enclosed by each quadtree.

GPLong
depth (Optional) Dialog Reference

The number of quadtree levels that will be generated. This ranges from 1-32.

GPLong
create_empty (Optional) Dialog Reference

Controls how quadtrees with no data will be handled.

  • Checked - Creates all quadtrees.
  • Unchecked - Only creates quadtrees that intersect with the input features. This is the default.

GPBoolean
create_square (Optional) Dialog Reference

Controls the shape of quadtrees.

  • Checked - Creates square quadtrees.
  • Unchecked - Creates rectangular quadtrees. This is the default.

GPBoolean

Code Samples

CreateQuadTrees example 1 (Python window)

Creates rectangular quadtrees dividing the device class into 10k quadrants.

import arcpy

arcpy.udms.CreateQuadTrees("ElectricDevice", "memory/quads", 10_000)

CreateQuadTrees example 2 (stand-alone script)

Creates quadtrees from all selected features in the map.

import os

import arcpy

aprx = arcpy.mp.ArcGISProject("CURRENT")

# Find all layers with a selection.
layers = [
    layer.longName
    for layer in aprx.activeMap.listLayers()
    if not layer.isBroken and layer.isFeatureLayer and layer.getSelectionSet()
]

arcpy.udms.CreateQuadTrees(
    in_features=layers,
    out_features=os.path.join(aprx.defaultGeodatabase, "quadTrees"),
    count=None,
    depth=3,
    create_empty=False,
    create_square=True,
)