1

I want to create a centerline from a river polygon using PolygonToCenterline. It works when I use the tool in ArcGIS, but when I run it from the script I get the following error:

AttributeError: 'module' object has no attribute 'topographic'

I need to be able to run it from the script. I use ArcGIS Pro 2.2.0 with an advanced license. I think I did it exactly as in the description. Any ideas what I could try? I added the code below:

# Import arcpy module
import arcpy
# Check out Production Mapping License
arcpy.CheckOutExtension ('foundation')
# Define variables
river_polygon = r'C:\zhaw\masterarbeit\data\diego\typical_rivers.gdb\birs_2011'
out_gdb = r'C:\zhaw\masterarbeit\data\diego\typical_rivers.gdb\centerline'
# Execute Polygon To Centerline
arcpy.topographic.PolygonToCenterline(river_polygon, out_folder)
3
  • What version of Python / arcpy are you using, and are you running directly from command line or through an IDE? I don't see this tool in ArcGIS 10.5 help, so I suspect it's accessing arcpy for an earlier version instead of Pro. Here's a link for the various ways to start Python for ArcGIS Pro: pro.arcgis.com/en/pro-app/arcpy/get-started/… – smiller Nov 2 '18 at 13:56
  • Thanks a lot for the hint. I used Python 2.7.13 running it through Wing IDE. When I ran it using Python 3.6.5 it worked just fine. – Cyrill Nov 2 '18 at 14:15
  • Great! I'll add this as an official answer. Please take a moment to accept it when you have a chance. – smiller Nov 2 '18 at 14:16
0

Confirm what version of Python / arcpy is being used. I don't see this tool in ArcGIS 10.5 help, so it's probably accessing arcpy for an earlier version instead of Pro. Here's a link for the various ways to start Python for ArcGIS Pro: http://pro.arcgis.com/en/pro-app/arcpy/get-started/installing-python-for-arcgis-pro.htm

For example, you can start from a command line by using "%PROGRAMFILES%\ArcGIS\Pro\bin\Python\Scripts\propy"

If working within an IDE, check to see which version of Python is being used. It should be 3.x for Pro, not 2.x.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.