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

learn more… | top users | synonyms

-2
votes
2answers
32 views

How to arcpy using automatically generated column names, calculation of the sum of all the columns by rows, update the results in a new column?

Does someone can help? import arcpy, os, string fc = "D:\\path\\exampless.shp" fields = arcpy.ListFields(fc) fieldNameList = [] for field in fields: if field.type in ("Double", ...
2
votes
1answer
47 views

Is it possible to find the feature class name from a python label expression in ArcGIS?

Does anyone know how to find the path to a feature class within a label expression using ArcGIS? I don’t need to simply display the path. My overall goal is to create a python function to display ...
0
votes
3answers
25 views

Extract raster values gdal looping rasters

I have this code, most of them getting from this forum. I need to loop over a folder and sub-folders, or just to run a list (putting previously all the raster inside, I don't mind one way or the ...
3
votes
2answers
727 views

How to debug 'Layer is not valid error' from Python plugin?

I'm trying to understand what goes wrong with a QGIS python plugin. Basically I'm trying to render a series of POINT. The query works fine, at least giving it by hand from inside PostGIS DB: "SELECT ...
1
vote
1answer
24 views

Memory issues with zonal statistics

I have got a memory issue due to the use of the zonal statistics command into a loop. It seems that after using the ZS command QGIS stores some information in the RAM (cache memory?). It is not ...
13
votes
4answers
8k views

How to manually break statement execution in Python window of ArcMap?

How does one break the execution of a long-running process in the python console of ArcMap? For example, how do you break a long iteration like the one below once it is started? for i in range(1, ...
1
vote
1answer
13 views

How to access multiple active layers?

qgis.utils.iface.activeLayer() accesses the current active layer, but what is there are multiple layers that are currently selected? How can I access both of these layers?
0
votes
0answers
35 views

Using if loop to concatenate rows Python [on hold]

I have a python script which brings in a JSON web-service I would like to concatenate rows. I have tried using the script before, but my table ends up truncated, with my SRList containing only 1 item ...
0
votes
2answers
39 views

python conditional statement to allow either two inputs or only one input going into a merge

I have a model builder process that I am converting to python for additional editing. In the process I have both a point and line features(input variables) being buffered and then the resulting ...
0
votes
1answer
27 views

Select the first 5 rows of a selection after reverse sorting using an attribute field in ArcGIS 10.2 with Python

I have a feature class containing 380 polygons representing sedimentary basins and another polygon feature class representing oil discoveries within said basins. My plan is to: Iterate through all ...
0
votes
0answers
11 views

How to create custom input widget using Plugin builder?

I am trying to develop a plugin that takes in user input for the time, using the QGIS plugin builder. However, I want to specify the different times the user is allowed to select from when the plugin ...
1
vote
0answers
10 views

python-mapscript on OSX Yosemite

I am keen to try out the mapserver export plugin from QGIS 2.6 This needs python-mapscript which comes from the mapserver package. This can be downloaded from ...
2
votes
1answer
31 views

How to find the distance of a point from the begning of a StringLine with shapely?

I have a route (represented by StringLine) and a location (Point) and I need to find the progress of the location in the route. The progress is the distance in meters from the begning of the route. ...
0
votes
1answer
25 views

GRASS Gis v 6.4.4. KeyError: 'version' when start

When I try to start the GRASS it gives me the following error GRASS 6.4.4 (Hellas):~ > ERROR: MAPSET Hellas - permission denied Traceback (most recent call last): File ...
0
votes
1answer
116 views

Code in python for arcgis to select multilines (path) and vertexes

I am learning to write Python code for ArcGIS 10.2. I have some shp poly lines file, need to learn how to write multiple selection of those lines, even if a cursor of mouse pressed not exactly on ...
18
votes
9answers
3k views

Is there a way to code-complete arcpy scripts using an external editor?

I have been scripting in Python for ArcGIS 10, and so far I have just been using Notepad++. I like how the Python command line interface code-completes arcpy functionality for you, showing you your ...
-4
votes
0answers
40 views

error while trying to build QGIS-2.6.1: qgis, qgis_app, qgis_gui fails for the reason qwt class couldn't found and QtUiTools.lib linking ignored [closed]

While trying to build qgis-2.6.1 from source on windows 7 32 bit with mvc++ 2008 I got the overall result ========== Rebuild All: 281 succeeded, 3 failed, 0 skipped ========== from this I am able to ...
2
votes
2answers
927 views

OSR Python testSR.ImportFromEPSG(4326) returns empty spatial reference

This is empty using Python .ImportFromEPSG(4326): import osr #this fails: testSR = osr.SpatialReference() testSR.ImportFromEPSG(4326) print testSR.ExportToPrettyWkt() #why did the import from EPSG ...
2
votes
1answer
28 views

How to trigger a Python script from an ArcGIS Desktop “save” operation?

Similar to the question Run a Python Script when opening an MXD, I'm looking for a way to run a Python script that is triggered when the "Save" command/button is pressed. I've read the Creating a ...
0
votes
0answers
24 views

How do you project a single pointGeometry object with arcpy?

In an attempt to create a python add-in for ArcMap that will pass x and y coordinates to another application via a mouse click on the map, I have written the following code. I need the output ...
-1
votes
2answers
26 views

How can I find a town which remotes from a hospital more than a hour? [on hold]

I want to show the town or village which is very far from a hospital so needs telemedicine. Please let me know how to find the town or village or if you know where the place is please let me know.
-1
votes
1answer
56 views

Understanding Python / ArcPy code? [on hold]

I am looking for a walk through of the Python code below to explain how it works in ArcGIS. #import modules import arcpy, os #set env arcpy.env.overwriteOutput = 1 ws = ...
0
votes
1answer
27 views

Python Toolbox Parameter List Update/Refresh?

I am using a python toolbox in ArcGIS 10.2.2 and want a drop down list of all the versions for the person reconciling to choose from. (And I do not want to include dbo.DEFAULT and DS.Draft). But this ...
3
votes
1answer
119 views
+200

How to compute Straight Skeletons using Python?

I'm looking for a Python package which provides an implementation of a Straight Skeleton algorithm. I'm aware that the open source (C++) project CGALcontains an implementation but it seems like ...
1
vote
2answers
49 views

How to create folders from shapefile attributes using ArcPy/Python?

I am wondering if anyone has solved this or can help me on my code. I have a Parcel shapefile, and I would like to create folders based on the attribute data (per row) from a field in the shapefile; ...
0
votes
2answers
38 views

Use Python in Field Calculator to increment up value

Please see screenshot for field calculator Python logic. I have no idea what I'm doing that's any different from this GISSE answer. The error I receive is ERROR 000989: Python Syntax Error (invalid ...
0
votes
1answer
585 views

ArcPy SelectLayerByAttribute Error and how to control GP output layer name

I have a rather long script that first references an SDE feature class (non-versioned) to perform an attribute selection based on a SQL selection. I've been unable to figure out why the script will ...
1
vote
2answers
94 views
+50

How to set NULL value by arcpy.da.InsertCursor on date column?

How to set NULL value by arcpy.da.InsertCursor on date column? I try insert "NULL", None, '', 0 dictIN= [{'field1':"test1",'date1':'01-02-2015','date2':''},\ ...
1
vote
2answers
38 views

How to programmatically close a QMessagebox without clicking ok or X? [on hold]

So part of my script in PyQGIS is this: QMessageBox.warning(None,"Warning","bla bla bla") The box apperas just fine but i want it to close after a few seconds so i am looking for something like ...
0
votes
1answer
27 views

Open MXD from network path [on hold]

MXD located in below path. I could able to open MXD from Windows explorer from dev box. I am running the script in development box and accessing mxd from the server isFile always fails. ...
2
votes
4answers
3k views

How to enumerate ArcGIS Server 10 map services with ArcPy

I need to connect to ArcGIS server with ArcPy and enumerate over map services. I need to: Loop through each ArcGIS server map service Stop/Start the service Get the service source document (MXD/MSD) ...
1
vote
0answers
82 views

How to create a schematic view of a line feature?

DEAR PEOPLE FROM THE FUTURE: Here's what we've figured out so far… I have a line feature (polyline with curves) in ArcGIS Desktop, and I want to create a linear representation (straigth line) of the ...
0
votes
1answer
117 views

Weighted Overlay - passing parameter as text error?

For some reason when hardcoding the save path for the wieghted raster just before runtime it works perfectly. Like such... arcpy.env.cellSize = "90" arcpy.env.workspace = r'G:\Xcel\Route ...
5
votes
1answer
507 views

looping the mask in python for arcgis 10

I am working with raster data on a worldwide level with a resolution of 30 arc seconds. I need to export the data into a table format but given the high resolution you can not run the "Sample" ...
0
votes
0answers
28 views

How to reload a raster file from the python shell

I do this in the QGIS python shell: # get the raster file (and data) of the active layer canvas = qgis.utils.iface.mapCanvas() rLayer = canvas.currentLayer() rLayerPath = ...
2
votes
3answers
219 views

Executing Python code takes a lot of time (more than 2 hours)? (Arcgis10.1)

I am executing this Python code, in which I am trying to determinate the position of neighbor parcel (north, south, east, west). It works fine but it took 2 hours for just 50 parcels! I think that ...
1
vote
1answer
23 views

QGIS get the X and Y of a raster file by click

I have a raster file (Geotiff) and try to write a plugin that can change the value of one cell in a raster (== array cell). I know how to get a QGIS point but how can I get the array index from on ...
0
votes
1answer
258 views

Polygon Neighbors Analysis script (ArcPy 10.1) producing erroneous results?

I'm struggling with a python script that is supposed to calculate a field for a polygon feature class. The calculation is of the average of a field value (P_TOT_DEV) for each of a given polygon's ...
-4
votes
0answers
45 views

Write a Python script in a single file that implements Haversine's formula [on hold]

A function named haversine which takes all five inputs needed to compute the function and returns the distance between the points on the spherical earth-like surface. It does this by computing the 2r ...
0
votes
1answer
26 views

UnboundLocalError: local variable referenced before assignment wthin model builder iterator in ArcGIS

Within an iterator in Model Builder in ArcGIS I am trying to calculate a field value based on the inline variable substitution. In the picture I have renamed the tools with the corresponding inline ...
1
vote
1answer
29 views

Updating Multiple Fields in Feature Class from a Table

I have a Point Feature Class with 2 million records with 35 fields. I have another csv file (contain 25 fields) which have around 4000 records to update certain records of the Point Feature Class . ...
2
votes
1answer
47 views

Why processing.runalg(“gdalogr:rasterize”…) is not creating out files when running in the QGIS 2.6.0 console?

I want to use the QGIS python scripting functions to turn to rasterize a point vector using many different dimensions. Right now my code looks like this: import processing RasterPixelSize = ...
0
votes
1answer
26 views

How to get layers created in a custom toolbox python script to add to the mxd

I'm trying to create a simple search tool so that my colleagues can easily query a database. My first version is like this. mxd = arcpy.mapping.MapDocument("CURRENT") df = ...
2
votes
1answer
32 views

Arcpy if statement to act on layers at the top level of hierarchy

I am about to save copies of all of the layers in my mxd. I only want to save the top level group layers though. I have some group layers within group layers - I dont want to save them individually. ...
2
votes
1answer
19 views

Odd behavior in a QGIS plugin: my function is triggered twice

I have a plugin with a function (triggered by a button) that selects a specific layer by name, then shows its attribute table. When I close the plugin and open it again, the attribute table pops up ...
0
votes
0answers
23 views

standard way to write a netcdf4

What is the standard way to write a netcdf4? I'm using this guide http://netcdf4-python.googlecode.com/svn/trunk/docs/netCDF4-module.html but when I dump the output file with ncdump, I get the error: ...
0
votes
0answers
5 views

how to write a netcdf4 in the right manner [duplicate]

What is the standard way to write a netcdf4? I'm using this guide http://netcdf4-python.googlecode.com/svn/trunk/docs/netCDF4-module.html but when I dump the output file with ncdump, I get the error: ...
1
vote
1answer
35 views

QGIS Modeler flexibility and errors?

I'm trying to build a simple multi-step selection (by attribute) with the QGIS Modeler. I created a simple sample layer to avoid data-driven errors. Now I want to query the layer and select features ...
1
vote
1answer
186 views

How to export a set of layers into multiple PDF(orAI)files, one layer at a time?

I am completely NEW to PYTHON(only took a 3-hr entry course in ESRI tutorial. I have a dataset contains files named as "1_A, 1_B, 1_C....12_A,12_B, 12_c,....200_A, 200_B, 200_C..etc." I need to export ...
5
votes
2answers
180 views

How to run a python script on the server, returning the results to the client

Here's the end result I'm trying for: the user clicks on a feature on an ArcGIS Server JS map a Python script is triggered on the server the Python script uses an attribute from the feature (eg its ...