Getting AttributeError from ArcPy?
Clash 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?
arcpy spatial-analyst attributeerror
New contributor
add a comment |Â
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?
arcpy spatial-analyst attributeerror
New contributor
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
add a comment |Â
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?
arcpy spatial-analyst attributeerror
New contributor
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
arcpy spatial-analyst attributeerror
New contributor
New contributor
edited 3 hours ago
Vince
14.1k32444
14.1k32444
New contributor
asked 3 hours ago
Alex C
61
61
New contributor
New contributor
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
add a comment |Â
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
add a comment |Â
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)
add a comment |Â
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)
add a comment |Â
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)
add a comment |Â
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)
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)
edited 2 hours ago
answered 2 hours ago
Aaronâ¦
37.1k17105242
37.1k17105242
add a comment |Â
add a comment |Â
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.
Alex C is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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