How to evaluate the world orientation of building footprints

443
4
12-05-2020 09:41 AM
Occasional Contributor

In a block with offset subdivision, I need to evaluate whether a lot sits on an East-West or North-South oriented street or – alternatively – whether the long edge of a sub shape is oriented East-West or North-South.

Is there a simple way to do that?

I have been researching the convert and comp functions as well as the geometry.isOriented and the geometry.angle functions. The former two I can't get my head around and the latter two only work on non-horizontal shapes. As I need to evaluate the orientation before I extrude the building envelopes, I find myself in a bit of a catch-22.

Any help would be much appreciated.

Nic

Image: Building footprints colored according to their world orientation with their long edge oriented either East-West (red) or North-South (blue)

building orientation.png

Reply
0 Kudos
4 Replies
New Contributor III

In Python:

def get_orientation(shape):
    """Returns a string describing the orientation ('NS', 'EW', or 'SQUARE') of the given feature geometry."""
    extent = shape.extent
    len_x = extent.XMax - extent.XMin
    len_y = extent.YMax - extent.YMin
    if len_x > len_y:
        return 'EW'
    if len_y > len_x:
        return 'NS'
    return 'SQUARE'

# do something with these values (e.g. calculate a field)
with arcpy.da.UpdateCursor(feature_class, ["SHAPE@", "Orientation"]) as cursor:
    for shape, orientation in cursor:
        orientation = get_orientation(shape)
        cursor.updateRow([shape, orientation])
        
Reply
0 Kudos
Occasional Contributor

Hi, thanks for the answer, yet as I understand it (I’m an architect, not a programmer) python rutines need to be activated manually and cannot be evoked by a cga script. Correct?

In that case, this solution is of little help to me, as I might as well check it manually/visually as to run a python script. What I need is for my cga script to be able to do the evaluation. Any chance of that?

(While I am quite fluent in cga, I have no clue of python.)

Best,

Nic

Reply
0 Kudos
New Contributor III

Ah, I didn't realize this was posted in the CityEngine group...

While I'm quite fluent in python, I have no clue of cga 🙂

Yeah, you'd have to manually start the python script. If that doesn't work for you, you could try out Attribute Rules (assuming you have an Enterprise or File Geodatabase with your data).

Overview of Attribute Rules 

Create a calculation rule that triggers on insert and update with the following Arcade code (same concept as the python code above):

var e = Extent(Geometry($feature))
var len_x = e.xmax - e.xmin
var len_y = e.ymax - e.ymin 
return When(len_x > len_y, 'EW', len_y > len_x, 'NS', 'SQUARE')

 

Reply
0 Kudos
by
New Contributor

you can use two array functions with comp.sel to detect the street frontage and another one to detect world orientation, so if the side is a street front and it is face east or west then it's on a N/S street, or if its facing north or south then it's on a W/E street, 

Sorry cant do up the codes, dont have a personal CE license, n at work's too busy to do it.

Reply
0 Kudos