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

learn more… | top users | synonyms

0
votes
0answers
3 views

Extract rastre 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 ...
0
votes
0answers
6 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 ...
2
votes
1answer
24 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 ...
-1
votes
2answers
24 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.
0
votes
0answers
18 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
24 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
30 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
52 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 = ...
2
votes
1answer
31 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
33 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 ...
1
vote
1answer
23 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
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. ...
0
votes
2answers
47 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
27 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
0answers
22 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
22 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 ...
-4
votes
0answers
44 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
25 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
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. ...
0
votes
0answers
4 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
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 . ...
0
votes
0answers
19 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
171 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 ...
1
vote
1answer
32 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
17 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
28 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
28 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
46 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 = ...
-4
votes
0answers
38 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 ...
3
votes
1answer
55 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
84 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':''},\ ...
0
votes
1answer
26 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
1answer
18 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
32 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
30 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 ...
1
vote
1answer
43 views

How to get a layer by name in PyQGIS?

I have a plugin which finds buffer for list of cities, provided the distance. The state and city names are taken from the attribute table and gets filtered accordingly. What I want is My plugin should ...
0
votes
0answers
20 views

Suppress values from multiband rasters

I have a raster stack with 84 bands . It is a time series raster. It so appears that the cloud is causing error in my processing and hence i need to suppress or replace them by a NaN to eliminate them ...
0
votes
1answer
25 views

ImportError: libqgis_core.so.2.9.0: cannot open shared object file: No such file or directory

I installed qgis in debian linux and I want to run a standalone app in python. So I import qgis.core and qgis.gui in this app. But it gives me an error: ImportError: libqgis_core.so.2.9.0: cannot ...
0
votes
0answers
50 views

gdal ReadAsArray returning NoneType

I'm trying to read in several rasters as array using gdal in a python script, but I keep getting NoneType returned and can't figure out why. The process is this: 1. Use gdalbuildvrt ...
2
votes
2answers
52 views

How to get cell value along Flow Direction

I have: a flow direction raster where I took off (assigned NoData value) the cells that overlayed the river network (from flow accumulation). a perfectly overlapping raster where I asigned a ...
0
votes
1answer
48 views

Is it possible to embed python in code for HTML pop-ups in ArcGIS

When clicking a point feature I want the html pop-up to not only contain the data of the feature but also an image of the area around the feature (eg. 2 km^2). The image would have the base map 'World ...
1
vote
2answers
149 views

Why is my cursor empty?

Yesterday I set up a Python script using a cursor on a layer. Today I've tried running again and no matter what I run it in, the cursor is empty. I've tried removing the query on the layer, tried ...
2
votes
1answer
26 views

Python FindLabel Function for Label Expression with Formatting Font?

I originally had this FindLabel function (which works)... def FindLabel ( [NAME], [Count_] ): if [Count_] != None: return [NAME] +'\n' + "Well Log Count: " + [Count_] I wanted to format the ...
0
votes
1answer
33 views

Cannot rename output file using standalone script for QGIS

I would like to rename all output files after my script has finished processing them by adding "(A)" after their file name (eg. Layer.shp -> Layer (A).shp). I received an answer from this post on the ...
0
votes
0answers
53 views

Problem exporting ecw project- arcpy

I work with arcview 10.3. Every time i export maps with ecw raster format , python (version 2.7.8) get crashed and i see: I use this code: import arcpy,os,sys,string import arcpy.mapping from arcpy ...
1
vote
1answer
43 views

How to add label to QgsVectorLayer by Python

my goal is to define label programmaticly for the case similar for the figure below: But didn't find any guidance how to do so using Python. I have a feeling it could be done using QgsLabel but ...
1
vote
3answers
48 views

SearchCursor Index Out of Range

I'm using ArcGIS 10.2 and trying to obtain values in a field using SearchCursor. Would someone help me with this? import arcpy oc = r"C:\Users\Scratch\oc.shp" catchments = ...
2
votes
5answers
126 views

How to export attribute table with start and end coordinates of lines to Excel?

I am working in QGIS. I have a georeferenced line layer and I want to export the attribute table and the coordinates of start and end points of my lines to Excel. Can I do this with QGIS?
1
vote
1answer
45 views

How to add multiple attributes to a newly created feature with PyQGIS

I am creating a form for updating the attribute values of the newly created feature. But when i am updating the values only one attribute field is getting updated. So if i want to update the multiple ...