Created
February 17, 2022 00:36
-
-
Save daranzolin/605e55541f2bd5696daf32218ff3e708 to your computer and use it in GitHub Desktop.
Display a raster's 'attribute' table w/arcpy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
def display_raster_attribute_table(ras): | |
if ras.hasRAT: | |
flds = [fld.name for fld in arcpy.ListFields(ras)] | |
table = [] | |
cur = arcpy.SearchCursor(ras, flds) | |
for row in cur: | |
rowList = [row.getValue(fld) for fld in flds] | |
table.append(rowList) | |
del cur | |
return pd.DataFrame(table, columns = flds) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment