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

learn more… | top users | synonyms

6
votes
4answers
645 views

How to optimise and speed up Python code? [closed]

Again my lines of surface runoff... I made a script, solving the issue when lines cross other lines. Something like generalization. Like on the picture below. The problem is that I have to solve 30 ...
1
vote
1answer
34 views

Con() does not recognize raster values

I have a problem when using the con() argument. What I want to do is to remap all raster of a raster file ("Red_SL") cells with values larger than 40 to the new value 5. All other values should be ...
0
votes
2answers
38 views

Check layer data type in gdb

I have path to layer or feature C:\base.gdb\test How to check is table or feature class by arcpy?
1
vote
1answer
49 views

How to write a (memory) layer from QGIS to PostGIS?

I am looking for an "elegant" solution to write, from a python script, a layer from qgis and into a new table of a PostGIS database. I thougth that this might be solved by QgsWriteVectorLayer, but I ...
0
votes
0answers
34 views

Is there a way to take control of the mouse pointer using python in QGIS?

i would like to take control of the mouse pointer in QGIS (for example constraining it to a given extent...) Is there any way to do that using PyQGIS ? Thanks !
1
vote
1answer
33 views

Iso Cluster tool in script failing to open clip raster

I have been coding in Python for only a few months, so maybe I'm just overlooking a minor detail as a newbie. I have written the script below for a class project. It is supposed to clip two rasters, ...
12
votes
2answers
311 views

How is the data access cursor performance so enhanced compared to previous versions?

The data access module was introduced with ArcGIS version 10.1. ESRI describes the data access module as follows (source): The data access module, arcpy.da, is a Python module for working with ...
0
votes
1answer
38 views

How can I efficiently use a list comprehension on an ogr.layer inside a loop in Python?

Problem statement I'm using python 2.7 and ogr 1.11.0 on Windows 7. I have two shapefiles: one for streets and one for junctions. The streets shapefile has fields listing the IDs of the start and ...
1
vote
2answers
42 views

Debugging SQL in arcpy.da.SearchCursor RuntimeError: An invalid SQL statement was used?

I am going through a python script in arcpy 10.1 to Select a field value (i.e. NEAR_DIST) based on three condition as 1) NEAR_DIST<=radius(i.e.500 or anything from user input) 2) ...
0
votes
0answers
36 views

Read large raster into lat/lon value pair to csv file using python and/or gdal?

I have rasters for all of the states in US and they are in 10m resolution. So they can be very large, containing a large number of pixels if you think of TX or AK. I want to create a csv file with ...
2
votes
1answer
48 views

How to return end of string up to a certain character using Field Calculator?

I am trying to accomplish this task: http://stackoverflow.com/questions/15851568/how-to-get-the-last-part-of-a-string-before-a-certain-character within the Field Calculator. I have the below but ...
2
votes
1answer
45 views

How do you duplicate a point within a shapefile using Python?

How do you duplicate a point within a single feature class using Python? I have a partial sample script below, but in a nutshell, I want to duplicate a point, copy it into the same shapefile, and ...
1
vote
1answer
41 views

Pyqgis 2.2 : How to allow editing on layer and features

I'm writing a pyqgis plugin with qgis 2.2 I succeeded in accessing and displaying vector data (geometries & attributes). Now I would like to allow editing for all my layers and all features ...
2
votes
2answers
36 views

Selection of lines that lays mostly in defined zone (majority overlap)

I have lines of surface runoff and I need to select the ones that are lying mostly in internal buffer of polygon. I'm trying to make some script in python, but it's very important to make the script ...
1
vote
0answers
27 views

How to sort a column in attribute table programmatically

Is there any way to sort ( alphabetically ) a column in the attribute table programmatically (without clicking on the column header) in QGIS ?
3
votes
2answers
113 views

PostGIS: Insert a Point using Python

What is the right way to insert a Point to a PostGIS database using Python?
2
votes
1answer
61 views

data source for worldwide cross-sections of topographic and bathymetric for woodworking art project?

i am a decent r programmer and statistician, i am able to work with data sets pretty well. i am less familiar with GIS tools, but if given a shapefile i can certainly plot political borders and ...
0
votes
0answers
45 views

