Python is an open source interpreted programming language used in many GIS programs.

learn more… | top users | synonyms

1
vote
2answers
614 views

Can anyone recommend an Arcpy GUI? [duplicate]

Can anyone recommend a GUI for arcpy? So if I want to run my script as an exe with some blank text boxes(or text boxes with default entries), radio buttons, check boxes etc.
1
vote
1answer
2k views

Find and replace unicode character in a shapefile

I've found several example of script and blog posts on working with unicode characters, but I haven't been able to make anything works so far... It's a little frustrating I have a shapefile encoded ...
1
vote
2answers
144 views

How to interact layers with a nested loop?

I've dealing with the code below with such a long time. I have to show in a raster image the result of calculating the cost of the electricity for a solar plant. The thing is that I have to interact a ...
1
vote
2answers
901 views

Select Layer by Location - Arcpy - Why are my inputs being interpreted as invalid?

I am working on a tool in a python toolbox and am totally confused about what is going on and causing my select by location operation to fail (Error 000368). I am trying to select the features in one ...
1
vote
1answer
574 views

Using Python if/then/else to return value from either of two fields based on value of third using ArcGIS Field Calculator?

I'm trying to avoid manually inputting Begin and End engineering station values already inputted into a seperate field. I'm dealing with(4) fields: Begin_Sta End_Sta Beg_End and Station. The ...
1
vote
2answers
635 views

Can you use arcpy.Copy_management() with in_memory tables?

I have a table in an ArcSDE GDB I'd like to step through using Python. For performance reasons I wanted to load it into memory like so: arcpy.Copy_management('C:/GDB.sde/MyTable', ...
1
vote
2answers
557 views

Python scripting for ArcPad Checkin

I can use ArcGIS Desktop model builder to leverage the ArcPad Check In Tool. When I run the model it executes successfully. When I export the model as python I get this code: import arcpy # Local ...
1
vote
3answers
283 views

Why do I get a no module error when I try to batch process in Arc10?

I was trying to batch reproject a set of shapefiles and I kept getting the error No OS Module As the set was relatively small I just did it individually, however I want to be able to batch process in ...
1
vote
1answer
575 views

How to translate ESRI cursor example to pyQgis?

For example, how to translate this code into pyqgis? rows = gp.UpdateCursor("D:/St_Johns/data.mdb/roads") row = rows.Next() while row: row.buffer_distance = row.road_type * 100 ...
1
vote
2answers
812 views

arcpy.Delete_management not deleting

I'm struggling with deleting an mxd in a for loop. My code is: import arcpy, glob, os, datetime, time from time import strftime for filename3 in glob.glob(os.path.join(folderPath, ...
1
vote
2answers
307 views

GetCount_management From ArcGIS ToolValidator

We want to check if features are empty in the ToolValidator. When you call GetCount_managment() and background processing is on, there is a popup from our validation step. Is there a different ...
1
vote
2answers
3k views

Get extent of Georeferenced Rasters in Python and output to polygon shapefile

I would like to create a shape file containing the extents of each of the rasters in a directory. Is it possible to capture the extent of a raster using Python? I have tried ...
1
vote
4answers
1k views

Install other python distributions [e.g. Python(x,y)] on top of ArcGIS installation ?

I'm using ArcGIS 10 and would like to use various additional libraries that are not included in the delivered version of ArcGIS (esp. numpy and matplotlib). First I tried to install them manually as ...
1
vote
3answers
508 views

python: Replace Variable in VB-Expression-File (.cal) [ArcGis 9.3]

I'm trying to modify a VB-Expression saved in a cal-file: dim out if [D19830701]=-9999 then out= [D19830501] else out= [D19830701] end if __esri_field_calculator_splitter__ out with this ...
1
vote
3answers
59 views

Determining Y coordinate for Create Fishnet from desired Angle of Rotation in Python/ArcPy?

On the ESRI website it says: How_Create_Fishnet_works Calculating a value for the y-axis coordinate If you know the angle of rotation, you can compute a value for the Y-Axis Coordinate parameter as ...
1
vote
2answers
28 views

QGIS 2.4 crashes when symbolizing QgsComposerShape in Python with ScriptRunner

I'm attempting to use ScriptRunner to output a jpeg of a red rectangle using QGIS Composer to understand the QgsComposerShape. Everything works except QGIS crashes when the symbol is applied. The ...
1
vote
1answer
81 views

