Select to view content in your preferred language

Module object reading error attribute

1140
10
01-10-2023 10:22 AM
JasonMa
Emerging Contributor

 

 

"""
Tesing the detect Gaps
"""
#import arcpy module
import arcpy

#Chcek out any necessary to licnes
arcpy.CheckOutExtension("Calgary1_done")

#local variables set
setNetwork = r"G:\Jason Ma\2022Q3 HERE shapefiles\Corridors\Old corridors\Calgary1_done"
#event =
final_gaps_output= r"G:\Jason Ma\2022Q3 HERE shapefiles\Corridors\Old corridors\New_Gaps_Cal1"



#Detect the GAPS in the linear events
arcpy.env.overwriteOutput = 1 
arcpy.DetectGapsForLinearEvents_locref(setNetwork, final_gaps_output)

 

 

Hello all staff of Esri, 

 

I am trying to create a function which detect gaps within road layer, seems that the library from Arcpy is not reading the module correctly in of the arcpy functions:  

Error: 

Runtime error
Traceback (most recent call last):
File "<string>", line 18, in <module>
AttributeError: 'module' object has no attribute 'DetectGapsForLinearEvents_locref'
>>>

 

Any suggests and Help I glad to hear , Thanks you 

0 Kudos
10 Replies
by Anonymous User
Not applicable

This is not available in Pro / Py 3.0.

unavailable-tools  - Location Referecing Tools section

You'll have to use the arcpy 2.7 version if you want to use that method DetectGapsForLinearEvents_locref

0 Kudos
JasonMa
Emerging Contributor

Hey @Anonymous User ,

 

Thanks for the reply, Yes I believe I understand the version difference, I did run the script in the 3.8 version, but the ArcMAP desktop I have is build-in fixed as 2.7, do the method DetectGapsForLinearEvents_locref should have recognized from the library, but I do not why arcpy is not reading the method and/or not found. Is there something I am missing? From the Code above?

0 Kudos
by Anonymous User
Not applicable

That is expected because arcpy modules are independent per python version and python environment.

Since you ran it in 3.8, it is looking at the 3.8 arcpy module within the 3.8 environment and it doesn't reach out to 2.7.

You have to point your IDE to which python version you want the script to execute in, so it would be using the C:\Python27\ArcGIS10.x\python.exe and 2.7 arcpy module, where the DetectGapsForLinearEvents_locref is.

JasonMa
Emerging Contributor

Hello @Anonymous User ,

Thank for the reply, I will see if IDE script which I can run maybe using 2.7 script rather than the 3.8 script environment. My question is I am running the above script directly in the ArcMap python build-in which is fixed 2.7 version , but I used version , I didnt run it in 3.8 IDE since there are no arcpy build into it. If you understand what I mean ? OR if there is something I am missing , please let me know 

 

Thanks again for the help and comments 

0 Kudos
by Anonymous User
Not applicable

Not sure if I follow that, are you running it in Pro, or ArcMap?

If you are in 2.7, the docs show that you need the 'Roads and Highways' extension (not Calgary1_done- which looks like it is something else) and you are missing a required parameter at the event argument. Your out_feature is in the in_event slot:

arcpy.locref.DetectGapsForLinearEvents(in_network, in_event, out_feature, {in_tvd}, {in_from_measure}, {in_to_measure}, {in_tolerance})

 

0 Kudos
JasonMa
Emerging Contributor

Hey @Anonymous User , 

        I am running ArcMap 10.8 and built in python version 2.7 , Calgary1_done is just a city work I m trying correct urban areas. I want to see if I can make a Gap script to indenified missing data and gaps within these city. I need these parameters possible to make it work ? I thought I needed a local variable where  need set to my folder thats all'

Thanks

 

 

0 Kudos
JasonMa
Emerging Contributor

also what are functions of these parameters? 

in_network, in_event, out_feature, {in_tvd}, {in_from_measure}, {in_to_measure}, {in_tolerance} 

 

0 Kudos
by Anonymous User
Not applicable

Check out the docs for the explanation of those arguments:

roads-and-highways-toolbox/detect-gaps-for-linear-events 

JasonMa
Emerging Contributor

Thanks @Anonymous User for the post,my apologies for intrusion, I put on the arguments and other parameters where necessary according to your instructions and I not  why python 2.7 shell was not able to read library locref as you wrote , I received this error : 

       Traceback (most recent call last):
File "G:\Jason Ma\Python scripts\CCTD\GapDetect.py", line 7, in <module>
from locref import DetectGapsForLinearEvents
ImportError: No module named locref

 

"""
Tesing the detect Gaps
"""
#import arcpy module
import arcpy
from arcpy import env
#from locref import DetectGapsForLinearEvents 

#Chcek out any necessary to licnes
arcpy.CheckOutExtension("Calgary1_done")

#local variables set
setNetwork = r"G:\Jason Ma\2022Q3 HERE shapefiles\Corridors\Old corridors\Calgary1_done"
#event =
final_gaps_output= r"G:\Jason Ma\2022Q3 HERE shapefiles\Corridors\Old corridors\New_Gaps_Cal1"



#Detect the GAPS in the linear events
arcpy.env.overwriteOutput = 1 
arcpy.DetectGapsForLinearEvents_roads(in_network,in_event,out_feature,{in_tvd},{in_from_measure},{in_to_measure},{in_tolerance},setNetwork, final_gaps_output)

@Anonymous User wrote:

Check out the docs for the explanation of those arguments:

roads-and-highways-toolbox/detect-gaps-for-linear-events 




0 Kudos