Advent of Code is back! Unwrap daily challenges to sharpen your Alteryx skills and earn badges along the way! Learn more now.
Free Trial

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

Shift polygons to different locations

abrahamlauer
7 - Meteor

Is it possible to take a polygon shape and shift it to a different location?  My use case is to duplicate a polygon and 'center' the new object on a point.  For example, if I wanted to compare the size of California and Texas, I would create a new California with it's centroid located at Texas' centroid.

7 REPLIES 7
Felipe_Ribeir0
16 - Nebula

If you want to compare the size (area) of California and Texas, it wouldnt be more easier to just get the area of each one with the Spatial Info tool and compare it as you wish?

 

Felipe_Ribeir0_0-1667427163339.png

 

gabrielvilella
14 - Magnetar

Hi @abrahamlauer, if you want to shift the location of a polygon you need to first calculate the X and Y difference from both centroids based on their lat, lon and then apply this shift on each point that creates the polygon you want to move. Here is how I did it.

gabrielvilella_0-1667428818748.png

gabrielvilella_1-1667428848554.png

 

DataNath
17 - Castor
17 - Castor

@gabrielvilella this is fine if you want an overview of what a rough recreation of the polygon will look like overlayed in that position. However, a word of warning here that if we dive into the size of the recreated polygon vs the original with the spatial info tool, we can see that rebuilding the shape this way isn't actually accurate and in fact increases the size by a decent amount, so not great if a detailed comparison is needed:

 

DataNath_0-1667430099561.png

abrahamlauer
7 - Meteor

@Feilpe_Rebeir0 - No, the use case is to create a new polygon at a different location, not to compare the areas of two different polygons.  I could have worded my example better.

 

Felipe_Ribeir0
16 - Nebula

@abrahamlauer understood! So the workflow provided by gabriel with some modification that correct the error pointed by datanath probably is the best way to go

abrahamlauer
7 - Meteor

@gabrielvilella - Phenomenal.  I was so engrossed in moving the polygon that I never considered breaking it into points.  Thank you!

abrahamlauer
7 - Meteor

@DataNath - Good callout.  The size difference is due to performing straight addition on the lat/lons rather than applying trig functions to account for the curvature of the earth.  Note how moving the object south increases the size and moving it north decreases the size.  

 

abrahamlauer_0-1667489613536.png

 

Labels
Top Solution Authors