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

learn more… | top users | synonyms

1
vote
0answers
14 views

Print Custom Feature Form using PyQGIS

I recently asked a question and accepted the answer, as it was a good guide on accessing the print composer using python. However, I am still looking for a way to print the custom feature form. Does ...
3
votes
1answer
292 views

Python Postgres Multiprocessing speed increase

I'm trying to speed up my PostGIS queries using multiprocessing. My current setup is using python and psycopg2 such as below. Although this has given a speed increase, it still seems like there are ...
2
votes
0answers
65 views

Script to unzip a file geodatabase fails with Memory Leak

Hijacked the ESRI script to unzip. After research I found there is a memory leak. There are three zip files I download on a regular basis. Each .zip contains one (1) .gdb. The largest is 2 GB zipped, ...
1
vote
2answers
58 views

How to label only house number in python? [duplicate]

I have parcel data that has the site address field as ex. 123 First Avenue. I only want to label the house numbers on the map, so 123 in the example. How can I do this using the label expression in ...
3
votes
0answers
31 views

Get value from Metadata in Python Script for attribute

I am working on a python script to create some feature classes from dbf tables. As part of the script I would like to pull two values (FGDC "publication date" and ArcGIS Spatial Reference ArcGIS ...
1
vote
1answer
40 views

Can't Remove a Menu in Python Add-in

I have a Python add-in with a good amount of buttons and menus. I'm trying to remove a menu using the addin_assistant, but the menu isn't being removed from config.xml. I've tried removing the add-in ...
1
vote
2answers
36 views

How to provide a default value in an arcpy script?

How do I provide a default value like recommended in every Arcpy script? This script is exported from ModelBuilder where every output except the last one is set to temporary and managed. I want this ...
1
vote
1answer
27 views

Issues with FME and the ArcInfo licence

I have ArcInfo 10.2.1, Python 2.7 and FME 2013 SP4 installed on my Computer. I want to run a python script I exported from ModelBuilder (where it ran without issues) and imported in FME as shutdown ...
0
votes
1answer
149 views

Writing shapefile with projection defined crashes fiona

I've just started trying to use Fiona to write out shapefiles. I found the example code below, which seems to work fine from shapely.geometry import mapping, Polygon import fiona # Here's an example ...
2
votes
2answers
53 views

How to open the “File Browse” dialog in Windows from a PyQGIS plugin code?

I am in the process of developing a plugin for QGIS using Python. Note that this is my first plugin, so the query could be quite basic... I have used this Digital Geography link to create the basic ...
1
vote
1answer
25 views

How to Set Label Expression Using a Long Field Type in Toolbox

What I am hoping to be able to achieve with this Tool within my Toolbox is to allow the user to input a number of layers and to set all of the labels with the same font settings (font style, color, ...
3
votes
2answers
303 views

Load and display a layer using PYQGIS

I'm having a go at using pyqgis from within the QGIS python console to load a layer from SQL Server and display it. I feel like I'm part way there but I'm having a real issue getting the layer to ...
2
votes
2answers
49 views

csv to shp missing file

I transform a csv file into a shape file using the following script import shapefile as shp import csv import tkinter.filedialog import urllib.request import os a = ...
1
vote
1answer
106 views

UnicodeDecodeError: While installing gdal in a new Python Virtual Environment

I was trying to create a Python Virtual Environment for some initial GIS development. I installed pip and virtualenv and then tried the following commands from the Linux-Terminal to accomplish the ...
0
votes
0answers
22 views

export qgis point symbols per feature

I am currently trying to export the drawn symbol in a QGIS map for a webmap. The current approach is to extract the properties: if i.rendererV2().dump()[0:6] == 'SINGLE' and i.geometryType() == 0: ...
0
votes
2answers
45 views

arcpy calculate string field: Any ideas what how to fix this?

I'm trying to store a string value obtained from a loop through a tuple into a field called ROW_1. The code goes like this: for creekclass in listOfClassTuples: (classname, Permanency, ...
4
votes
3answers
2k views

'NoneType' object has no attribute

I am new to python geospatial programming. i ran the following script and got the corresponding error message >>> import osgeo >>> import osgeo.ogr >>> shapefile = ...
3
votes
1answer
85 views

Using GDAL in python to stack Landsat bands

I am processing a large amount of landsat data. Landsat scenes ship as a collection of tiffs- one file for each spectral band, plus a bunch of masks. I need to stack some of the bands into a single ...
11
votes
7answers
7k views

Python GDAL package missing header file when installing via pip

I asked this question on Stack Overflow before I realised this site existed. As this site it more appropriate, I'll ask it here too. I'm trying to install gdal from pip pip install gdal inside a ...
1
vote
1answer
39 views

Using Selection Sets with Python

I am trying to build a model that reads through about 30 different point feature classes and appends only the selected features to a new feature class. Some of the feature classes don't have any ...
6
votes
3answers
6k views

Converting X,Y coordinates to lat/long using pyproj and Proj.4 returns the wrong coordinates

I'm writing a python script that reads multiple XML files containing x and y coordinates and combines them all into a single csv file. Latitude and Longitude are required fields in the csv, but I am ...
2
votes
0answers
33 views

QGIS 2.2.0-Valmiera 64bit on windows 8.1 displays error while creating ROI in SAC plugin

I don't know what happened while creating ROI during Classification using Semi automatic Classification Plugin 3.1.0 "Rome" installed on hp Pavillion i7 with windows 8.1 When i started to generate ROI ...
3
votes
1answer
163 views

draw lines with an angle inside a rectangle in python

I am trying to make a plugin for Qgis with python. I have the four corner coordinates for a rectangle. I want to give the user the inputs, line space and angle (0 -180 degrees). With these inputs, I ...
3
votes
2answers
45 views

Python, OGR and Mapnik: Possibility of passing existing ogr.Open() datasource into Mapnik without using mapnik.Ogr()?

Okay, I'm trying to modify create_utfgrids.py to use an OGR VRT file, rather than shapefiles, and while the OGR stuff in this code responds to the VRT, the Mapnik stuff is not. It's failing with.. ...
1
vote
0answers
36 views

midpoint of segments in QGIS determination

Gene thanks for your note on the problem yesterday ... This is a follow up to a question I posed before (How to find the middle point of a line in QGIS - Where to place input file name). Errors coming ...
0
votes
1answer
173 views

Python Geoserver gsconfig create resource from Postgis store table

I've working Workspace and PostGIS store in GeoServer. I would like to use python and gsconfig to create new resource/new layer from existing PostGIS table, with: computing bbox, adding abstract, ...
1
vote
1answer
42 views

how to convert kml to wkt using geodjango or python?

in geodjango i found that i can use WKT to insert geometry such as: pnt = GEOSGeometry('POINT(5 23)') but it doesn't show how to do it if the data is KML, as my data is in kml format, so my plan is ...
1
vote
1answer
142 views

Raster extent, just clipped by geomtery, slightly differs from a given geometry

The raster using arcgis geoprocessing is cliped with a feature, reading it's geometry and as a result, rasters extent slightly differs. Extent of geom: str(row.shape.extent) '570600,537958652 ...
2
votes
1answer
49 views

Adding new Field and writing values for all features

I need to create new Field in Attribute table of vector layer, and afterwards to calculate values and store them in that Field for all features I have in that layer. I have solution which works, but ...
7
votes
2answers
94 views

Rules of Nodata value?

What are the arithmetic rules that govern Nodata values? Regardless of how these null values are defined? I am using ArcMap Raster Calculator. I am thinking specifically of operations like 1*Nodata ...
4
votes
1answer
179 views

How can I modify layer order with the QGIS python API [duplicate]

Typically, after a new_layer = addRasterLayer(...) that inserts new_layer before the active layer, I'd like to move it to the top of the table of contents. How to do it? I use an existing QGIS ...
2
votes
1answer
171 views

How to use SAGA ShapesToGrid via Processing in a Python plugin?

I run these lines in my code: vectorlayer_vector = ftools_utils.getVectorLayerByName(inputLayer) Elevation = self.lineAttrib.currentText() cellSize = int(self.linePix.value()) outPath = ...
1
vote
0answers
50 views

Is there a python function in QGIS to detect if the output file is saved to the hard disk?

I'm currently using QGIS 2.4 and writing some custom scripts on it. A proper script not only accomplishes its function, but also accepts user defined parameters and checks for possibilities of errors. ...
2
votes
1answer
41 views

Exporting layout elements and constants to Python script?

Is it possible to export the elements and constants used in a layout to a Python script? Something similar to creating a model and exporting it to Python but instead of being a model, it's a layout? ...
9
votes
2answers
5k views

How to list feature classes in multiple geodatabases in a folder?

I have a folder with numerous geodatabases in it. Within the geodatabases are feature classes. I would like to get a list of the feature classes in these geodatabases using a Python script. I've only ...
3
votes
4answers
278 views

Having trouble with 'and' 'or' statements and negative numbers

I have set up a program that calculates the relationship between a point and the first point of a polyline. The aim of the program is to run this calculation and then copy the result to a certain ...
2
votes
2answers
135 views

Geodjango read raster files

I am developing a web app in geodjango (django) framework but I need to import raster files. Is it possible a geodjango app read raster files from a directory? Thanks
1
vote
2answers
467 views

How to create GRASS scripts in C# in Windows

Most of the tutorials that I have seen are under Python and Linux. Is it Possible to create GRASS scripts in C# or atleast in Windows. I can create scripts using a different language as a compromise ...
1
vote
1answer
129 views

How to save after using fet.setFeatureId in pyQGIS?

By using the following code, I want to change the id of the line when saving the line. But the setFeatureId command, gives a false when doing the commitChanges(). Any idea how to change the id? vl = ...
11
votes
4answers
2k views

Looking for a pythonic way to calculate the length of a WKT linestring

I was quite unsatisfied with Calculating Length of Linestrings in WGS84 in Miles. It kept me wondering if there is a more convenient, Pythonic way to calculate the length of a WKT linestring according ...
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
164 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
17 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
53 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 ...