Python + GME (Spatial Ecology) + Subprocess.call

I'm trying to run the following code to use GME commands in Python. import arcpy,os,subprocess from arcpy import env env.workspace=r"D:\Users\myname\Desktop\aviso" count=0 for raster in (f for f in ...
1
vote
0answers
53 views

ArcPy Multiprocessing 000714 - Working in Debug Mode

In an attempt to render an interactive window via matplotlib I am using an out of process script in a toolbox. If I debug the script, it is possible to step through and render the window as expected. ...
1
vote
1answer
37 views

Couldn't load SIP module (QGIS doesn't load Python)

I recently installed QGIS 2.4, but Python does not load. I am running on a Windows 64 bit machine. I receive the error message "Couldn't load SIP module Python support will be disabled". Traceback ...
1
vote
1answer
43 views

Controlling Python Version from ArcGIS?

I am writing a VB.net console application that calls ArcGIS Desktop 10.1 ArcToolbox geoprocessing tools from my code. Some of these tools use Python syntax and I am encountering a problem that I ...
0
votes
1answer
48 views

Cannot put a layer name as the same as the raster name just created by Python script

I have a question regarding Python script for making a Heat Map Tool. I am making a Heat Map Tool where users can set the map extent, the tool will read the current scale of the map, then make a ...
0
votes
0answers
38 views

Is it possible to rotate the geographic projection in QGIS?

I'm trying to create a Qgis plugin that can rotate a raster layer in the canvas so that the north is pointing at another direction. Unlike the thread below, I'm open to defining a custom projection. ...
1
vote
1answer
59 views

What is the inverse of QgsGeometry.asGeometryCollection() in qgis python?

What is the inverse operation of QgsGeometry.asGeometryCollection() as documented here: http://qgis.org/api/classQgsGeometry.html#a7cb1cbf8cfa441456067a66ad3a25a94 I'd like to do something like: ...
1
vote
1answer
67 views

Updating a feature class

I am working on ArcGIS 10.2.1. I have a feature class containing more than 4000 records and a table having approximately 1000 records. Both feature class and table have some common fields however, ...
2
votes
0answers
19 views

How to snap dangling nodes with prescribed angle?

