Skip to main content
sort field. Create a new layer named fclyr. Add "1" in SecondField for first and last 5%
Source Link
BBG_GIS
  • 5.8k
  • 5
  • 45
  • 88

I think the best solution is scripting.It's versatile.

Create a new field with "Long Integer" type.I named it to "SecondField".

Row count = 151823

First 5% finished to 7591 row (I rounded it)

Last 5% started from 144232 row

In this code set your workspace. example:

arcpy.env.workspace = "D:/test.gdb"

Set Layer name after "fc= " :

fc= "Mylayer"

Set field names in the bracket of "UpdateCursor". The id field name and the new field name respectively.

The First 5% and last 5% will be write in this new field.Then you can select records and extract them.

import arcpy
arcpy.env.workspace = r"...\Geodatabase.gdb"
fc = "YourlayerName"
i = 0arcpy.Delete_management("fclyr")
sorted_table = arcpy.Sort_management(fc,"in_memory/fclyr""fclyr","NewID DESCENDING")
with arcpy.da.UpdateCursor(sorted_table,["NewID","SecondField"]) as cur:
    for row in cur:
        if i<row[0]< 7591 or i>row[0]> 144232:           
    
            row[1] = row[0]1
        cur.updateRow(row)
 del row 
del cur
    i = i + 1

Note: There are some solutions to calculate the number of rows and first-last 5% numbers automatically.I want to give a simple example for you then i hardcode these numbers.

I think the best solution is scripting.It's versatile.

Create a new field with "Long Integer" type.I named it to "SecondField".

Row count = 151823

First 5% finished to 7591 row (I rounded it)

Last 5% started from 144232 row

In this code set your workspace. example:

arcpy.env.workspace = "D:/test.gdb"

Set Layer name after "fc= " :

fc= "Mylayer"

Set field names in the bracket of "UpdateCursor". The id field name and the new field name respectively.

The First 5% and last 5% will be write in this new field.Then you can select records and extract them.

import arcpy
arcpy.env.workspace = r"...\Geodatabase.gdb"
fc = "YourlayerName"
i = 0
sorted_table = arcpy.Sort_management(fc,"in_memory/fclyr","NewID DESCENDING")
with arcpy.da.UpdateCursor(sorted_table,["NewID","SecondField"]) as cur:
    for row in cur:
        if i< 7591 or i> 144232:           
    
            row[1] = row[0]
    cur.updateRow(row)
        i = i + 1

Note: There are some solutions to calculate the number of rows and first-last 5% numbers automatically.I want to give a simple example for you then i hardcode these numbers.

I think the best solution is scripting.It's versatile.

Create a new field with "Long Integer" type.I named it to "SecondField".

Row count = 151823

First 5% finished to 7591 row (I rounded it)

Last 5% started from 144232 row

In this code set your workspace. example:

arcpy.env.workspace = "D:/test.gdb"

Set Layer name after "fc= " :

fc= "Mylayer"

Set field names in the bracket of "UpdateCursor". The id field name and the new field name respectively.

The First 5% and last 5% will be write in this new field.Then you can select records and extract them.

import arcpy
arcpy.env.workspace = r"...\Geodatabase.gdb"
fc = "YourlayerName"
arcpy.Delete_management("fclyr")
sorted_table = arcpy.Sort_management(fc,"fclyr","NewID DESCENDING")
with arcpy.da.UpdateCursor(sorted_table,["NewID","SecondField"]) as cur:
    for row in cur:
        if row[0]< 7591 or row[0]> 144232:           
    
            row[1] = 1
        cur.updateRow(row)
del row 
del cur
        

Note: There are some solutions to calculate the number of rows and first-last 5% numbers automatically.I want to give a simple example for you then i hardcode these numbers.

Sort field added to the Answer.
Source Link
BBG_GIS
  • 5.8k
  • 5
  • 45
  • 88

I think the best solution is scripting.It's versatile.

Create a new field with "Long Integer" type.I named it to "SecondField".

Row count = 151823

First 5% finished to 7591 row (I rounded it)

Last 5% started from 144232 row

In this code set your workspace. example:

arcpy.env.workspace = "D:/test.gdb"

Set Layer name after "fc= " :

fc= "Mylayer"

Set field names in the bracket of "UpdateCursor". The id field name and the new field name respectively.

The First 5% and last 5% will be write in this new field.Then you can select records and extract them.

import arcpy
arcpy.env.workspace = r"...\Geodatabase.gdb"
fc = "YourlayerName"
i = 0
sorted_table = arcpy.Sort_management(fc,"in_memory/fclyr","NewID DESCENDING")
with arcpy.da.UpdateCursor(fcsorted_table,["NewID","SecondField"]) as cur:
    for row in cur:
        if i< 7591 or i> 144232:           
    
            row[1] = row[0]
    cur.updateRow(row)
        i = i + 1

Note: There are some solutions to calculate the number of rows and first-last 5% numbers automatically.I want to give a simple example for you then i hardcode these numbers.

I think the best solution is scripting.It's versatile.

Create a new field with "Long Integer" type.I named it to "SecondField".

Row count = 151823

First 5% finished to 7591 row (I rounded it)

Last 5% started from 144232 row

