I am using ArcGIS 10.3 for Desktop.
I received a feature class with attributes, as illustrated in the first table below.
I am seeking a geoprocessing tool or process that would help me reformat the feature class into the arrangement in the second table.
-
i am assuming each area is a seperate polygon? pretty sure you want to use the merge tool.ed.hank– ed.hank2015年12月16日 19:05:08 +00:00Commented Dec 16, 2015 at 19:05
-
What GIS software are you using?PolyGeo– PolyGeo ♦2015年12月16日 19:14:20 +00:00Commented Dec 16, 2015 at 19:14
-
ArcGIS 10.3.1 @ed the top view IS merged. So, no, merge aggregates the data together from various sources but does not reformat it like we needCOCO– COCO2015年12月16日 19:21:16 +00:00Commented Dec 16, 2015 at 19:21
-
if they are merged then try to dissolve them based on the area field.ed.hank– ed.hank2015年12月16日 19:27:46 +00:00Commented Dec 16, 2015 at 19:27
-
ed, if you merge then you lose attribution.COCO– COCO2015年12月16日 19:32:28 +00:00Commented Dec 16, 2015 at 19:32
4 Answers 4
If you are working in ArcGIS, open the attribute table, right click on the AREA attribute, and summarize. Then, in the menu for Summarizing, there should be a field menu, with + signs to expand for each field. Click each one, and check the box for 'Sum'. As long as your data types are numeric, it should sum those values so they look like your second table. Then, if you need to map this data, join your summary table back to a feature class or shapefile based on the AREA attribute.
This answer is just playing around with a pretty arcpy/numpy method for doing this. I am still missing handling joining the outputs to a shape field (which would let me use NumPyArrayToFeatureClass instead). You can realistically do the same thing with Summary Statistics as it is right now.
from arcpy.da import TableToNumPyArray
from arcpy.da import NumPyArrayToTable
import numpy as np
input = "FullFeatureClassPath"
output = "FullOutputPath"
na = TableToNumPyArray(input, ['*'])
# Get all the integer fields. Could also add in float fields.
fields = [x for x in na.dtype.names if np.issubdtype(na.dtype[x], np.integer)]
# Get all the unique values in 'AREA'
areas = np.unique(na['AREA'])
rows = []
# Make a new row for each area, summing up all the integer fields that match each one
for area in areas:
row = [area]
row.extend([na[na['AREA']==area][x].sum() for x in fields])
rows.append(tuple(row)) #Append the row to the array of summed rows
# Build a new numpy array, using the data structure of the original
# I am fudging here because all the fields other than area were integer fields
nb = np.array(rows, dtype=na.dtype)
# Convert this array to a table. Still missing shapes.
arcpy.da.NumPyArrayToTable(nb, output)
-
interesting code, but where are you plugging the "input" variable? It seems like input should be named "fc"COCO– COCO2015年12月16日 22:41:04 +00:00Commented Dec 16, 2015 at 22:41
-
Thanks. Fixed. It is not complete code yet, so most of it was done interactively and then I fixed variables as I go :)blord-castillo– blord-castillo2015年12月17日 14:27:01 +00:00Commented Dec 17, 2015 at 14:27
Is this something that you will need to do repetitively and actually need a tool for? To me, the quickest solution would be a SQL query, similiar to this Stack Overflow solution. I see your statement being something similar to the code below:
SELECT DISTINCT AREA,
SELECT POPUNDER20 FROM TempTable WHERE T.POPUNDER20 = POPUNDER20 AND POPUNDER20 IS NOT NULL) AS PopUnder20,
SELECT POPOVER20 FROM TempTable WHERE T.POPOVER20 = POPOVER20 AND POPOVER20 IS NOT NULL) AS PopOver20,
SELECT POPOVER50 FROM TempTable WHERE T.POPOVER50 = POPOVER50 AND POPOVER50 IS NOT NULL) AS PopOver50
FROM TempTable AS T
-
I think the question was added for ArcGIS after I was writing out my answer. I believe Summarize is a good way to go for this.MaryBeth– MaryBeth2015年12月17日 14:44:26 +00:00Commented Dec 17, 2015 at 14:44
Thanks everyone for your helpful responses. arcpy.Statistics_Analysis is the solution I was really looking. Set Area as the CASE field and the other fields as the statistics fields using "MAX" seemed to work great.
Explore related questions
See similar questions with these tags.