How to work with accentuated strings in Python scripts in ArcGIS Desktop Field Calculator?

` pre-logic: def myCalc(name,nameVal): if (name == nameVal): return 1 else: return 0 var_name= myCalc(!Epulettipus!,"Lakóépület") ` This doesn't work with accentuated strings. (But ...
1
vote
2answers
50 views

building dictionary from feature class field values, how can I ensure there are no duplicate values per key

I found this code sample that builds a dictionary from two fields; the end result is a concatenation of all values per key to a new field. It's a great tool except that it doesn't account for ...
1
vote
1answer
43 views

How to ascertain if a cell/field contains a value in ArcGIS attribute table

I have done a bit of research on this but can't seem to find an answer. I am wondering if there is a way to identify whether a cell/field in the ArcGIS attribute table contains a value using the ...
1
vote
2answers
72 views

How to concatenate double with string in field calculator with Python expression?

I'd like to concatenate my lat/lng with a few string fields in ArcGIS. What is the correct expression to use, avoiding VBA. I don't want to convert the lat/lng fields to string either. my 4 fields ...
1
vote
1answer
98 views

What's the reason for this Invalid Layer “Cannot open GDAL dataset …” error

When adding a rasterfile with QGIS python console there appears an error when the first letter of a rasterfile to be added is not written in capital letters. Why this behaviour? Example case1: ...
1
vote
1answer
121 views

Why is feature.geometry() None in my user-defined expression function?

I'm trying the user-defined expression functions for QGIS, as listed on Nathans blog: http://nathanw.net/2012/11/10/user-defined-expression-functions-for-qgis/ I always get the feature.geometry() as ...
1
vote
2answers
52 views

Creating shapefile from selection - remove from map

I am iterating over a shapefile and creating a new shape from each row. I will be creating several thousand individual shapes and do not want to inundate my TOC with that many layers (I bet ArcMap ...
1
vote
1answer
92 views

User defined parameter within code block of field calculator - Modelbuilder - ArcGIS - Python

I am using Reclass within a Code Block in Field Calculator in a Model to calculate field values for a variable based on several other fields. Using reclass is much quicker than select and then using ...
1
vote
2answers
82 views

Raster' object is not iterable

I'm trying to calculate the percentage of cell counts in new raster and the new raster is created from an old raster based on the Value > 14. In my code, 1st for loop is for original raster and ...
1
vote
1answer
40 views

sum of raster counts

I'm trying to get the sum of "counts" in a raster. I have the code below which can successfully read the counts of each row in raster attribute and stores the counts in a list provided below. ...
1
vote
5answers
159 views

Calculations in if statement

I want to perform a simple calculation with the Field Calculator using this piece of script (note that all the elif statements are attempts for another syntax and non of the worked): def ...
1
vote
2answers
60 views

If-Then-Else statement in ModelBuilder has improper syntax

I have a model that converts a road network into a different schema for a different program. In one step of the model I am converting values for a field "Class". I wrote an If-Then-Else statement in ...
1
vote
2answers
56 views

Problems searching for attributes

I've come across this problem a few times and have not been able to find a satisfactory answer. I am new to python though so perhaps I have not been looking in the right places! Anyway, In ArcGIS I ...
1
vote
1answer
181 views

Script to “extract by mask” a list of raster files

I'm trying to mask a group of raster files and save the new rasters in a different folder using the same name of the original files. It doesn't sound as a difficult task, but I'm having trouble ...
1
vote
2answers
195 views

How can I group Points to make polygon via Python

I have an array of coordinates Point= [lat,long] ListPoint= [[38.203655,-76.113281],[38.10,-76.12],..] I wanna make a polygon that contains all these points ? There is a project developed by ...
1
vote
1answer
74 views

Arcpy Script tool

I'm creating a script tool and using the SelectLayerBy Attribute function (below), arcpy.SelectLayerByAttribute_management("cities_lyr", "NEW_SELECTION", '"CRIME_INDX" <= 0.02') However, I keep ...
1
vote
1answer
213 views

QGIS Map tools and Map canvas--QString errors

I'm trying to learn more about using QGIS Map Canvas widgets and creating custom map tools, so the information from the PyQGIS cookbook is very helpful. After trying to experiment with mywnd.py from ...
1
vote
2answers
230 views

Mask image based on no-data pixels in another image with different projection - GDAL or Python

I've got a land cover image which covers the whole globe, and a satellite image which covers a very small part of the globe. These two images have different projections, co-ordinate systems and pixel ...
1
vote
1answer
139 views

Equivalent function to shapely's envelope in ogr?

I wrote a very simple python function that gives me the envelope/bounding box/...based on two coordinate pairs (ower left and upper right corner): # ... def get_bounding_box(self, ll_corner, ...
1
vote
3answers
444 views

Problem with python script to control GRASS GIS from outside - How to import grass.script under Win 8.1?

I am working with GRASS 6.4.3 and python 2.7.6 under WIN 8.1. I am a novice with computer science and coding, and I have seen many posts including those:Is it possible to use GRASS GIS in Python ...
1
vote
1answer
90 views

Is it a good idea to use GRASS Algorithms for Geoprocessing in a Server Environment?

I´m designing a web-service to run in a server environment that will do some geoprocessing actions to datasets uploaded by users and send the results back. I´m programming in Python, and so far I´ve ...
1
vote
2answers
56 views

Fill Sinks of multiple rasters in a Python expression

I have 31 rasters that represent different watersheds and I would like to use the Fill (Spatial Analysis) tool to fill the sinks of all rasters at once in Python. All the rasters have the same name ...
1
vote
1answer
158 views

ListRasters not recognizing raster files in python

I have 2 rasters in my workspace, one in TIFF Format and the other in GRID format: "C:\ExampleFolder" When I use the python script: import arcpy >>> ...
1
vote
2answers
266 views

Efficient way to store multiple values of an x,y location in Python?

I am trying to read values from a stack of images and store them in a structure that will allow for easy readability. My current idea is to create a loop for x in width: for y in length: ...
1
vote
1answer
158 views

How to remove all selection from all registered layers using QGIS plugin?

I want to remove all selection from registered layer in QGIS using Python. I tried to clear the map canvas using: self.iface.mapCanvas().clear() self.iface.mapCanvas().refresh() but the ...
1
vote
2answers
783 views

How to terminate Python scripts in Processing framework properly?

I'm writing a Python script to use it in Processing framework. I need to cancel script execution if certain conditions are met (to save user's time). I tried to use sys.exit(arguments) command. The ...
1
vote
1answer
396 views

