1

I am using ArcGIS 10.3 for Desktop.

I received a feature class with attributes, as illustrated in the first table below.

enter image description here

I am seeking a geoprocessing tool or process that would help me reformat the feature class into the arrangement in the second table.

PolyGeo
65.5k29 gold badges115 silver badges350 bronze badges
asked Dec 16, 2015 at 18:34
6
  • i am assuming each area is a seperate polygon? pretty sure you want to use the merge tool. Commented Dec 16, 2015 at 19:05
  • What GIS software are you using? Commented 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 need Commented Dec 16, 2015 at 19:21
  • if they are merged then try to dissolve them based on the area field. Commented Dec 16, 2015 at 19:27
  • ed, if you merge then you lose attribution. Commented Dec 16, 2015 at 19:32

4 Answers 4

2

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.

answered Dec 16, 2015 at 20:03
1

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)
answered Dec 16, 2015 at 21:41
2
  • interesting code, but where are you plugging the "input" variable? It seems like input should be named "fc" Commented 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 :) Commented Dec 17, 2015 at 14:27
0

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
answered Dec 16, 2015 at 20:05
1
  • 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. Commented Dec 17, 2015 at 14:44
0

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.

answered Dec 18, 2015 at 1:49

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.