Getting AttributeError from ArcPy?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty margin-bottom:0;







up vote
1
down vote

favorite












I'm working on a simple Python code to make a raster from a shapefile using the Natural Neighbors tool, and then use the resulting raster to generate a contour using the Contour tool. I keep getting an Attribute Error saying the module has no attribute.



The following is my code:



import arcpy

arcpy.env.overwriteOutput = True

# Variable Definitions

in_point_features = "C:\GIS\PythonProgramming\Lesson3\Lesson3_Data\WellsSubset.shp"
z_field = "TD"
out_polyline_features = "C:\GIS\PythonProgramming\Lesson3\Lesson3_Data\ContourOut.shp"

# Generate raster from WellsSubset shapefile using Natural Neighbor interpolation

raster = arcpy.NaturalNeighbor (in_point_features, z_field)

# Use Contour tool with 1500 as contour interval on the raster

arcpy.Contour (raster, out_polyline_features, 1500)


The following is the error message I get when I run it:
Traceback (most recent call last):
File "C:/GIS/PythonProgramming/Lesson3/Crotty_Homework3.py", line 15, in



<module>
raster = arcpy.NaturalNeighbor (in_point_features, z_field)
AttributeError: 'module' object has no attribute 'NaturalNeighbor'


Can anyone steer me in the right direction here?










share|improve this question









New contributor




Alex C is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.















  • 2




    Did you check out the spatial analyst extension? arcpy.CheckOutExtension("Spatial") Import Spatial Analyst
    – Pdavis327
    3 hours ago











  • Thank you for responding. I did need to include that
    – Alex C
    3 hours ago
















up vote
1
down vote

favorite












I'm working on a simple Python code to make a raster from a shapefile using the Natural Neighbors tool, and then use the resulting raster to generate a contour using the Contour tool. I keep getting an Attribute Error saying the module has no attribute.



The following is my code:



import arcpy

arcpy.env.overwriteOutput = True

# Variable Definitions

in_point_features = "C:\GIS\PythonProgramming\Lesson3\Lesson3_Data\WellsSubset.shp"
z_field = "TD"
out_polyline_features = "C:\GIS\PythonProgramming\Lesson3\Lesson3_Data\ContourOut.shp"

# Generate raster from WellsSubset shapefile using Natural Neighbor interpolation

raster = arcpy.NaturalNeighbor (in_point_features, z_field)

# Use Contour tool with 1500 as contour interval on the raster

arcpy.Contour (raster, out_polyline_features, 1500)


The following is the error message I get when I run it:
Traceback (most recent call last):
File "C:/GIS/PythonProgramming/Lesson3/Crotty_Homework3.py", line 15, in



<module>
raster = arcpy.NaturalNeighbor (in_point_features, z_field)
AttributeError: 'module' object has no attribute 'NaturalNeighbor'


Can anyone steer me in the right direction here?










share|improve this question









New contributor




Alex C is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.















  • 2




    Did you check out the spatial analyst extension? arcpy.CheckOutExtension("Spatial") Import Spatial Analyst
    – Pdavis327
    3 hours ago











  • Thank you for responding. I did need to include that
    – Alex C
    3 hours ago












up vote
1
down vote

favorite









up vote
1
down vote

favorite











I'm working on a simple Python code to make a raster from a shapefile using the Natural Neighbors tool, and then use the resulting raster to generate a contour using the Contour tool. I keep getting an Attribute Error saying the module has no attribute.



The following is my code:



import arcpy

arcpy.env.overwriteOutput = True

# Variable Definitions

in_point_features = "C:\GIS\PythonProgramming\Lesson3\Lesson3_Data\WellsSubset.shp"
z_field = "TD"
out_polyline_features = "C:\GIS\PythonProgramming\Lesson3\Lesson3_Data\ContourOut.shp"

# Generate raster from WellsSubset shapefile using Natural Neighbor interpolation

raster = arcpy.NaturalNeighbor (in_point_features, z_field)

# Use Contour tool with 1500 as contour interval on the raster

arcpy.Contour (raster, out_polyline_features, 1500)


The following is the error message I get when I run it:
Traceback (most recent call last):
File "C:/GIS/PythonProgramming/Lesson3/Crotty_Homework3.py", line 15, in



