Questions tagged [nameerror]

Use when NameError from Python is thrown by your code

Filter by
Sorted by
Tagged with
1
vote
1answer
35 views

NameError: name '**' not defined in ModelBuilder Calculate Value

This question follows up on Crianopa's answer https://gis.stackexchange.com/a/107687/126329 - I am attempting to do just this, but my model fails at the Calculate value stage. Using the expression ...
1
vote
1answer
29 views

SAGA Raster Calculator processing script give error “name 'Rasterout' is not defined”

I am trying to build a custom script using things I have learned from this post: Number inputs as raster calculator variables in QGIS Modeler This is my script so far: ##Maechtigkeit unterhalb einer ...
1
vote
0answers
1k views

NameError: name data_all1 is not defined in Python 3.x

I have a standalone script using data opened from a Geopackage with Fiona. When I run this portion of my script: import os import fiona import numpy as np datapath= '/media/sf_SharesShapefiles/' ...
0
votes
1answer
5k views

NameError: name '**' is not defined

After importing PyQt4.QtCore,PyQt4.QtGui and processing and after having correctly defined layers, I executed this script in PyQGIS but it returns this error: Traceback (most recent call last): ...
2
votes
1answer
235 views

Debugging NameError: name 'QgsLinearlyInterpolateDiagramRenderer' is not defined from PyQGIS?

I have gone through an online tutorial on how to do a pie chart map using PYQGIS. The following is my code, identical to what was provided. # -*- coding: utf-8 -*- from PyQt4.QtGui import* from ...
3
votes
1answer
249 views

Layers visibility- code error in Arcpy

I try to turn of all the layers, using this code using ArcGIS 10.3.1: import arcpy from arcpy import env env.workspace = r"G:\desktop\gis" for mxd in arcpy.ListFiles("*.mxd"): mapdoc = arcpy....
4
votes
1answer
432 views

Importing modules in PyQGIS

I am trying to build a a library of scripts to call inside the QGis Python console/Python editior. I do not understand why they work independently, but not when being called from another script. ...
0
votes
1answer
57 views

NameError from using definition query in ArcPy?

I am having trouble getting my definition query to be defined. What am I missing? The current error is: Runtime error Traceback (most recent call last): File "<string>", line 44, in <...
2
votes
1answer
152 views

Setting globals in PyQGIS?

I'm working on this script in PyQGIS to take points from a layer called LEK_ALL and snap them to the closest feature of a line layer called LEID_filtered which fulfills a certain request. In order to ...
1
vote
1answer
43 views

Correct SQL expression for SelectbyAttribute Tool [duplicate]

I'm trying to apply the sql expression described here https://geonet.esri.com/thread/76028, that involves querying out odd values in a field. The specific sql expression is Round(NumberField / 2, 0) &...
2
votes
1answer
80 views

Cannot Import arcpy.mapping on ArcGIS

I can import arcpy and have been using ArcGIS Desktop, but in the tutorial I am following mxd = mapping.MapDocument("CURRENT") NameError: name 'mapping' is not defined This is frustrating because I ...
2
votes
1answer
112 views

Removing annotation layer according to data source using ArcPy gives NameError?

I work with this FGB annotation (ArcView 10.3): and i try to remove it with this code: import arcpy,os from arcpy import env env.workspace = r"G:\PROJECTS\road611\gis\aa" for mxdname in arcpy....
0
votes
2answers
92 views

Arcpy cannot locate rasters inside geodatabase

I've bunch of rasters inside a geodatabase and I'm trying to call them as inputs in a script, but I'm running into a strange problem. The script cannot find/locate these rasters, so I manually added ...
1
vote
0answers
41 views

NameError when attempting to auto increment field with python script [closed]

I am getting the following error when trying to run my code and I am not sure why: NameError: global name 'rec' is not defined Here is my code: field = "id_num" rec=0 def autoIncrement(): ...
1
vote
1answer
45 views

Getting NameError when using Cursors to read vertex coordinates in ArcPy? [closed]

I am new to python and having trouble Looping each feature in the new polygon shapefile, then use geometry cursors to read vertex coordinates of this lake polygon, identify the city that is the ...
3
votes
2answers
2k views

Global name "fc' not defined?

First, I'm trying to call a function from a module (final_functions) I created in a separate script. However I receive the following error: Traceback (most recent call last): File "C:\Python27\...
0
votes
2answers
330 views

