Creating a table with COGO

299
4
02-19-2024 03:35 AM
jw2109
by
New Contributor

Hello everyone, i wanted to know if it is possible to create a table of line directions automatically witht the COGO function. 

I know how to put angles in the attribute table after adding a field, with this methodology, however, i would have to manually input all the angles; my question is is there a way to do it automatically, in bulk, rather than each line at a time.

Thank you for any help. 

0 Kudos
4 Replies
JeffHouser
Occasional Contributor

Hello jw2109,

Looks like there are several examples to get you going.  A good source with Python code, https://pro.arcgis.com/en/pro-app/latest/tool-reference/data-management/enable-cogo.htm

EnableCOGO example 1 (Python window)

The following Python window script demonstrates how to use the EnableCOGO function in immediate mode.

import arcpy arcpy.env.workspace = "E:\ArcGISXI\Mont\Montgomery.gdb" arcpy.EnableCOGO_management("\Landbase\Road_cl")

or

EnableCOGO example 2 (stand-alone script)

The following stand-alone script demonstrates how to check for and enable COGO on a line feature class.

import arcpy # Variable to contain the path of the feature class that is to be COGO enabled lineFeatureClass = r"d:\test.gdb\myLineFC" # Check to see if the feature class is already enabled by using .isCOGOEnabled on a Describe if arcpy.Describe(lineFeatureClass).isCOGOEnabled == False: # If it returns False, run EnableCOGO_management and pass the feature class arcpy.EnableCOGO_management(lineFeatureClass) else: print("{} is already COGO Enabled".format(lineFeatureClass))

 

Let us know how it goes or if additional detail is needed/helpful 😄

~Jeff

jw2109
by
New Contributor

Hi Jeff,

Thank you very much for replying.

Although I really appreciate your efforts, i have no idea how i would carry this out, I'm onl;y a university student i've never worked with code, i know where the python window is and thats about it. I will try to work this out anyway (i will probably be unsuccessful). Again, thank you for your efforts.

0 Kudos
jw2109
by
New Contributor

Hello Jeff,

I've been getting python help from a lecturer at my university and he keeps getting a syntax error and he also cannot work out what the problem is this is the issue: 

if arcpy.Describe(lineFeatureClass).isCOGOEnabled == False:

    arcpy.EnableCOGO_management(lineFeatureClass)

    else:

        print("Already done")

SyntaxError                               Traceback (most recent call last)

File C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\ast.py, in parse:

Line 50:    return compile(source, filename, mode, flags,

 

SyntaxError: invalid syntax (<string>, line 3)

0 Kudos
JeffHouser
Occasional Contributor

Hello JW,

Not sure if there's enough info in your post regarding the error?  I am not familiar with ast.py.  Upfront in your code, did you "import ast"?  I'm assuming you are. Not sure if you have at this point, but refer to the following for more info on compile(source, filename, mode, flags). 

https://python-reference.readthedocs.io/en/latest/docs/functions/compile.html

~Jeff

0 Kudos