<module>
raster = arcpy.NaturalNeighbor (in_point_features, z_field)
AttributeError: 'module' object has no attribute 'NaturalNeighbor'


Can anyone steer me in the right direction here?










share|improve this question









New contributor




Alex C is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











I'm working on a simple Python code to make a raster from a shapefile using the Natural Neighbors tool, and then use the resulting raster to generate a contour using the Contour tool. I keep getting an Attribute Error saying the module has no attribute.



The following is my code:



import arcpy

arcpy.env.overwriteOutput = True

# Variable Definitions

in_point_features = "C:\GIS\PythonProgramming\Lesson3\Lesson3_Data\WellsSubset.shp"
z_field = "TD"
out_polyline_features = "C:\GIS\PythonProgramming\Lesson3\Lesson3_Data\ContourOut.shp"

# Generate raster from WellsSubset shapefile using Natural Neighbor interpolation

raster = arcpy.NaturalNeighbor (in_point_features, z_field)

# Use Contour tool with 1500 as contour interval on the raster

arcpy.Contour (raster, out_polyline_features, 1500)


The following is the error message I get when I run it:
Traceback (most recent call last):
File "C:/GIS/PythonProgramming/Lesson3/Crotty_Homework3.py", line 15, in



<module>
raster = arcpy.NaturalNeighbor (in_point_features, z_field)
AttributeError: 'module' object has no attribute 'NaturalNeighbor'


Can anyone steer me in the right direction here?







arcpy spatial-analyst attributeerror






share|improve this question









New contributor




Alex C is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




Alex C is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited 3 hours ago









Vince

14.1k32444




14.1k32444






New contributor




Alex C is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked 3 hours ago









Alex C

61




61




New contributor




Alex C is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





Alex C is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






Alex C is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.







  • 2




    Did you check out the spatial analyst extension? arcpy.CheckOutExtension("Spatial") Import Spatial Analyst
    – Pdavis327
    3 hours ago











  • Thank you for responding. I did need to include that
    – Alex C
    3 hours ago












  • 2




    Did you check out the spatial analyst extension? arcpy.CheckOutExtension("Spatial") Import Spatial Analyst
    – Pdavis327
    3 hours ago











  • Thank you for responding. I did need to include that
    – Alex C
    3 hours ago







2




2




Did you check out the spatial analyst extension? arcpy.CheckOutExtension("Spatial") Import Spatial Analyst
– Pdavis327
3 hours ago





Did you check out the spatial analyst extension? arcpy.CheckOutExtension("Spatial") Import Spatial Analyst
– Pdavis327
3 hours ago













Thank you for responding. I did need to include that
– Alex C
3 hours ago




Thank you for responding. I did need to include that
– Alex C
3 hours ago










1 Answer
1






active

oldest

votes

















up vote
2
down vote













You need to properly call the Spatial Analyst license and module. In your case, the syntax would be as follows:



import arcpy
arcpy.CheckOutExtension("Spatial") # This checks out the license
from arcpy.sa import * # This imports all the SA tools

arcpy.env.overwriteOutput = True

# Variable Definitions

in_point_features = "C:\GIS\PythonProgramming\Lesson3\Lesson3_Data\WellsSubset.shp"
z_field = "TD"
out_polyline_features = "C:\GIS\PythonProgramming\Lesson3\Lesson3_Data\ContourOut.shp"

# Generate raster from WellsSubset shapefile using Natural Neighbor interpolation

raster = NaturalNeighbor (in_point_features, z_field)

# Use Contour tool with 1500 as contour interval on the raster

Contour (raster, out_polyline_features, 1500)





