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

learn more… | top users | synonyms

4
votes
2answers
2k views

Programmatically alter AliasName for fields defined in layer file (not underlying source)

Is there a way to alter the AliasName on a layer file only, and not the underlying shapefile or feature class? I have a few hundred layers that define joins between hundreds of tables with census data ...
3
votes
2answers
2k views

How to save currently opened mxd and changes using ArcPy and Python?

Here is what I have so far... import arcpy import arcpy.mapping as map mxd = map.MapDocument() mxd.save() And yes I know that map.MapDocument requires an argument, but I want it to automatically ...
5
votes
3answers
143 views

Grouping latitude and longitude coordinates by city neighborhood

I'm working on a model to predict whether craigslist apartment listings are over or under market value. I'm a complete novice with GIS. I have the lat and long as well as what neighborhood the author ...
0
votes
1answer
32 views

Finding Pseudo Nodes using ArcGIS for Desktop?

Trying to write a python scrip to find and dissolve pseudo nodes for a large dataset. Anyone have any code to perform such a task? For example, I have a road line with several end/start nodes ...
2
votes
1answer
80 views

How to check if an ArcGIS extension has already been checked out manually in arcpy?

I've written a python script that uses a Spatial Analyst function and hence requires the Spatial Analyst extension to be enabled. I would like to be able to check out the extension only if it hasn't ...
2
votes
1answer
62 views

How can I iterate over several layers and run a process using PyQGIS?

I am trying to find road intersections within each of my memory Polyline layers (which are named road_layer_i for i in (0-99)) so this is what I tried: import processing self=qgis.utils layers = ...
0
votes
1answer
24 views

Sum a field, and take that sum and use it to populate an existing field in the same table

I am trying to break down land uses in a watershed by making a tool in ModelBuilder. Right now I am clipping a land use layer by a watershed polygon, dissolving land use layer by land use code, ...
1
vote
1answer
113 views

Import error when utilizing QGIS's Python Init function

Based on the answer to Referencing Qt UIs external to plugin with python. I'm trying to utilize the "Layer Properties / Fields / Python Init function" to execute a file (test_file.py) that is located ...
0
votes
0answers
10 views

Importing XML Schema, Update/Delete Field Names

Presently, I am trying to write a script to import a XML workspace that contains the outline of schema. I want to create a tool/script that allows the user to import it, specify the number of certain ...
0
votes
1answer
137 views

Copying XY to clipboard using Python Add-In (ArcMap)

I am trying to create a simple tool to copy XY from where i click the mouse button. What i have done already is: create add-in files using Python Add-In Wizard create toolbar and tool inside it in ...
1
vote
0answers
50 views

Using processing using other output (result from another algorithm) as input

I have a problem. I am developing a standalone app in python and I need to use processing algorithms. I was able to use one algorithm without erros but I need to run other processing algorithm which ...
9
votes
4answers
8k views

How to change feature class and field aliases in bulk?

I have over a hundred FCs, each with 10 or 20 attributes to add or change the aliases for, two or more times a year. Needless to say, this is not something I'm going to grunt my way through. How can I ...
6
votes
1answer
212 views

How to get the file name of current style using PyQGIS?

I get the name of the current style file using layer.styleURI(). Then, I change the style file using layer.loadNamedStyle(different_filename). However, when I call layer.styleURI() again, it ...
0
votes
1answer
37 views

How to position the Qwidget form/QDialogBox in the left corner using python programming

1) I am creating a Qwidget Form or QDialogBox using QT Designer. I am using the following code to move the form: sDialog.move(50,450) But i want to fit the dialogBox to fit in the left corner.How ...
4
votes
2answers
96 views

Adding a vector layer at QGIS start

I have added a shape file in QGIS using Python plugin. I want to add this shape file when QGIS is loading so i have to add code in the initgui() method. I have used following code in the initgui() ...
2
votes
1answer
123 views

How to print 2 maps in the same PDF page using PyQGIS?

I am trying to generate a one-page PDF document containing the following items: 1) On the left half, a full state map (say, New York State). 2) On the top right quadrant, a map that zooms in to one ...
3
votes
3answers
113 views

