Questions tagged [nameerror]
Use when NameError from Python is thrown by your code
56
questions
2
votes
1
answer
47
views
"NameError: name 'JoinStyleRound' is not defined" error when offsetting feature of line type geometry with PyQGIS
I'm trying to offset a feature with line-type geometry, I found a suggestion to work based on the QgsGeometry.offsetCurve() method, see https://qgis.org/pyqgis/3.34/core/QgsGeometry.html#qgis.core....
0
votes
0
answers
53
views
Error when running LecoS Plugin in QGIS (Query raster values- Point): NameError: name 'QMessageBox' is not defined
This error message comes up when I try to run the LecoS Plugin in QGIS for querying landcover raster values at coordinate points of Bluetit birds on my map:
QGIS version: 3.32.3-Lima
QGIS code ...
1
vote
1
answer
46
views
Issue accessing qgis.core module from separate Python file
I have a few python scripts I would like to call from the QGIS Python console. It was working well until I attempted to separate some of the functions to another file -- the qgis.core modules are not ...
0
votes
1
answer
225
views
Python script run error QGIS
I have been using the Python console in QGIS to develop a script. However, I keep getting the below error whenever I try to execute it.
This is line 43 which has the error
2
votes
1
answer
308
views
NameError: name '__file__' is not defined when getting the path of the current script using PyQGIS
I am trying to run a script in the QGIS Processing Script Editor, but I get the following error:
If I run the script from the PyQGIS console it works with these changes in the console_editor.py (...
4
votes
1
answer
261
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",
...
0
votes
1
answer
670
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
106
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 ...
1
vote
1
answer
55
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 (...
1
vote
1
answer
517
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
153
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:...
0
votes
1
answer
219
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
165
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 ...
3
votes
0
answers
674
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....
7
votes
2
answers
3k
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 ...
4
votes
1
answer
1k
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....
2
votes
1
answer
394
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 ...
1
vote
1
answer
196
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
131
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 ...
0
votes
1
answer
51
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
543
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 ...
1
vote
1
answer
939
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
1
answer
70
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 ...
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/'
...
0
votes
1
answer
8k
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
1
answer
361
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
764
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....
5
votes
2
answers
4k
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
230
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
335
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
1
answer
62
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
1
answer
222
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
300
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
2
answers
217
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
0
answers
77
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
1
answer
55
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
2
answers
3k
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
765
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
1
answer
205
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
193
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 ...
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
vote
1
answer
193
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
6k
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:
...
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 ...
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....
-2
votes
1
answer
1k
views
Shapely Python NameError when using cascaded_union
I am fairly new to Python and therefore my error-solving skills are not much yet developed.
I am using Python within a geoprocessing script which is supposed to use ogr (reading/writing shp) and ...
11
votes
1
answer
9k
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 ...