Select to view content in your preferred language

combine points

7899
6
Jump to solution
08-12-2019 07:35 AM
JaredPilbeam2
MVP Regular Contributor

Hello,

I'm wondering how to combine points that are within a small distance from each other, but are from the same feature class. The points represent signs on a road. When the feature was originally created an additional point was created if the sign had something on the back-- so, two points for the same sign. But, the tricky thing is each point was given a unique number.

My question is how can I bring these points together and at the same time preserve the attributes?

In ArcGIS Pro, I've tried arcpy.MergeLayers_geoanalytics, but that doesn't seem to work because it requires two layers. I've also tried arcpy.Integrate_management, but this treats the points within a specified distance as vertices, and sort of pulls them on top of each other.

In this screen shot is an example of two signs with a point for the front of the signs and a point of the backs. I'm looking to combine these somehow?

0 Kudos
1 Solution

Accepted Solutions
rachelg_esri
Esri Contributor

Hello Jared!

I did some testing in ArcGIS Pro, and I think the Spatial Join tool should work for you. This workflow does involve first separating the data, and my workflow assumes the Post_Number field is string. (If it isn't, you can make a new field of type Text and calculate it as equal to your old Post_Number field for a temporary solution.) Here's what I did:

I started with 4 points in a dataset representing two different sign posts with two sides each. I made sure to match your "ending in 1/6 or 2/7" scenario on the Post_Number column.

First I used Select by Attributes using a SQL expression (there's a toggle button on the Select by Attributes expression builder page to turn on SQL). Note that this only works on text fields the way I did it. My expression was:

Post_Number LIKE '%1' OR Post_Number LIKE '%6'

I then exported the selection to a "FrontSide" feature class. Then I switched the selection using the "Switch" button on the table pane and exported the new selection to a new "BackSide" feature class.

Now I have 2 feature classes -- one that represents the signs' front side and one that represents the signs' back side.

I then used the Spatial Join tool:

I used the parameters:

  • Target: FrontSide
  • Join: BackSide
  • Output: NewSignPoints
  • Join: Operation: Join one to one
  • Field Map of Join Features: Rename fields based on front or back
  • Match Option: Within a Distance
  • Search Radius: The furthest distance between two points of the same sign (ex. 15 feet for mine -- I didn't zoom in much when I made the points. Your distance may be much smaller. You can use the measure tool to check this.)

I then got an output that looked like this, with one row for each sign post and 4 columns -- two that represented the Post Numbers and two that represented the text of the sign:

Here's some more information about the Spatial Join tool: Spatial Join—Help | ArcGIS Desktop 

Let me know if that answers your question?

Best regards,

Rachel

Esri Support Services

Rachel Guttmacher
ArcGIS Online Technology Lead
Esri Support Services

View solution in original post

6 Replies
rachelg_esri
Esri Contributor

Hello Jared!

So, if I am understanding:

- You have 2 points for each location that are slightly offset from each other

- Each point has a unique set of attributes

- The two points are in the same feature class

And you're wanting (scenario 1):

- Still, just one feature class

- One row for each of the points so that you keep the attributes of both

- The points to be on top of each other but separate points

Is this correct? Or are you wanting (scenario 2):

- One point for each sign

- One row for each sign that has different columns to represent the front and the back (that used to be 2 attribute rows)

If you're wanting the former (scenario 1), I think the easiest way to do this would be to consider the Snap tool. This will snap vertices (or in this case, points) to the closest features within a distance. In the case of features being in the same feature class, it will use the geometry of the lowest Object ID.

See: Snap—Help | ArcGIS Desktop 

In the case of scenario 2, thinking this through, I think the easiest thing would be to select all "front of the sign" points, export them, then select all "back of the sign" points so they are two separate feature classes, making sure to select the right fields you want in each (with a unique identifier included in both), and then set up a join between the two feature classes. You can then export the data which, I think, should result in one point with one row per point but additional fields for the front or the back, if I'm thinking about this correctly?

Hopefully that helps.

Best regards,

Rachel

Esri Support Services

Rachel Guttmacher
ArcGIS Online Technology Lead
Esri Support Services
JaredPilbeam2
MVP Regular Contributor

Hi Rachel,

Thanks for the reply. Scenario 2 is what I'm after more or less.

There's a field called "Post_Number" in the attributes, it's 7 digits. When the point/sign has something on back the last digit is either a 2 or a 7. In turn, to indicate the front of the sign the last digit is either a 1 or a 6. For example, this is the same sign as two different points:

Is there a way to combine them based on distance while preserving the attributes?

0 Kudos
rachelg_esri
Esri Contributor

Hello Jared!

I did some testing in ArcGIS Pro, and I think the Spatial Join tool should work for you. This workflow does involve first separating the data, and my workflow assumes the Post_Number field is string. (If it isn't, you can make a new field of type Text and calculate it as equal to your old Post_Number field for a temporary solution.) Here's what I did:

I started with 4 points in a dataset representing two different sign posts with two sides each. I made sure to match your "ending in 1/6 or 2/7" scenario on the Post_Number column.

First I used Select by Attributes using a SQL expression (there's a toggle button on the Select by Attributes expression builder page to turn on SQL). Note that this only works on text fields the way I did it. My expression was:

Post_Number LIKE '%1' OR Post_Number LIKE '%6'

I then exported the selection to a "FrontSide" feature class. Then I switched the selection using the "Switch" button on the table pane and exported the new selection to a new "BackSide" feature class.

Now I have 2 feature classes -- one that represents the signs' front side and one that represents the signs' back side.

I then used the Spatial Join tool:

I used the parameters:

  • Target: FrontSide
  • Join: BackSide
  • Output: NewSignPoints
  • Join: Operation: Join one to one
  • Field Map of Join Features: Rename fields based on front or back
  • Match Option: Within a Distance
  • Search Radius: The furthest distance between two points of the same sign (ex. 15 feet for mine -- I didn't zoom in much when I made the points. Your distance may be much smaller. You can use the measure tool to check this.)

I then got an output that looked like this, with one row for each sign post and 4 columns -- two that represented the Post Numbers and two that represented the text of the sign:

Here's some more information about the Spatial Join tool: Spatial Join—Help | ArcGIS Desktop 

Let me know if that answers your question?

Best regards,

Rachel

Esri Support Services

Rachel Guttmacher
ArcGIS Online Technology Lead
Esri Support Services
JaredPilbeam2
MVP Regular Contributor

Hi Rachel,

That was really helpful. Thanks a lot.

I was able to create the new feature class with fields for both FrontSide and BackSide. Now I'm trying to figure out how to join this new feature class to all the points with the last digits being anything but 1/6, 2/7. These are the signs that are by themselves (i.e. nothing on the back). I exported the rest of the points to a feature class of its own. I'm thinking this would be a Join Features task, not a Spatial Join?

0 Kudos
rachelg_esri
Esri Contributor

Hello Jared!

I think Append will be best for you in that case. Your Input would be your "JustOneSide" feature class (the ones that didn't have a 1/6 or 2/7), your Target would be your "NewSignPoints", and you can use the Field Map in the tool to feed the front of the sign information into the Front_SignText and Front_Post_Number. The Back_SignText and Back_Post_Number fields would be <Null> after the append.

Here's some information: Append—Data Management toolbox | ArcGIS Desktop 

Best regards,

Rachel

Rachel Guttmacher
ArcGIS Online Technology Lead
Esri Support Services
JaredPilbeam2
MVP Regular Contributor

Rachel,

Thanks. I went ahead and used a SQL expression to select all the signs that were not 2/7 --> exported them. Then I switched the selection in the attributes so as to only get the 2/7 signs. This I exported. Then I did a Spatial Join on the two feature classes. So, now the only extra fields are for the BackSide. I'll mark your former reply correct!

0 Kudos