Getting AttributeError from ArcPy?

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











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
    Oct 1 at 2:27











  • Thank you for responding. I did need to include that
    – Alex C
    Oct 1 at 2:38














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
    Oct 1 at 2:27











  • Thank you for responding. I did need to include that
    – Alex C
    Oct 1 at 2:38












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 Oct 1 at 2:49









Vince

14.1k32445




14.1k32445






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 Oct 1 at 2:08









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
    Oct 1 at 2:27











  • Thank you for responding. I did need to include that
    – Alex C
    Oct 1 at 2:38












  • 2




    Did you check out the spatial analyst extension? arcpy.CheckOutExtension("Spatial") Import Spatial Analyst
    – Pdavis327
    Oct 1 at 2:27











  • Thank you for responding. I did need to include that
    – Alex C
    Oct 1 at 2:38







2




2




Did you check out the spatial analyst extension? arcpy.CheckOutExtension("Spatial") Import Spatial Analyst
– Pdavis327
Oct 1 at 2:27





Did you check out the spatial analyst extension? arcpy.CheckOutExtension("Spatial") Import Spatial Analyst
– Pdavis327
Oct 1 at 2:27













Thank you for responding. I did need to include that
– Alex C
Oct 1 at 2:38




Thank you for responding. I did need to include that
– Alex C
Oct 1 at 2:38










1 Answer
1






active

oldest

votes

















up vote
3
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
    3
    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
      3
      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
        3
        down vote










        up vote
        3
        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 Oct 1 at 3:40

























        answered Oct 1 at 3:25









        Aaron♦

        37.1k17105243




        37.1k17105243




















            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













































































            Popular posts from this blog

            How to check contact read email or not when send email to Individual?

            Displaying single band from multi-band raster using QGIS

            How many registers does an x86_64 CPU actually have?