In this code set your workspace. example:

arcpy.env.workspace = "D:/test.gdb"

Set Layer name after "fc= " :

fc= "Mylayer"

Set field names in the bracket of "UpdateCursor". The id field name and the new field name respectively.

The First 5% and last 5% will be write in this new field.Then you can select records and extract them.

import arcpy
arcpy.env.workspace = r"...\Geodatabase.gdb"
fc = "YourlayerName"
i = 0
with arcpy.da.UpdateCursor(fc,["NewID","SecondField"]) as cur:
    for row in cur:
        if i< 7591 or i> 144232:           
    
            row[1] = row[0]
    cur.updateRow(row)
        i = i + 1

Note: There are some solutions to calculate the number of rows and first-last 5% numbers automatically.I want to give a simple example for you then i hardcode these numbers.

I think the best solution is scripting.It's versatile.

Create a new field with "Long Integer" type.I named it to "SecondField".

Row count = 151823

First 5% finished to 7591 row (I rounded it)

Last 5% started from 144232 row

In this code set your workspace. example:

arcpy.env.workspace = "D:/test.gdb"

Set Layer name after "fc= " :

fc= "Mylayer"

Set field names in the bracket of "UpdateCursor". The id field name and the new field name respectively.

The First 5% and last 5% will be write in this new field.Then you can select records and extract them.

import arcpy
arcpy.env.workspace = r"...\Geodatabase.gdb"
fc = "YourlayerName"
i = 0
sorted_table = arcpy.Sort_management(fc,"in_memory/fclyr","NewID DESCENDING")
with arcpy.da.UpdateCursor(sorted_table,["NewID","SecondField"]) as cur:
    for row in cur:
        if i< 7591 or i> 144232:           
    
            row[1] = row[0]
    cur.updateRow(row)
        i = i + 1

Note: There are some solutions to calculate the number of rows and first-last 5% numbers automatically.I want to give a simple example for you then i hardcode these numbers.

added 224 characters in body
Source Link
BBG_GIS
  • 5.8k
  • 5
  • 45
  • 88

I think the best solution is scripting.It's versatile.

Create a new field with "Long Integer" type.I named it to "SecondField".

Row count = 151823

First 5% finished to 7591 row (I rounded it)

Last 5% started from 144232 row

In this code set your workspace. example:

arcpy.env.workspace = "D:/test.gdb"

Set Layer name after "fc= " :

fc= "Mylayer"

Set field names in the bracket of "UpdateCursor". The id field name and the new field name respectively.

The First 5% and last 5% will be write in this new field.Then you can select records and extract them.

import arcpy
arcpy.env.workspace = r"...\Geodatabase.gdb"
fc = "YourlayerName"
i = 0
with arcpy.da.UpdateCursor(fc,["NewID","SecondField"]) as cur:
    for row in cur:
        if i< 7591 or i> 144232:           
    
            row[1] = row[0]
    cur.updateRow(row)
        i = i + 1

Note: There are some solutions to calculate the number of rows and first-last 5% numbers automatically.I want to give a simple example for you then i hardcode these numbers.

I think the best solution is scripting.It's versatile.

Create a new field with "Long Integer" type.I named it to "SecondField".

Row count = 151823

First 5% finished to 7591 row (I rounded it)

Last 5% started from 144232 row

In this code set your workspace. example:

arcpy.env.workspace = "D:/test.gdb"

Set Layer name after "fc= " :

fc= "Mylayer"

Set field names in the bracket of "UpdateCursor". The id field name and the new field name respectively.

The First 5% and last 5% will be write in this new field.Then you can select records and extract them.

import arcpy
arcpy.env.workspace = r"...\Geodatabase.gdb"
fc = "YourlayerName"
i = 0
with arcpy.da.UpdateCursor(fc,["NewID","SecondField"]) as cur:
    for row in cur:
        if i< 7591 or i> 144232:           
    
            row[1] = row[0]
    cur.updateRow(row)
        i = i + 1

I think the best solution is scripting.It's versatile.

Create a new field with "Long Integer" type.I named it to "SecondField".

Row count = 151823

First 5% finished to 7591 row (I rounded it)

Last 5% started from 144232 row

In this code set your workspace. example:

arcpy.env.workspace = "D:/test.gdb"

Set Layer name after "fc= " :

fc= "Mylayer"

Set field names in the bracket of "UpdateCursor". The id field name and the new field name respectively.

The First 5% and last 5% will be write in this new field.Then you can select records and extract them.

import arcpy
arcpy.env.workspace = r"...\Geodatabase.gdb"
fc = "YourlayerName"
i = 0
with arcpy.da.UpdateCursor(fc,["NewID","SecondField"]) as cur:
    for row in cur:
        if i< 7591 or i> 144232:           
    
            row[1] = row[0]
    cur.updateRow(row)
        i = i + 1

Note: There are some solutions to calculate the number of rows and first-last 5% numbers automatically.I want to give a simple example for you then i hardcode these numbers.

added 224 characters in body
Source Link
BBG_GIS
  • 5.8k
  • 5
  • 45
  • 88
Loading
Source Link
BBG_GIS
  • 5.8k
  • 5
  • 45
  • 88
Loading