Select to view content in your preferred language

Viewing Survey Area of an Observation

2520
11
Jump to solution
08-16-2022 04:13 PM
Labels (3)
PaintedSun
Emerging Contributor

Hello! 

I have a large dataset that I want to be able to create a polygons from it to visualize what survey area a person is observing. The dataset consists of:

- Location Data (UTM's, NAD 1983)

- Left Bearing 

- Right Bearing

- Visible Distance (in meters)

Can anyone point me in the right direction on how I can do this? I'm very new to mapping so if you can use basic terminology it would be appreciated!

0 Kudos
11 Replies
PaintedSun
Emerging Contributor

Oh gosh, I know so little! Yes, I just labelled the field in the excel sheet, not realizing what an OID was until I did some Googling. 

I added a column to my excel sheet:

PaintedSun_0-1660755810701.png

 

Which gives me this table in Arc GIS Pro:

PaintedSun_1-1660755889134.png

 

I entered the code into the Python pane as such:

def circle_section(x, y, start, end, radius, wkid):
    """Creates a circle section.
        x, y: float, coordinates of the center
        start, end: int, start and end of the section in degrees, Nort=0°, East=90°
        radius: float, radius of the section
        wkid: int, well-known id of the coordinate system

        returns an arcpy.Polygon in the chosen coordinate system
    """
    start = int(start)
    end = int(end)
    center = arcpy.Point(x, y)
    center_geo = arcpy.PointGeometry(center, wkid)
    arc_geos = [center_geo.pointFromAngleAndDistance(angle, radius, "PLANAR") for angle in range(start, end, 1)]
    points = [center] +  [ag.firstPoint for ag in arc_geos] + [center]
    return arcpy.Polygon(arcpy.Array(points), spatial_reference=wkid)


def create_view_sheds(in_table, out_features, x_field, y_field, bearing_left_field, bearing_right_field, distance_field, wkid):
    """Creates a polygon feature class with circle sections.

    in_table: str, path to the input table or name of the table in the active map
    out_features: str, path to the output feature class
    *_field: str, names of the fields in the input table
    wkid: int, well-known id of the coordinate system
    """
    # create output feature class
    from pathlib import Path
    folder = str(Path(out_features).parent)
    name = str(Path(out_features).name)
    arcpy.management.CreateFeatureclass(folder, name, "POLYGON", spatial_reference=wkid)
    arcpy.management.AddField(out_features, "FID", "LONG")

    with arcpy.da.InsertCursor(out_features, ["SHAPE@", "FID"]) as i_cursor:
        with arcpy.da.SearchCursor(in_table, ["ID", x_field, y_field, bearing_left_field, bearing_right_field, distance_field]) as s_cursor:
            # for each table row
            for oid, x, y, bearing_left, bearing_right, distance in s_cursor:
                # create a circle section 
                poly = circle_section(x, y, bearing_left, bearing_right, distance, wkid)
                # write the polygon and the table row's objectid into the feature class
                i_cursor.insertRow([poly, oid])
create_view_sheds("Observations", "memory/Viewsheds", "X", "Y", "BearingLeft", "BearingRight", "Distance", 25832)

The program seems to read it (there are no more error messages) and creates a Viewshed, but... it's blank. 

PaintedSun_2-1660756241850.png

I tried changing the order layer and style to see if it was hidden somehow, but it didn't do anything. Did I edit the code correctly?

0 Kudos
PaintedSun
Emerging Contributor

The Fields chart data type says it is 'Long'. Is that appropriate? 

0 Kudos