ArcGIS tells me 'raster' isn't defined

I am trying to get zonal statistics for a set of geographical units for several years and I would like to get the output in one dbf table, where the rows mark the geographical units and each column is ...
0
votes
1answer
155 views

Getting NameError with PythEveryone in ArcGIS virtual campus module?

I'm working on the python for everyone lab in Esri's Virtual campus. I'm running into an issue that I can't seem to solve, I've already done some outside research hence posting here! The issue: 4th ...
0
votes
2answers
122 views

CellStatistics is not defined error

Code : >>> import arcpy >>> ras1 = arcpy.Raster(r'D:\IMD\test_converted1961.img') >>> ras2 = arcpy.Raster(r'D:\IMD\test_converted1961_fliped_ud1.img') >>> result = ...
9
votes
1answer
2k views

Adding PostGIS layer from QGIS Python plugin

I try to develop a plugin to add postgis layers to qgis from a plugin as part of learning python. The code for adding a postgis layer is taken from the cookbook and work fine if I run it from the ...
3
votes
1answer
585 views

Scripting with “self” in PyQGIS?

What is "self" and how can I use it error-free in a Q script? Example: mc = self.iface.mapCanvas() But when I try to run this in the Console I get the following error: NameError: name 'self' is ...
1
vote
1answer
159 views

NumPy Array to Feature Class: NameError from Inner Loop Variables

I have a NumPy Array to FC script that parses a JSON web-service. The outer loop writes to my FC correctly, however my inner loop variables come back as not defined when appending the items. The ...
2
votes
2answers
3k views

Error msg “Name is not defined” when trying to populate a field with the shape file name

I am trying to populate a field with corresponding file name. For example, if the file name is Route1.shp then the field value will be Route1 as well. However my code is not working. Can you please ...
1
vote
4answers
9k views

NameError: variable not defined even though set multiple times

This code original worked when run through the python command window in ArcCatalog. After I added the script to a toolbox I have had all sorts of troubles. The most frustrating error has been: ...
3
votes
3answers
2k views

Calculate field using variables as fields gives ERROR 000539?

When I calculate a field like this: field_0="field_name0" arcpy.CalculateField_management("Layer", field_0, '!field_name1! / !field_name2!', "PYTHON_9.3") It works! The field "field_name0" in the ...
1
vote
1answer
1k views

trouble with code block execution in python script

I am trying to calculate values for a field in a python script, but keep getting an error that I don't understand: ExecuteError: ERROR 000539: Error running expression: Fron000000F1 Traceback (most ...
0
votes
1answer
2k views

NameError: name 'QImage' is not defined [closed]

Traceback (most recent call last): File "<input>", line 1, in <module> File "F:/QGIS/bin/test.py", line 6, in <module> img = QImage(QSize(800,600), QImage....
8
votes
1answer
6k views

How to copy values from field to another using arcpy?

Can some one please let me know how I can do simple field calculation like Copying From "A" to "B" in ArcPy? I have found lots os example on web which they all used extra expression and they were ...
0
votes
1answer
3k views

NameError: name 'Con' is not defined

I have 365 rasters with the same extent, and I am trying to sum them together by month. I have the script below, which was working until I added the line out1 = Con(IsNull(raster), 0, raster) which is ...
0
votes
1answer
466 views

NameError: name 'finalPdf' is not defined

Could you please help me with this error: Traceback (most recent call last): File "C:\DDPeX\Export_GroupPDF.py", line 19, in finalPdf.appendPages(tempPdf) NameError: name 'finalPdf' is not ...
2
votes
2answers
1k views

How to control state of buttons in Python Add-In?

I have bunch of buttons to perform separate tasks within a Python Add-In. Buttons are greyed out and required to be enabled after initial tools run. In the following example, tool1 is turned off after ...
8
votes
1answer
3k views

Calling GRASS modules in pyQGIS?

I wish to use a Grass module (v.to.db) in QGis, without the grass toolbox. I tried with the Python console, but to no avail : Using Sextante plugin but obviously it didn't know all the grass modules....
6
votes
1answer
5k views

Performing Ordinary Kriging in SAGA via QGIS SEXTANTE Plug-in?

I'm trying to learn how to apply the kriging analysis in QGIS using the SEXTANTE plug-in and SAGA tools. It appears that I have my SEXTANTE and SAGA folders configured properly according to the user ...