Hi, I'm looking for an easy way to take a spatial object and cut it to just contain the area above a certain longitude. For example, splitting the state of California on longitude 36.32 to get a "northern CA" and a "southern CA" zone. Right now I am making an object by poly-splitting the state and filtering for all centroidy < 36.32 then re-forming the polygon and cutting it from the full state object. It seems like there should be an easier way. Any ideas?
Solved! Go to Solution.
There's a few ways you can go about there. I would start by creating a bounding rectangle around the state. Once that is drawn, build polygons that covers the north and south of the state based on your desired split value of 36.32 and spatial process the matching area of each.
Alternatively, you could draw a line through the state and add a tiiiiny buffer around that line so it's a polygon that can be used to cut from the state polygon. Then a Poly Split tool will break out those regions for you. This doesn't work perfectly here because of the islands present in the California polygon I used. This is just to show an alternative, and I would recommend using the first method.
Check out the attached example to see both methods in action and let me know if you have any questions.
EDIT: Fun fact: you can do this with a single formula tool and two formulas. I've added that to the attached example. If you input object is [SpatialObj], then the formula for the northern part is as follows:
ST_Intersection([SpatialObj]
,ST_CreatePolygon(
ST_CreatePoint(ST_MinX(ST_BoundingRectangle([SpatialObj])),36.32)
,ST_CreatePoint(ST_MaxX(ST_BoundingRectangle([SpatialObj])),36.32)
,ST_CreatePoint(ST_MaxX(ST_BoundingRectangle([SpatialObj])),ST_MaxY(ST_BoundingRectangle([SpatialObj])))
,ST_CreatePoint(ST_MinX(ST_BoundingRectangle([SpatialObj])),ST_MaxY(ST_BoundingRectangle([SpatialObj])))
))
this is great, thanks so much!
dang @CharlieS well played sir. Spatial formulas are the great hidden features within alteryx.
The final product attached. I had more than just California to cut so made two inputs, one for North/South cuts and one for East/West cuts (I could probably have spent more time and been more clever with if statements and got them all in one, but oh well).
I just have the north and west regions, but realize if I needed them I could use the Cut formula instead of the intersection formula to get the other half of the state.
This saved me about 10 tools, so thanks again!!