How to draw a graphic line in PRO using Python

2881
8
Jump to solution
02-02-2021 10:09 AM
JaniceBaird
Occasional Contributor II

How can I add a graphic to the map in arcgis pro 2.6 or 2.7 using python? I have a script that selects point features based on attributes and I have collected the x,y values from the point features. I want to draw a line from one point to the other. I can create a polyline but do not know how to add it to the graphics layer to display it.

Anyone else creating graphics in pro using python?

I am sure there must be a way to do this but I am unable to find any documentation.

Thanks,

Janice.

0 Kudos
1 Solution

Accepted Solutions
DanPatterson
MVP Esteemed Contributor

I don't even see it on the long term list.  An idea perhaps for the ideas site.

You can "fudge" it using copy features to create the temporary featureclass and the line at once.

It won't be a graphic though

line1.png


... sort of retired...

View solution in original post

0 Kudos
8 Replies
DanPatterson
MVP Esteemed Contributor

you can create features in a featureclass

there is no graphics class in arcpy

ArcGIS Pro Python reference—ArcGIS Pro | Documentation


... sort of retired...
0 Kudos
VickyWang
Esri Contributor

Hi @JaniceBaird , 

The points to line method can input point feature as input with output to a line feature class. 

hope this helps.

https://pro.arcgis.com/en/pro-app/latest/tool-reference/data-management/points-to-line.htm

~Vicky Wang~
0 Kudos
JaniceBaird
Occasional Contributor II

To those who have replied so far, thanks for the info...

I do not want to create a feature class... I am really looking for adding graphics to a graphics layer using python.

If this is not yet available in ArcGIS Pro, I suppose I need to do this using feature classes. Or, maybe javascript... 

Thanks,

Janice.

VickyWang
Esri Contributor

As @DanPatterson mention that in ArcGIS Pro will not create a graphic line but a feature class. 

Yes. you can create a graphic line from points in Javascript. 

~Vicky Wang~
0 Kudos
DanPatterson
MVP Esteemed Contributor

line.png

 

 

 

You just have to display it elsewhere 😉


... sort of retired...
JaniceBaird
Occasional Contributor II

@DanPatterson I am not sure I understand... I can draw a graphic line with python in arcgis pro as long as I don't want to display it in a graphics layer? Not following.

I have my script working by using a feature class. The feature class gets written over every time I run the script. It is doing exactly what I want except that it is not using graphics and a graphics layer. I was tasked with writing a script that would add graphics to the map view in pro. I will report back that it can not be done at 2.7.

Anyone know when this will be available in ArcGIS Pro?

Thanks to those who have replied.

Janice.

0 Kudos
DanPatterson
MVP Esteemed Contributor

I don't even see it on the long term list.  An idea perhaps for the ideas site.

You can "fudge" it using copy features to create the temporary featureclass and the line at once.

It won't be a graphic though

line1.png


... sort of retired...
0 Kudos
JackFanZhang
Occasional Contributor

I have used the embed Notebook in ArcGIS Pro to run some quick Python code snippet, because the UI is better than than hopeless embed Python Window, even Notebook in ArcGIS Pro doesn't support code intelligence.

I just want to quickly overlay the temporary result  points/lines/polygons of Notebook cell against other layers in the ArcGIS Pro map, but I can't find a shortcut but have to create temp feature class, insert, blahblahblah. 

ESRI please update your arcpy and Notebook modules to make it more interactive with ArcGIS Pro map like how it works with web map (e.g. plot geometry data to graphic layer). 

 

 

 

0 Kudos