Insert Cursor fails to write results to table

Insert Cursor fails to write results to table. The Search Cursor is returning the results, but errors when trying to insert into field. # Insert Cursor for GDB table to GDB table # Import modules, ...
1
vote
1answer
47 views

Trigger a custom ArcToolbox tool outside Model Builder

I have created a model in a custom Arc Toolbox with Model Builder in ArcMap 10.1. Is it possible to trigger the model outside Model Builder and ArcMap? For example, use a Python script to trigger the ...
1
vote
2answers
87 views

What is the most efficient method to delete points?

I have a script that takes a point featureclass (FC) through the following workflow: Select points that lie within individual polygons From the selected points within each polygon, randomly subset ...
1
vote
1answer
148 views

selection by attributes with python

I have a problem concerning the selection by attribute with python on arcmap. I use this code: import arcpy from arcpy import env arcpy.env.workspace= "E:\cities" Mi=(r"E:\cities\rivers.shp") rows = ...
1
vote
3answers
272 views

How to access user credentials in database connection?

I am trying to automate a couple of things when a QGIS plugin is activated: If Layer A is not in the TOC, add it. This requests username and password to access a PostGIS table using the inbuilt ...
1
vote
1answer
232 views

How to automate creation of PNG maps using Python?

I have a project with 50 vector layers and I have done custom styling for them. Now I want to make around 30 png files with different xmin, ymin, xmax, ymax. The output size (png) should be width ...
1
vote
2answers
207 views

Hyperlink broken path - python check

I've recently come across an issue where some of our hyperlinks aren't working. I'm familiar with python and have made similar scripts before, but I would first like to ask for your assistance to ...
1
vote
2answers
268 views

Reducing number of decimal places after X/Y coordinates in a FC

I'm using arcpy.AddXY_management to add coordinates, and I want to reduce each X/Y field by x number. I've tried to reduce it by string slicing and that obviously didn't work. I also tried setting the ...