Select to view content in your preferred language

Drawing lines at angles from xy coordinate

6956
14
Jump to solution
12-03-2015 01:54 PM
LauraBlackburn
Deactivated User

I have three fixed points and a number of lines I would like to draw that radiate out from each point.  I have tried to use the bearing distance to line tool but it keeps failing for some reason and I'm not exactly sure how to draw my lines otherwise.  I am using the angle field for the bearing and this is in degrees (I think...the values fall between 0 and 360).  And my distance field is the 20yrSpread field which is in KM.

Any help is greatly appreciated...see the attached table.

0 Kudos
1 Solution

Accepted Solutions
DarrenWiens2
MVP Honored Contributor

No, I ran this directly from the provided Excel file. I just highlighted the zero distance rows in Excel, right-click delete (don't leave blank rows by pressing delete key), save Excel, then run Bearing Distance to Line tool on Excel file. That said, sometimes Excel files cause funky issues and can vary between versions of Excel and ArcGIS, so don't be shocked if it doesn't work in .xlsx format.

View solution in original post

0 Kudos
14 Replies
RichardFairhurst
MVP Honored Contributor

The Bearing Distance to Line tool fails due to the negative values in the 20yrSpread field.  It is impossible to create a line with negative length.  You either need to change all the values to their absolute value (positive), or create a new field and set it to the absolute value of the 20yrSrpread length.  If you need to reverse the line direction for some reason after creating it based on the signed value of the length in the 20yrSpread field, that would happen in a separate step.

KyleBalke__GISP
Frequent Contributor

Looks like you have some negative numbers in your distance field (20yrSpread)...might be causing the tool to fail.

0 Kudos
LauraBlackburn
Deactivated User

I altered my excel file (attached) so that the negative values were just zeros instead of a negative value and re-ran the bearing distance tool using the alt10yrSpread or the alt20yrSpread fields for the distance and it still didn't work.

Here's the error that I get in case that helps to figure out the problem:

Runtime error  Traceback (most recent call last):   File "<string>", line 1, in <module>   File "c:\program files (x86)\arcgis\desktop10.3\arcpy\arcpy\management.py", line 2360, in BearingDistanceToLineraise e ExecuteError: ERROR 999999: Error executing function. No current record. Failed to execute (BearingDistanceToLine).

Any other ideas on how to draw these lines besides manually drawing them in an editing session is greatly appreciated.

0 Kudos
DarrenWiens2
MVP Honored Contributor

I assume your problem is now that you're trying to draw lines of distance zero.

I deleted those rows in your table, and it seems to work, although I'm not sure what your spatial reference is:

LauraBlackburn
Deactivated User

Hi Daren,

Are you doing anything special to the table, like placing it in a geodatabase?

When I try to run the tool (after changing the values to all positives) it tells me that the input table does not exist or is not supported.

Just wondering what you did to make it work.

0 Kudos
DanPatterson_Retired
MVP Emeritus

try getting it into any other format than an excel file

DarrenWiens2
MVP Honored Contributor

No, I ran this directly from the provided Excel file. I just highlighted the zero distance rows in Excel, right-click delete (don't leave blank rows by pressing delete key), save Excel, then run Bearing Distance to Line tool on Excel file. That said, sometimes Excel files cause funky issues and can vary between versions of Excel and ArcGIS, so don't be shocked if it doesn't work in .xlsx format.

0 Kudos
RichardFairhurst
MVP Honored Contributor

Field names cannot begin with numbers.  So the 15yrDisplacement and 20yrSpread fields need to be changed to start with a letter.  I changed them to Displacement15yr and Spread20yr and the tool then worked directly from the xlsx file I downloaded.  The output table also should begin with a letter and not a number.  I figured this out when I ran the Excel to Table tool and it automatically changed the 15yrDisplacement and 20yrSpread column names to f15yrDisplacement and f20yrSpread.  Beginning field names with numbers has always been discouraged since it is known to cause issues all over ArcGIS.

The tool actually does work with the negative length values.  It automatically reverses the angle and converts the length to a positive value when it encounters a negative length value, so if that is what you want you don't have to change the bearing or distance values for the rows with negative lengths.  The negative length lines are highlighted in blue in the picture below.

RichardFairhurst
MVP Honored Contributor

Laura:

Lines with 0 distance are points, not lines, and the tool does not support drawing points.  You must assign a length value greater than 0 to those rows or eliminate those rows as Darren suggested.  You don't have to necessarily delete those rows if you use a layer/table view with a selection of only the rows that have a length greater than 0 as the input to the tool.  Potentially one approach to those rows with negative lengths is to select all of those rows and calculate the angle field to reverse the angle by adding 180 degrees to the angle (the tool should handle angle values that equal or exceed 360 degrees), then set the length to ABS([20yrSpread]) so that it is positive.