Questions tagged [nameerror]

Use when NameError from Python is thrown by your code

Filter by
Sorted by
Tagged with
4 votes
1 answer
63 views

Deleting specific attributes of layer using PyQGIS

I want to delete specific columns in the attribute table of my layer: except for the "LAYER" Column. This is my code: clip = processing.runAndLoadResults("native:clip", ...
  • 111
0 votes
0 answers
86 views

ArcPy CalculateGeometryAttributes parameters for area calculation - Failed to execute error

I have a large project I am working on and am stumped on one step. There is a large group of layers (over 40), for each of which I need to (1) add an area column to the attribute table and then (2) ...
0 votes
1 answer
41 views

"NameError: name 'SetNull' is not defined" error in ArcPy script? [closed]

I am trying to set a flood raster to a null value whenever it is less than 0.1 feet, but I am getting a NameError. I think I am following the SetNull documentation correctly, but can't figure out why ...
  • 121
1 vote
1 answer
44 views

Why is help(activeLayer()) not working?

Why are neither of the commands below returning details on the active layer method? It works when I use the class iface. help(activeLayer) help(activeLayer()) This is the error I get Traceback (...
0 votes
1 answer
141 views

Using Field Calculator to put file name into field

I am using ArcGIS ModelBuilder. I want to use Field Calculator to put the file name into a field. I created a field using add field. But I don't know the function to call the file name. What I've ...
3 votes
1 answer
100 views

Getting NameError on GetParameterAsText

I am trying to write a simple script that get input from a variable in ModelBuilder and use it in a Python script to "zoom" on a selected features in layout. Here is the script and the error:...
  • 37
0 votes
1 answer
157 views

How to add user input shapefile as a parameter into "GDB Creator" Python Script tool

I created a Python Script tool to create a GDB inside of a user defined folder path. I am trying to find a way to add another parameter in my script tool for a user to input a shapefile after they ...
0 votes
0 answers
122 views

Output of first iteration as the input of the next step in a for loop

I use a Python script to find the closest facilities. I have 24 cities to process. For one city, I should create 100 random datasets. To do that, I use Python, and for loops. After I create the random ...
  • 115
3 votes
0 answers
415 views

Reading files with Japanese filenames with GeoPandas

I'm trying to read all shapefiles in a folder using this script: import glob import geopandas as gpd infolder = r'E:/folder/test_input' shapefiles = glob.iglob(infolder+'/*.shp') gdfs = [gpd....
  • 424
7 votes
2 answers
2k views

NameError: name 'QMessageBox' is not defined

When I'm loading a CSV into QGIS, I get this error code, see below. Does anyone know what this means? This also is an issue when I attempt to run NNJoin Plugin too. An error has occurred while ...
3 votes
1 answer
664 views

Using sym.renderer.fields with ArcPy and ArcGIS Pro gives NameError: attribute 'fields' not supported on instance of UniqueValueRenderer

I have a script that updates the symbology of layers in ArcGIS Pro 2.5.0 with Python 3.6: if lyr.name == "Oiling Zone": sym = lyr.symbology sym.updateRenderer('UniqueValueRenderer') sym....
  • 460
2 votes
1 answer
348 views

PyQGIS script for loading several .xyz files into QGIS gives NameError

I found a script for loading several csv files into QGIS and modified it for .xyz Data. Yesterday on one Computer it worked and today on a different Computer it's not working anymore. Is there ...
  • 2,457
1 vote
1 answer
180 views

Avoiding Python NameError when rewriting script with user defined functions for ArcGIS Pro

I am rewriting a script for Python 3.6 and ArcGIS Pro compatibility and it seems like user defined functions will be necessary to clean it up. I am fairly new. I separated the code block into two ...
2 votes
1 answer
111 views

Extracting Summary Statistics value with cursor and assigning it to a variable

I am writing a script (to be used in ArcGIS 10.7.1) that uses a Zonal Statistics tool to create an average of a raster that is beneath a grid. I then use the Summary Statistics tool to take the ...
  • 483
0 votes
1 answer
47 views

Python code error - NameError [closed]

I am relatively new to writing Python code so this is probably obvious to most of you but I am receiving the following error: NameError: name 'latest_edition' is not defined > # Import system ...
0 votes
1 answer
454 views

Exporting attribute tables of rasters using ArcPy

I have this script that worked once before to export the attribute tables of some rasters as CSV files. However when I run this script again, I get an error: Runtime error Traceback (most recent call ...
  • 69
1 vote
1 answer
765 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 ...
  • 65
1 vote
1 answer
60 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 ...
  • 177
2 votes
0 answers
2k 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/' ...
  • 41
0 votes
1 answer
7k 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): ...
  • 185
2 votes
1 answer
354 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 ...
4 votes
2 answers
671 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....
  • 3,984
5 votes
2 answers
3k 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
1 answer
191 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
1 answer
323 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 ...
  • 143
1 vote
1 answer
60 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) &...
  • 246
2 votes
1 answer
142 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
1 answer
221 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....
  • 3,984
0 votes
2 answers
168 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 ...
  • 419
1 vote
0 answers
66 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,006
1 vote
1 answer
54 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 ...
  • 51
3 votes
2 answers
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\...
1 vote
2 answers
675 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 ...
  • 147
0 votes
1 answer
198 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
2 answers
182 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 = ...
10 votes
1 answer
3k 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 ...
  • 1,623
3 votes
1 answer
1k 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,217
1 vote
1 answer
191 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 ...
3 votes
2 answers
5k 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
4 answers
10k 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: ...
  • 21
3 votes
3 answers
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
1 answer
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 ...
  • 1,396
0 votes
1 answer
3k 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....
  • 51
11 votes
1 answer
8k 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 ...
  • 1,474
0 votes
1 answer
6k 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 ...
  • 75
0 votes
1 answer
723 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 ...
  • 33
3 votes
2 answers
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 ...
  • 1,211
9 votes
1 answer
4k 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. ...
  • 91
6 votes
1 answer
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 ...
  • 271
2 votes
1 answer
322 views

Using ArcObjects ITextSymbol.GetTextSize in Python to define two input variables that get populated by method

I am using Python 2.6 and ArcObjects in ArcGIS 10.0 to build and draw, among other things, graphic text on the current display. At one point I need to use the ITextSymbol.GetTextSize method. In a ...
  • 1,622