share|improve this answer






















    Your Answer







    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "79"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    convertImagesToLinks: false,
    noModals: false,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );






    Alex C is a new contributor. Be nice, and check out our Code of Conduct.









     

    draft saved


    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f297508%2fgetting-attributeerror-from-arcpy%23new-answer', 'question_page');

    );

    Post as a guest






























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    2
    down vote













    You need to properly call the Spatial Analyst license and module. In your case, the syntax would be as follows:



    import arcpy
    arcpy.CheckOutExtension("Spatial") # This checks out the license
    from arcpy.sa import * # This imports all the SA tools

    arcpy.env.overwriteOutput = True

    # Variable Definitions

    in_point_features = "C:\GIS\PythonProgramming\Lesson3\Lesson3_Data\WellsSubset.shp"
    z_field = "TD"
    out_polyline_features = "C:\GIS\PythonProgramming\Lesson3\Lesson3_Data\ContourOut.shp"

    # Generate raster from WellsSubset shapefile using Natural Neighbor interpolation

    raster = NaturalNeighbor (in_point_features, z_field)

    # Use Contour tool with 1500 as contour interval on the raster

    Contour (raster, out_polyline_features, 1500)





    share|improve this answer


























      up vote
      2
      down vote













      You need to properly call the Spatial Analyst license and module. In your case, the syntax would be as follows:



      import arcpy
      arcpy.CheckOutExtension("Spatial") # This checks out the license
      from arcpy.sa import * # This imports all the SA tools

      arcpy.env.overwriteOutput = True

      # Variable Definitions

      in_point_features = "C:\GIS\PythonProgramming\Lesson3\Lesson3_Data\WellsSubset.shp"
      z_field = "TD"
      out_polyline_features = "C:\GIS\PythonProgramming\Lesson3\Lesson3_Data\ContourOut.shp"

      # Generate raster from WellsSubset shapefile using Natural Neighbor interpolation

      raster = NaturalNeighbor (in_point_features, z_field)

      # Use Contour tool with 1500 as contour interval on the raster

      Contour (raster, out_polyline_features, 1500)





      share|improve this answer
























        up vote
        2
        down vote










        up vote
        2
        down vote









        You need to properly call the Spatial Analyst license and module. In your case, the syntax would be as follows:



        import arcpy
        arcpy.CheckOutExtension("Spatial") # This checks out the license
        from arcpy.sa import * # This imports all the SA tools

        arcpy.env.overwriteOutput = True

        # Variable Definitions

        in_point_features = "C:\GIS\PythonProgramming\Lesson3\Lesson3_Data\WellsSubset.shp"
        z_field = "TD"
        out_polyline_features = "C:\GIS\PythonProgramming\Lesson3\Lesson3_Data\ContourOut.shp"

        # Generate raster from WellsSubset shapefile using Natural Neighbor interpolation

        raster = NaturalNeighbor (in_point_features, z_field)

        # Use Contour tool with 1500 as contour interval on the raster

        Contour (raster, out_polyline_features, 1500)





        share|improve this answer














        You need to properly call the Spatial Analyst license and module. In your case, the syntax would be as follows:



        import arcpy
        arcpy.CheckOutExtension("Spatial") # This checks out the license
        from arcpy.sa import * # This imports all the SA tools

        arcpy.env.overwriteOutput = True

        # Variable Definitions

        in_point_features = "C:\GIS\PythonProgramming\Lesson3\Lesson3_Data\WellsSubset.shp"
        z_field = "TD"
        out_polyline_features = "C:\GIS\PythonProgramming\Lesson3\Lesson3_Data\ContourOut.shp"

        # Generate raster from WellsSubset shapefile using Natural Neighbor interpolation

        raster = NaturalNeighbor (in_point_features, z_field)

        # Use Contour tool with 1500 as contour interval on the raster

        Contour (raster, out_polyline_features, 1500)






        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited 2 hours ago

























        answered 2 hours ago









        Aaron♦

        37.1k17105242




        37.1k17105242




















            Alex C is a new contributor. Be nice, and check out our Code of Conduct.









             

            draft saved


            draft discarded


















            Alex C is a new contributor. Be nice, and check out our Code of Conduct.












            Alex C is a new contributor. Be nice, and check out our Code of Conduct.











            Alex C is a new contributor. Be nice, and check out our Code of Conduct.













             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f297508%2fgetting-attributeerror-from-arcpy%23new-answer', 'question_page');

            );

            Post as a guest













































































            Comments

            Popular posts from this blog

            Long meetings (6-7 hours a day): Being “babysat” by supervisor

            Is the Concept of Multiple Fantasy Races Scientifically Flawed? [closed]

            Confectionery