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

learn more… | top users | synonyms

0
votes
1answer
37 views

window map (in pixels) given a window size (in miles) for a particular map resolution

i'm a noob when it comes to gis so just had a quick question. i searched for this question...and it seemed like the questions were arcgis specific. i'm using python and basemap for my analysis. ...
4
votes
0answers
48 views

Python IDE complete code autocompletion [closed]

I am seeing that code completion in both PyScripter and PyCharm is not complete, compared to the code completion you get in the interpreter window. In PyScripter, if you add arcpy to the code ...
1
vote
1answer
34 views

Trouble buffering a vector layer in QGIS with PyQGIS

I am working on a script that imports a .csv layer that has lat long coordinates, which I then want to buffer in feet. I've created a vector layer from the .csv file and tried to set the coordinate ...
1
vote
1answer
40 views

Get a point value with psycopg2 and PPyGIS

I'm trying to setup a basic working postgis setup with python ppygis package. >>> import psycopg2 >>> import ppygis >>> connection = psycopg2.connect(database='spre', ...
1
vote
1answer
81 views

How to store attribute values from a custom form into shape file?

I have created a custom form (for mapping bird species in the field with different attributes like species, type of observation, number of birds, date, ...) with some python logic. One important ...
2
votes
1answer
78 views

Using ArcPy to Read from Excel Spreadsheet to Python Dictionary

How would I go about creating a script that reads a specified excel spreadsheet and places the values in a dictionary? I have read about the xlrd library and how the library in such endeavors to read ...
1
vote
1answer
53 views

Python Code for generating random points not working!

I am trying to create some code to generate 10 random points within a vector layer's districts: layer=iface.activeLayer() import ogr import sys import random from shapely import wkb, geometry ...
1
vote
1answer
26 views

Getting error in running ExportReport Python code in ArcMap

i am unable to generate pdf report using ExportReport function of Arcgis 10.2. getting error of IOError: Could not open report template tried different template files but still getting this error. ...
1
vote
1answer
65 views

arcpy.da.UpdateCursor - How to update last column from Field Name List?

examples: for field in arcpy.ListFields(fc): if field.name != 'Hi': arcpy.AddField_management(fc, 'Hi', 'FLOAT') else: print "kolona Hi vec postoji" with ...
1
vote
1answer
60 views

arcpy.da.UpdateCursor - how to make multiplication of each column with the selected column, for each row in particular?

If I have a table with a number of columns [col1, col2, col3 ... col_n] how to perform multiplication of each column with one selected column, for example: multiplication = col1 * col_def, ...
1
vote
0answers
39 views

Trouble importing qgis.core python module

I am having issues loading the qgis Python modules in the osgeo4w shell. Ultimately I want to work with the modules in pyscripter. I tried the solution mentioned in Problem with import qgis.core when ...
3
votes
1answer
70 views

Intersecting lines get crossings

I have a set of lines representing bus lines. Some of the lines are overlapping and take the same roads. I am able to extract the nodes. However I am interested in extracting only crossings like ...
-1
votes
3answers
77 views

Sum fields from ListFields - RuntimeError: A column was specified that does not exist?

Does anyone have a suggestion on how to otherwise solve the problem ... The need to automatically generate all the columns from the table, the calculation of the sum, the results are updated in the ...
0
votes
1answer
38 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 ...
3
votes
2answers
71 views

How to access checked layers in PyQGIS?

qgis.utils.iface.activeLayer() accesses the current active layer, but I would like to get all checked layers in the QGIS ToC. How can I do it?
0
votes
0answers
25 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
27 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 ...
0
votes
3answers
49 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 ...
1
vote
1answer
37 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 ...
3
votes
2answers
61 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
1answer
43 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 ...
0
votes
1answer
45 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 ...
0
votes
2answers
60 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 ...
-1
votes
1answer
70 views

Understanding Python / ArcPy code? [closed]

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 = ...
2
votes
1answer
63 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 ...
1
vote
2answers
50 views

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

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 ...
2
votes
1answer
35 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
29 views

Open MXD from network path [closed]

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. ...
1
vote
2answers
57 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
0answers
38 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 = ...
0
votes
1answer
29 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 ...
1
vote
1answer
25 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
40 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 ...
0
votes
1answer
30 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
34 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. ...
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
50 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 . ...
0
votes
0answers
31 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: ...
5
votes
2answers
222 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 ...
2
votes
1answer
47 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 ...
2
votes
1answer
44 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 ...
1
vote
1answer
31 views

How to select from selection with PyQGIS?

The expression box has a handy "select from selection" button. Is there a way to emulate this with python? I have the basic expressions down, but can't find a way to do this.
2
votes
3answers
32 views

QGIS python plugin appends values every time it's started

I've written a small python plugin (using plugin builder as base) to simplify the expression process for a given layer (just a few comboboxes that are used to create a query). The combo box populating ...
2
votes
1answer
66 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 = ...
3
votes
1answer
61 views

More efficient way to get the start and the end points of a line (arcpy)?

I am collecting start and end points for a large polyline feature class in a file geodatabase. I am using arcpy, ArcGIS 10.3, Python 2.7.3 64-bit and a 10.3 compressed file geodatabase with just one ...
1
vote
2answers
120 views

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':''},\ ...
0
votes
1answer
31 views

Collect last word from varied length string for filtering, auto labeling and column population? [closed]

I have been looking and reading for a few days about how to collect the last word from a varied length string. I have found lots of postings about how to collect/split the last word, but none of the ...
0
votes
2answers
28 views

Shapely (geos) crashes during unary_union

When attempting to union multiple polygons with Shapely 1.5.6 in Python 2.7.9, using GEOS 3.4.2, I get the following error in the underlying C++ code: Assertion failed: (!"should never be reached"), ...
1
vote
2answers
49 views

Inline variable substitution in Model Builder using python code

I have an inline variable substiution which I would like to import into my Python script. Is that possible? I am trying to make a parameter within my path. My path currently is ...
1
vote
0answers
33 views

If Else Statement Existence of a File With User Input [closed]

I am trying to design a block of code that checks if a user inputted directory exists, prints if it does, and if it does not. import os foldername = raw_input ("Please enter the name of your ...