Questions tagged [nameerror]

Use when NameError from Python is thrown by your code

Filter by
Sorted by
Tagged with
1 vote
1 answer
31 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 (...
user avatar
0 votes
1 answer
39 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 ...
user avatar
3 votes
1 answer
55 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:...
user avatar
  • 37
0 votes
1 answer
94 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 ...
user avatar
0 votes
0 answers
60 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 ...
user avatar
  • 115
3 votes
0 answers
285 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....
user avatar
  • 412
7 votes
2 answers
1k 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 ...
user avatar
3 votes
1 answer
448 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....
user avatar
  • 450
1 vote
1 answer
279 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 ...
user avatar
  • 2,337
1 vote
1 answer
159 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 ...
user avatar
2 votes
1 answer
93 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 ...
user avatar
  • 463
0 votes
1 answer
43 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 ...
user avatar
0 votes
1 answer
327 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 ...
user avatar
  • 37
1 vote
1 answer
640 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 ...
user avatar
  • 65
1 vote
1 answer
55 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 ...
user avatar
  • 157
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/' ...
user avatar
  • 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): ...
user avatar
  • 185
2 votes
1 answer
350 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 ...
user avatar
4 votes
2 answers
583 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....
user avatar
  • 3,984
4 votes
2 answers
2k 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. ...
user avatar
0 votes
1 answer
167 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 <...
user avatar
2 votes
1 answer
300 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 ...
user avatar
  • 43
1 vote
1 answer
56 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) &...
user avatar
  • 246
2 votes
1 answer
112 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 ...
user avatar
2 votes
1 answer
191 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....
user avatar
  • 3,984
0 votes
2 answers
161 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 ...
user avatar
  • 419
1 vote
0 answers
58 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(): ...
user avatar
  • 1,006
1 vote
1 answer
53 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 ...
user avatar
  • 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\...
user avatar
1 vote
2 answers
623 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 ...
user avatar
0 votes
1 answer
189 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 ...
user avatar
0 votes
2 answers
169 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 = ...
user avatar
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 ...
user avatar
  • 1,603
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 ...
user avatar
  • 1,187
1 vote
1 answer
184 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 ...
user avatar
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 ...
user avatar
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: ...
user avatar
  • 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 ...
user avatar
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 ...
user avatar
  • 1,386
0 votes
1 answer
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....
user avatar
  • 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 ...
user avatar
  • 1,454
0 votes
1 answer
5k 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 ...
user avatar
  • 75
0 votes
1 answer
646 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 ...
user avatar
  • 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 ...
user avatar
  • 1,211
9 votes
1 answer
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. ...
user avatar
  • 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 ...
user avatar
  • 261
2 votes
1 answer
321 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 ...
user avatar
  • 1,622