Select to view content in your preferred language

Create a shape with lines connecting adjacent polygons (from centroid points)

3628
3
Jump to solution
01-31-2013 02:10 PM
ElenaLopez
Deactivated User
Hi everyone,

I am looking for a tool that allows me to create a shapefile with lines connecting adjacent polygons.

For example: if polygon A has 2 adjacent polygons (B and C), I need to create a shapefile with a line that connects centroid of polygon A with centroid of polygon B and another line that connects centroid of polygon A with centroid of polygon C. The total number of polygons from which I have to do this is 300.

I have been able to do it for 1 polygon but it takes me 6 steps and the creation of multiples shapefiles and tables in the process. It's not a choice when trying to repeat the process for the 300 polygons of the shapefile. I need an easier way to do it !

Any help would be muuuuuch appreciated !

Thank you.
0 Kudos
1 Solution

Accepted Solutions
RichardFairhurst
MVP Honored Contributor
Hi everyone,

I am looking for a tool that allows me to create a shapefile with lines connecting adjacent polygons.

For example: if polygon A has 2 adjacent polygons (B and C), I need to create a shapefile with a line that connects centroid of polygon A with centroid of polygon B and another line that connects centroid of polygon A with centroid of polygon C. The total number of polygons from which I have to do this is 300.

I have been able to do it for 1 polygon but it takes me 6 steps and the creation of multiples shapefiles and tables in the process. It's not a choice when trying to repeat the process for the 300 polygons of the shapefile. I need an easier way to do it !

Any help would be muuuuuch appreciated !

Thank you.


Use Spatial Join of the layer with a copy of itseld using a very, very small overlapping tolerance. Use the One to Many option. This will cause each polygon to duplicate to cover as many neighbors as it has (plus itself). Filter out the cases where the ObjectIDs of the two layers are the same.

Add a text field called APN_PAIR and create a concatentation of the two parcel numbers with a space separator. Create a Long Integer Field and name it LINE_ORDER and calculate a 1 in it.

Start an edit session. Select all of the parcels in the layer and copy them to itself. While the copied set is still selected calculate the LINE_ORDER field as 2 and calculate the APN_PAIR as the reversed concatenation of the APN values. Save your edits and stop editing.

Use the Feature to Point tool on the data. Check the keep inside option.

Use the Point to Line tool using the concatenated APN_PAIR field as the Line Field and the LINE_ORDER field as the Sort field.

You should now have your lines with the first point in the center of the first APN in the concatenated APN_PAIR field and the last point in the second APN of the APN_PAIR field. Now create two APN fields and calculate the original separate APNs into them. If you filtered a particular APN and use arrowheads they will point out from the parcel.

The screen shot shows the result for 1379 parcels.

View solution in original post

0 Kudos
3 Replies
RichardFairhurst
MVP Honored Contributor
Hi everyone,

I am looking for a tool that allows me to create a shapefile with lines connecting adjacent polygons.

For example: if polygon A has 2 adjacent polygons (B and C), I need to create a shapefile with a line that connects centroid of polygon A with centroid of polygon B and another line that connects centroid of polygon A with centroid of polygon C. The total number of polygons from which I have to do this is 300.

I have been able to do it for 1 polygon but it takes me 6 steps and the creation of multiples shapefiles and tables in the process. It's not a choice when trying to repeat the process for the 300 polygons of the shapefile. I need an easier way to do it !

Any help would be muuuuuch appreciated !

Thank you.


Use Spatial Join of the layer with a copy of itseld using a very, very small overlapping tolerance. Use the One to Many option. This will cause each polygon to duplicate to cover as many neighbors as it has (plus itself). Filter out the cases where the ObjectIDs of the two layers are the same.

Add a text field called APN_PAIR and create a concatentation of the two parcel numbers with a space separator. Create a Long Integer Field and name it LINE_ORDER and calculate a 1 in it.

Start an edit session. Select all of the parcels in the layer and copy them to itself. While the copied set is still selected calculate the LINE_ORDER field as 2 and calculate the APN_PAIR as the reversed concatenation of the APN values. Save your edits and stop editing.

Use the Feature to Point tool on the data. Check the keep inside option.

Use the Point to Line tool using the concatenated APN_PAIR field as the Line Field and the LINE_ORDER field as the Sort field.

You should now have your lines with the first point in the center of the first APN in the concatenated APN_PAIR field and the last point in the second APN of the APN_PAIR field. Now create two APN fields and calculate the original separate APNs into them. If you filtered a particular APN and use arrowheads they will point out from the parcel.

The screen shot shows the result for 1379 parcels.
0 Kudos
ElenaLopez
Deactivated User
Thanks a lot, that was exactly what I meant !!

Just one more question: How can I delete from the final shapefile the duplicate lines (those connecting the same polygons) ?

The line connecting polygon A to polygon B is exactly the same as that connecting polygon B to polygon A. 

I need to delete duplicate lines.

I would really appreciate your help !
0 Kudos
RichardFairhurst
MVP Honored Contributor
Thanks a lot, that was exactly what I meant !!

Just one more question: How can I delete from the final shapefile the duplicate lines (those connecting the same polygons) ?

The line connecting polygon A to polygon B is exactly the same as that connecting polygon B to polygon A. 

I need to delete duplicate lines.

I would really appreciate your help !


Had I known this was what you wanted here is how the instructions would have gone.

Use Spatial Join of the layer with a copy of itself using a very, very small overlapping tolerance. Use the One to Many option. This will cause each polygon to duplicate to cover as many neighbors as it has (plus itself). Filter out the cases where the ObjectIDs of the two layers are the same.

Add a text field called APN_PAIR and select all cases where the first parcel is less than (<) the second parcel.  Create a concatentation of the two parcel numbers with a space separator with first parcel first and second parcel second (the concatenation will be in sorted pair order). Create a Long Integer Field and name it LINE_ORDER and calculate a 1 in it.

Select all cases where the first parcel is greater than (>) the second parcel.  Create a concatentation of the two parcel numbers with a space separator with the second parcel first and first parcel second (i.e, the concatenation keeps the pair in sorted order). Calculate a 2 in the LINE_ORDER field.
 
Use the Feature to Point tool on the data. Check the keep inside option.

Use the Point to Line tool using the concatenated APN_PAIR field as the Line Field and the LINE_ORDER field as the Sort field.

You should now have just one line for each parcel pair with your lines always originating from the parcel with the lower parcel number and ending in the parcel with the higher parcel number.

To create and polulate separate fields for the original Parcel numbers in the final connector lines, create two Parcel fields that are identical in type and configuration to your original Parcel field, and name them with names that relate to the Parcel field name, such as PARCEL1 and PARCEL2.

For PARCEL1 use the Field Calculator.  With the parser set as VB Script use this formula:

Split(APN_PAIR)(0)

For PARCEL2 use the Field Calculator.  With the parser set as VB Script use this formula:

Split(APN_PAIR)(1)

These two fields should now join/relate with your original Parcels.
0 Kudos