Copy polygons from one fc to another, and merge them

1023
7
Jump to solution
10-09-2018 11:33 AM
CharlesGeiger
New Contributor III

I am relatively new to Python, but have a workflow in which I select a group of contiguous parcels in my Parcels feature class, copy them, paste (special) them into another existing feature class called Neighborhoods and, when they are in the Neighborhoods feature class, merge them into one polygon (the neighborhood).  I am trying to decide between the CopyFeatures_management and Append_management ArcPy tools for the first part, and I cannot find any ArcPy tool for the merge.

0 Kudos
1 Solution

Accepted Solutions
ModyBuchbinder
Esri Regular Contributor

Hi

As far as I understand the workflow you should first use Dissolve without the parameter Dissolve_field (it is optional) to make one polygon in temporary fc.

Then use Append to add it to any other polygon layer.

Have fun

View solution in original post

7 Replies
deleted-user-qpvAI3Fo0MKR
Occasional Contributor III

Here's the Merge documentation:

Merge—Data Management toolbox | ArcGIS Desktop 

However, it sounds to me like you should be using Dissolve - 

Dissolve—Data Management toolbox | ArcGIS Desktop 

CharlesGeiger
New Contributor III

Thanks for your quick reply.  I looked at both of those,  but Merge seems to be focused on merging entire feature classes, while Dissolve requires an attribute field which, at that stage in the process, doesn't exist yet.  When I perform the task manually, the tools are in the "Modify Features" tools on Pro's Edit menu, but they don't seem to have Python equivalents.

0 Kudos
deleted-user-qpvAI3Fo0MKR
Occasional Contributor III

I just want to clarify your workflow so I understand what it is you're trying to accomplish.

You have a source and a target feature class. When you move the data from the source to the target, you want the data in the target to be grouped by neighborhood. Is this accurate?

0 Kudos
CharlesGeiger
New Contributor III

Sorry, I replied via e-mail but it is not showing up here.

Yes, but by "grouped" I mean turning a set of, for example, 30 parcel polygons into one neighborhood polygon.  My expectation is that I will select the parcels in Pro and then run my custom tool.

0 Kudos
ModyBuchbinder
Esri Regular Contributor

Hi

As far as I understand the workflow you should first use Dissolve without the parameter Dissolve_field (it is optional) to make one polygon in temporary fc.

Then use Append to add it to any other polygon layer.

Have fun

CharlesGeiger
New Contributor III

Thank you.  I finally got it working.  My script code is:

# Python Script
# This script copies polygons from the Lancaster County parcels feature
# class into the Neighborhoods feature class and processes them into a
# single neighborhood.

import arcpy
# Set the current workspace
from arcpy import env
env.workspace = "CURRENT"

# Copy the currently selected features in the parcels layer
fc_in = "Parcels_2016"
fc_tempin = "in_memory/Neighborhoods_in"
fc_tempout = "in_memory/Neighborhoods_out"
fc_out = "Neighborhoods_2016"
arcpy.CopyFeatures_management(fc_in, fc_tempin)

# Merge the copied parcels before adding to Neighborhoods fc
arcpy.Dissolve_management(fc_tempin, fc_tempout)
schema_type = "NO_TEST"
arcpy.Append_management(fc_tempout, fc_out, schema_type)
ModyBuchbinder
Esri Regular Contributor

Hi

Great but you can drop the CopyFeatures  Just dissolve from fc_in to fc_tempout and save a step

0 Kudos