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

learn more… | top users | synonyms

1
vote
0answers
39 views

QGIS Add WMS layer with python

I'm developing a stand alone python script using QGIS 2.2.0 libraries. I want to add a WMS base layer to my map, and I follow the instructions reported by the documentation: urlWithParams = ...
1
vote
1answer
29 views

Raster created by python GDAL interpreted upside down

I am using CRS which has axis in left bottom corner. Code below produce Geotiff which is shown allright in QGIS but when I open it in other software it is upside down. Also gdal_calc takes it as ...
0
votes
1answer
165 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 ...
1
vote
0answers
18 views

PyQGIS: Properly trigger actionPan() tool when feature is added

I wrote a plugin which creates a custom map tool that adds features. I would like to cleanly connect to the pan tool after a feature is added. I've done it in the following way and it works, but I get ...
5
votes
1answer
46 views

PySAL natural breaks from Numpy array

I am attempting to extract natural break values from a raster using Python. The intended process goes: Arcpy raster object to NumPy Array (using RasterToNumPyArray) to natural break values (using ...
0
votes
0answers
16 views

Using setCrsTransformEnabled in qgis 2.4

In the python console of qgis I try to load layers from shapefiles which have different CRS using the setCrsTransformEnabled() method. To test the procedure I changed the CRS of the shape file using ...
3
votes
0answers
54 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 ...
3
votes
1answer
35 views

How to refresh the view in QGIS Print Composer using Python?

I am trying to automate the printing of maps based on different attribute classifications using Python in QGIS. Everything is okay except for when I open the printed image, the labels are blurry. ...
2
votes
0answers
56 views

Identifying certain polygon from overlapping set

To clean up a large shapefile, I am looking for a way to do the following: I have the ID of many polygons which need getting rid of stored in a list. These polygons are villages and a second ...
0
votes
0answers
59 views

Why will my field calculator python function always return Null if any inputs are Null?

I've written a simple python function that outputs a list based on yes/no fields. It appends a word to a list if it has a "yes" in another column then writes the list, formatted according to the ...
3
votes
2answers
92 views

How to determine number of features in GeoJSON file using Python or JavaScript?

Is there a best way to determine the number of features in a GeoJSON file? Ideally using Python or JavaScript.
4
votes
1answer
587 views

Iterative position within Field Calculator/Python

I'm not great with Python or programming in general, so I'm not even sure how to ask this question. Basically what I've got is in the left column, and what I want is in the right column. UniqueID ...
1
vote
1answer
66 views

Importing file geodatabase (GDB) to table of contents (TOC) of ArcMap?

I have a geodatabase with several feature dataset and feature classes associated with it respectively. I would like to create a .mxd where the Table of contents consist of group layer and each group ...
1
vote
0answers
34 views

User input and passing variables with ModelBuilder

I have created three modelbuilder tools that must be run in sequence. After running each tool, the user must examine several shapefiles and potentially change the input parameters of the next tool. ...
1
vote
0answers
22 views

Stereo-pair Image Registration

Is there a simple command line or python based way to visually register a pair of overlapping stereo images and clip the non-overlapping areas out? These images do not have spatial information ...
2
votes
2answers
386 views

How to use gdal module in python

I am trying to import gdal modules from osgeo installed in my win64x machine but I get the following error: Traceback (most recent call last): File "", line 1, in from osgeo import ogr ...
4
votes
1answer
2k views

How to calculate the incidence angle of a polyline?

How can I calculate the angle of each polyline in ArcGIS?
1
vote
1answer
69 views

List all Feature datasets & feature classes from a single geodatabase into CSV

I have prepared a python code and I got the following errors: "Parsing error IndentationError: expected an indented block (line 11)" and "Runtime error Traceback (most recent call last): ...
2
votes
3answers
62 views

How to find all distinct values from a single column of an attribute table with GDAL (Python)?

I am working with GDAL and modify ESRI shapefiles with it. I am searching a possibility how to find all distince values from a single column of an attribute table with GDAL (Python). In SQL it would ...
2
votes
4answers
100 views

Field Calculator Python Expression Issues

I'm pretty new to Python and this is my first post on this forum so I could use some help. I am currently attempting to run some code in the Field Calculator in a model in order to replace string ...
0
votes
0answers
50 views

Exporting table of contents (TOC) with group layers to file geodatabase (GDB) with feature datasets?

I have created a python code for exporting shapefiles from TOC from different source folder to a output folder. However, in this case, I have some group layers in the Table of Contents (TOC). ...
-3
votes
0answers
36 views

Exporting group layers from Table of Contents (TOC) to Folders of shapefiles?

I have some group layers in the Table of Contents (TOC). Each group of layers references a few shapefiles from different source folders. I would like to export each group layer name as a folder and ...
1
vote
1answer
135 views

QGIS Python Labelling

i want to label a point layer with those values exceeding a set of variables attribute table as follows 'loc field'(text),'a'(float),'b'(float),'c'(float) variables as follows vara = 5, varb = 3, ...
2
votes
1answer
60 views

ListRasters based on filename using Arcpy

I am trying to create a python script for ArcMap which calculates the ndvi from two raster images for each RGB/NIR pair in a folder. However, I am unsure how to create two raster lists; one which ...
0
votes
0answers
23 views

Export qgis vector layer to PostGIS table using python

I've created script, which does bunch of stuff, and in the end, I would like to export it to postGIS table. What is easiest way to do such export using qgis api or sth. I dont want to write SQL ...
0
votes
0answers
64 views

Looping through each specified layer and exporting PDF map showing shapefile and information taken from each attribute table?

I have been working on an automation script for the purpose of mass pdf exportmaps. I am required to export many pdf maps showing individual boundary files and client information. I believe the ...
0
votes
1answer
136 views

Using Z and M feature geometry to create line graph in ArcPy/Python?

I am a Python (v2.6.5) noob trying to plot a series of 3D polylines into graphs. So far I've come up with: # Import system modules import arcpy, os, sys, string from arcpy import env ...
0
votes
0answers
31 views

How to get rid of suffixes from several shapefiles in a folder [duplicate]

I have several shapefiles in a folder and each one is suffixed by “ _LINES” or “_AREAS” I would like to get rid of these suffixes California_Aqueduct_LINES.shp --> California_Aqueduct.shp ...
1
vote
1answer
34 views

Creating multiple Feature Datasets from table/list using ArcPy?

How to Create multiple Feature Datasets from a table/list. I can create a single feature dataset in a geodatabase with this python code. import arcpy from arcpy import env env.workspace = ...
1
vote
1answer
54 views

Listing all feature datasets and classes from multiple geodatabase into CSV file? [duplicate]

I have a folder having multiple geodatabase and I am calling that folder “Multiplegdb” There are 3 geodatabase in a folder which are as follows: ABC.gdb UVW.gdb XYZ.gdb Each geodatabase have ...
4
votes
1answer
937 views

Setting the extent for a QGIS map using python

I am writing a stand-alone application in Python/QGIS that simply creates maps. I want to load vector/raster layers, set symbology, set extent At the moment, that is all! Currently I am just using ...
1
vote
1answer
42 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 ...
2
votes
1answer
52 views

How to check shape length before running code in Python/ArcPy?

I am using a code to convert a polygon into evenly spaced parallel lines for point in range(0,numPoints+1): shortPoint1 = currentLines[firstLong].positionAlongLine(lineSpaceNum*point) ...
2
votes
1answer
233 views

Arcpy Network Analyst solver error

Hello GIS Stack Exchange, I am finding it difficult to load locations to sublayers using python in ArcGIS 10.0 network analyst Vehicle routing problem. I'm also having some trouble debugging my ...
2
votes
2answers
35 views

Assigning a vector to a field in feature class (UpdateCursor)

I don't know if my mistake is of a general nature. I come from R where it is very easy to store a vector in a matrix column. So now I (new to coding with arcpy) am desperately trying to do the same ...
0
votes
1answer
42 views

QGIS Python - Convert the CRS of an in memory vector layer

In a python script of qgis I load layers from different datasources using the QgsVectorLayer() and the QgsRasterLayer() commands. The coordinate reference systems of the data sources differs. Since I ...
2
votes
1answer
56 views

how to load the QGIS openlayers_plugin in standalone python script (not the QGIS embedded python console)

if I try to load the openlayers plugin in a standalone application it always fails with False, although paths are set, and plugin shows available. (tested on Ubuntu 14.04, QGIS 2.4, python-2.7) ...
1
vote
1answer
27 views

ArcGIS 10.2.1 working with time and reporting when feature geometry has changed

I'm working, with ArcGIS 10.2, ona whole lot of petroleum licencing data that chops and changes, in active areas, on a relatively frequent period. i collect the geometry data month by month (saving ...
8
votes
1answer
1k views

Creating table containing all filenames (and possibly metadata) in File Geodatabase?

I need to create a metadata-table for all files in a File Geodatabase or Spatial Database. It would be awesome if it were possible to automatically be updated with new filenames, and possibly even ...
2
votes
1answer
719 views

GDAL loads in Python, but not IPython (Linux)

I am trying my hardest to utilize the work of the good folks at the GeoDa center, but I cannot seem to get all of the components to load. GDAL, in particular, has been giving me some difficulty. The ...
0
votes
1answer
460 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 ...
3
votes
2answers
150 views

Is there a function to select a region of a map for further processing with Python?

I would like to select a map's region in QGIS for further processing with python console. Ideally I would like to select the region with a mouse drag (like Gimp crop function) and then e.g. analyze ...
-1
votes
1answer
58 views

Help interpreting open text file [closed]

I have an existing Arcpy script written by others that I need help interpreting. The script reads records from a feature class and loops through and writes them to a log file. Here is the section I ...
1
vote
1answer
110 views

Simple field calculator equation in ArcGIS 10.2.1 not working with python parser

I am trying to calculate a percentage in a field in a table. customers and total_customers are short integer fields. arcpy.AddField_management(tableSepSel2, "percent", "DOUBLE") ...
0
votes
1answer
293 views

Apply Symbology to a group layer

I currently have around 200 features that all need have the same symbology applied to them. I have used the ApplySymbologyfromlayer_management however this takes much to long to process, at least a ...
1
vote
2answers
54 views

Creating a plugin tutorial

I am looking for a tutorial of how to create a plugin for QGIS. I want a tutorial that: Explains about the latest version of QGIS Working in windows environment. adequate for absolute beginners and ...
2
votes
1answer
49 views

Loading features attributes into numpy array

I am currently working on an add-on that relies on the user choosing fields of tables (that can be from shapefiles, csv or dbf) that are open in QGIS and then making computations with such data. ...
2
votes
1answer
48 views

GDAL Python Not Working Correctly - Raster Calculations

I am sure this question has been asked and answered before. I am working with a x64 bit installation of OSGeo4W. I am trying to perform raster calculations using the gdal through the OSGeo4W shell, ...
3
votes
1answer
142 views

Extracting centerline of a Complex-Polygon in PostGIS/Python

Any idea how to extract the centerline of the following polygon (Fig1) using PostGIS functions or Python modules? I was trying Voronoi Function but thats not helpful for this kind of shape. I want ...
3
votes
3answers
375 views

Per-pixel (statistical) calculations on a raster stack using GDAL

In R, it's relatively trivial to perform per pixel calculations based on a raster stack (e.g., get std.dev for each pixel on a 12 layer GeoTIFF). Unfortunately, the speed is less than desirable when ...