Separate a string value in two integers in QGIS

My problem is the following. I have a huge dataset of forest stands. All the information are separated but in many cases the stands have different age and this is marked in one attribute for example ...
4
votes
2answers
1k views

What is Python equivalent of ModelBuilder's Iterate Feature Selection?

My data consists of two featureclasses: Points = points representing trees Polygons = Polygons representing % canopy area by area. Each polygon in the FC has a % canopy measurement in the ...
1
vote
1answer
44 views

Keeping dev scripts in sync with projects

How do you keep your development scripts in sync with your source code management (SCM) and your projects? For instance right now I have things like D:\code\reusable-stuff that goes to an SCM (e.g. ...
3
votes
1answer
130 views

How to open QGIS attribute table in form view using Python?

I've got a plugin where I load some layers. After the last layer loaded, I show the attribute table. However, I would like to select the form view and not the table view (see image). How can I do ...
0
votes
0answers
19 views

Building simple offline map application using Python? [duplicate]

I need to build a simple offline map application using python, which will need some plotting and overlays, using some form of a satellite imagery. I need some help getting off the ground. what ...
0
votes
1answer
55 views

Paper PDF maps to geoJSON

Is there a way to do this? Maps with lat/lng can be analyzed in Acrobat with the analyze/geospatial tool. When a user clicks on the map, the lat/lng is returned. There has to be a way to grab these ...
3
votes
3answers
684 views

How to Populate new field using expression containing MAX value from another field in ArcGIS attribute table using field calculator?

I've got one field X with 10 numerical attributes (float/double). I've created a new field Y (also float/double) which I need to populate with the percentage of each record/attribute (in each of the ...
2
votes
1answer
100 views

PostgreSQL PL/Python Function for “IF” condition

I am using OSM data to run pgr_dijkstra() for weighted-path calculation. But after importing OSM data using osm2pgsql I populated some additional columns into my ways table. So now it has gid serial, ...
1
vote
1answer
373 views

Calculating Stream Length-gradient Index (Hack Index) with the field calculator

I'm trying to calculate the Stream Length-Gradient Index of a stream (example data below). Just started to get into python, but am struggling with a solution to this problem. I have 42 streams to run ...
1
vote
0answers
26 views

WindowsError: [Error 32] The process cannot access the file because it is being used by another process

I am reading images (through Python) and do something. These images are placed in a temporary file, through: tf = tempfile.mkdtemp(filename) I use gdal to read the images (short part of code): ... ...
1
vote
3answers
193 views

Extract numbers from string field

I am trying to calculate field test2 with only the numeric values from a string field test. The entire script is like: def makestr(test) list=[] for s in test: if s.isdigit(): ...
1
vote
2answers
271 views

How to change the value of an attribute using QgsFeature in PyQGIS?

I would like to update one attribute of a feature. However, I don't know to update it using the feature object. I have to use data provider to update it. layers = ...
1
vote
2answers
89 views

How to calculate the Oriented Bounding Box (OBB) of a polygon or point set?

I'd like to calculate the "Oriented Bounding Box" (OBB) which is the enclosing rectangle aligned to the longest extent of a point set (which is not necessarily aligned with the axes of the co-ordinate ...
0
votes
0answers
42 views

How to resolve warning messages from standalone script?

The standalone script, loaded from OSGeo4W Shell and copied below, follows a set of steps: Create grid with cells length/width at 200m Clip a polygon layer onto the grid Use Distance to nearest hub ...
6
votes
1answer
936 views

ArcPy script causing python.exe to stop working (memory issue?)

I have a script written in Python that uses ArcPy to create maps of the kernel densities of thousands of datasets. Each dataset is relatively small, but there about 50,000 sets in total. When I run ...
5
votes
1answer
140 views

How to create a python plugin in QGIS 2.4.0?

While I am learning to create a python plugin in QGIS 2.4.0, I have followed the proceedure expalined in ...
1
vote
1answer
73 views

In qgis using python, how can I get multiple pixels from a raster based on a vector point file

I just started working with qgis, and for the life of me I cannot figure out how to solve this problem: I have several points of interest, these are stored in a shape file (just simple points). I ...
0
votes
1answer
57 views

How to create lines from points from different feature class ArcPy

I want to create lines based on two points: 1st line: point number 1 from pointFc, point number 1 from centFc 2nd line: point number 2 from pointFc, point number 2 from centFc and so on Where did I ...
0
votes
1answer
33 views

GetParameterAsText(arcpy) does not work

I am new in this area. I was practicing the function GetParameterAsText(). I know that when you run the code (for example in PythonWin) it works like the function raw_input(), therefore it should ...
2
votes
0answers
55 views

How to change the group icon in legend via Python in QGIS 2.6?

How to change the group icon in legend via Python in QGIS 2.6? At version 1.x I did it this way: self.legendTree = self.iface.mainWindow().findChild(QDockWidget,"Legend").findChild(QTreeWidget) ...
1
vote
2answers
206 views

Python/GDAL: Best way to read in raster for use in A* search algortihm

I want to create a least cost path program with Python and GDAL since I couldn't find any open source cost path additions for use in Python. As recommended here the best approach is to use A* ...
1
vote
1answer
58 views

Error: 'NoneType' object is not iterable (arcpy.ListRasters)

I am trying to extract a raster through a particular shapefile. import arcpy from arcpy import env from arcpy.sa import * arcpy.CheckOutExtension("Spatial") env.overwriteOutput = True ...
0
votes
2answers
1k views

ArcGis Python Script, Calculate Field

Sorry for my English. I am trying to write a Python Script for ArcGis 10.2. #import system modules import arcpy import math from arcpy import env #Set environment options ...
1
vote
1answer
99 views

Python Stand Alone ArcGIS toolbox output feature class becomes input feature class within same tool?

Developing a script in toolbox. I have a table that I use to make X Y layer (input 1) I am saving that created layer as a point feature class. (output 1) I then want to run kriging on that newly ...
1
vote
2answers
86 views

Can't get SRS from PostGIS using Proj4 text

I'm having a problem transforming a point from the Australian MGA UTM datum (eg MGA Zone 51 http://spatialreference.org/ref/epsg/28351/) to WGS84 using GeoDjango. I've narrowed that down to a problem ...
3
votes
2answers
806 views

Creating Python script to reconcile/post geodatabase versions?

I’m trying to set up a python script so that I can schedule our rec/post to run on a server. I’ve created a model with the Reconcile Version tool, with the option to Post checked on. I then export ...
2
votes
2answers
96 views

How to load a data table as a 'vector layer' using PyQGIS?

This might be a simple problem, but how does one load a simple two column CSV with no associated geometric data? I have given a couple go's via QgsVectorlayer[delimited text, spatialite] types - but ...
22
votes
1answer
915 views

What does the adoption of Python by NVIDIA for GPGPU mean for GIS?

Today NVIDIA announced support for the Python language on its flavor of GPGPU (CUDA). Manifold GIS uses CUDA to enable some accelerated raster operations but it is not a programmable environment and ...
2
votes
1answer
32 views

How to list items in a raster catalog?

I have a managed raster catalog in a file geodatabase that is comprised of 12 images. The screenshot shows the raster catalog footprint with the names of the tiff images that make up the raster ...
2
votes
1answer
47 views

Converting Historical Railroad Systems Data from KML?

I'm writing a paper for an undergraduate economic history class and I'm interested in North American railways in the 1800's. I've found historical GIS data for the period here. The railroad data are ...
0
votes
1answer
30 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 ...
2
votes
1answer
29 views

pymodis download issues

I'm trying to download and process MODIS imagery using pymodis. I have Python 2.7.8 (Spyder), numpy 1.9.1 and gdal 1.11.1. I've also installed WXPython. I originally tried to use the ...
3
votes
0answers
47 views

Error writing memory layer to shapefile in QGIS

I have created a memory polygon layer in my QGIS plugin. Then I added a buffer based on a point. I can see the ploygon memory layer in the map canvas and I can save it to a shapefile from the main ...
0
votes
1answer
32 views

Get Path of File found with os.walk [closed]

I am trying to expose the full path of a file found using os.walk. The walk function is working correctly and is exposing all the files I want however when I try to get the path it looks like it is ...