I have got a streets shape file, to snap the dangling nodes in ARCGIS. But, I have to snap only some nodes(of feature) with a prescribed angle (green node in the image, and the angle marked in ...
2
votes
1answer
25 views

raster overlap count

Would it be possible to simply detect and count overlaps between raster files, i.e. not polygons against rasters, using arcpy? By default I don't have the spatial analyst extension for ArcMap 10.1 but ...
0
votes
0answers
37 views

ArcGIS 10.2 with MatPlotLib Non-Blocking Plot

ArcGIS 10.2 ships with MatPlotLib 1.1.1 installed. I am trying to display a non-blocking plot window. Trials: Launch an interactive plot in a Tk window from a toolbox. This causes the plot to ...
0
votes
0answers
31 views

Placing Pins and following transformation on zoom map d3

So I am using this http:// bl.ocks. org/mbostock/4699541 framework on D3.js and I just figured out how to append circles to the map. However when you click on a state the circle moves out of place ...
0
votes
1answer
26 views

Adding a Vertex To Exisiting Feature(linear) Using OGR Python

I am working on a project that involves finding the intersection of linears in a shapefile, if that vertex(the found intersection) doesn't already exist for each(or one) of the features, then that ...
0
votes
2answers
65 views

gdal2Tiles output differs from MapTiler

I'm in need to process a large batch of Landsat images with MapTiler and since the version I'm using (1.0 Beta 2) does not support multiple input files, I created a simple python script that calls ...
1
vote
2answers
60 views

Raster' object is not iterable

I'm trying to calculate the percentage of cell counts in new raster and the new raster is created from an old raster based on the Value > 14. In my code, 1st for loop is for original raster and ...
1
vote
0answers
37 views

How to go about creating a custom tool/adding special functionality for a web app

In my soon to be developed web app, I will have an image service and also a feature service that is essentially an index to the image service, with all kinds of attributes. I would like for the user ...
7
votes
4answers
439 views

How to split single address field into 4 fields (House No., Direction, Name, Suffix)

I have to do some massaging of our parcel data to make it usable by a program in sheriff helicopters. The program requires one of the following address formats within the fields: Our addresses are ...
2
votes
0answers
24 views

Polygon parcel division in python

Is there an open source tool or module in python that does parcel division of polygons like in ArcEditor?
1
vote
0answers
39 views

PyQGIS: Editable Combobox for Value Map widget isses

I am having issues with an editable combo box in QGIS 2.4. The edit widget is set to Value Map with an uploaded CSV. However, if a new values (not included in the key value pair list) is added, the ...
1
vote
1answer
109 views

How does one modify selected geometry with a function in qgis python console?

My example use-case is that I want to redistribute vertices along lines as in: Redistribute linestring vertices to specified distance How to create points in a specified distance along the line in ...
2
votes
1answer
47 views

How to do loops on raster cells with python console in QGIS?

I'm new here and beginner with python. I'm looking for a solution to my problem for some hours but now you are my last chance... I'm using the python (2.7.5) console in QGIS (2.4.0). Is there a ...
1
vote
1answer
62 views

Import arcpy using PyScripter or IDLE gives No module named RuntimeError?

I'm trying to figure out this problem. Yesterday I installed PyScripter and since then, scripts doesn't work. When I run any script (in PyScripter or IDLE) which uses "import arcpy", I get this error ...
0
votes
1answer
93 views

How to write output from subprocess to disk (using multiprocessing)

This code was developed from another question I posted about how to kill an arcpy tool if it takes longer than a specified time. See How to cancel tool execution in python. Using the multiprocssing ...
0
votes
1answer
60 views

What is the syntax for Python 2.7 to permanent display in percent in a field column?

What is the syntax to build to calculate field, for example, Acres to Percent? 841173.00 to 82 % What I want the field column in Percent to be display numbers with percent with the alignment to ...
0
votes
2answers
63 views

Error while importing CSV File using PyQGIS

Currently I am trying to import a CSV file using the python extension in QGIS and I have run into a problem that I can not seem to solve. I am trying to do a basic import of a CSV file from a python ...
0
votes
0answers
16 views

How to get sql error from postgis when a plugin fail to load vector layer?

I am writing a plugin for qgis that load a sql layer from postgis database. I am disappointed that when the layer fails to load i can't find a way to get the sql error message from database server. ...
0
votes
1answer
39 views

40k+ points from Shapefile, clustering them and populating on Google Maps/Webapp

I just started a new Python/Django webapp job related to GIS (and i'm totally new to GIS). Here is my task and what i have found so far, and i am stuck as to finding out what's the best way or the ...
1
vote
0answers
29 views

Import QGIS Python modules in Python command line or standalone script

I am running a Windows 7 machine with Python version 2.7.8 (32 bit). I installed QGIS 2.4 (Chugiak) from OSGeo4W and simply want to be able to import the QGIS Python modules (e.g. qgis.core) into ...
1
vote
2answers
45 views

How to find the minimum pixel value within a region of interest?

I am working on a Python script for dark object subtraction, a radiometric correction method for remotely sensed data.To accomplish this, I need to find the minimum band pixel value of a waterbody ...
2
votes
1answer
50 views

Randomly choosing one from multiple fields in Field Calculator of ArcGIS for Desktop?

Using the Field Calculator in ArcGIS for Desktop, I want to randomly choose one field from a list of 10 fields (strings). The Excel equivalent, which is working, is: =INDEX(A2:J2;rnd()*10+1). How ...
0
votes
2answers
59 views

Export Raster Data to TIFF, BMP, or PNG File Using Python

I am writing a Python script to export a Raster Dataset to a TIFF, BMP, or PNG file, as I would manually by right-clicking on the layer, choosing Data | Export Data, and then make my choices in the ...
1
vote
0answers
29 views

Link to pdf file through mouse clicking

I need help in identifying the feature attributes displaying a pdf file when click in that feature. I see many examples but I don't have success. I try this code: command = "firefox"; imagerelpath = ...
6
votes
1answer
179 views

How to classify time periods in a new field, using Python?

I have a datetime field (Horario) in my feature class, showing only the time. Although the date doesn't appear, it seem to be stored automatically as 30 Dec 1899, I'm not sure why. I want to use ...