Instrução

Selecionar registros ArcGIS contendo valores ímpares ou pares em um campo numérico usando Python no ArcGIS Pro

Last Published: September 13, 2023

Resumo

In ArcGIS Pro, it is possible to select specific records containing odd or even numbers from a numeric field in the attribute table using Python.

The following image shows the example of records for selected odd numbers from a numeric field.

The example of records for selected odd numbers from a numeric field.

Procedimento

  1. In ArcGIS Pro, click the Analysis tab on the top ribbon. Click the drop-down menu next to Python, and click Python window.
  2. In the Python window, insert the following command to select records with even values in a numeric field:
arcpy.management.SelectLayerByAttribute('<Feature layer>', 'SUBSET_SELECTION', 'MOD ("<Field name>",  2)  = 0')
  1. Press Enter.
  2. In the attribute field, click the Switch Selection The Switch Selection icon to select the opposite results of the previous selection. option to select records with odd values in the numeric field.

Alternatively, in the Python window, insert the following command to select records with odd values in the numeric field:

arcpy.management.SelectLayerByAttribute('<Feature layer>', 'SUBSET_SELECTION', 'MOD ("<Field name>",  2)  = 1')

To use both Python commands consecutively, insert the following command to remove the previous selection before selecting new records or click the Clear The Clear icon to clear the previous selection. option in the Selection group:

arcpy.management.SelectLayerByAttribute('<Feature layer>', 'CLEAR_SELECTION')

ID do Artigo: 000026383

Receba notificações e encontre soluções para problemas novos ou comuns

Obtenha respostas resumidas e soluções de vídeo do nosso novo chatbot de IA.

Baixe o Aplicativo de Suporte da Esri

Informações Relacionadas

Descubra mais sobre este tema

Obtenha ajuda de especialistas do ArcGIS

Entre em contato com Suporte Técnico

Baixe o Aplicativo de Suporte da Esri

Ir para as opções de download