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

learn more… | top users | synonyms

8
votes
2answers
643 views

What are mystery green lines in Layout View produced during ArcObjects script execution?

Could any of ArcObjects guru tell me, what are these green lines on my Page Layout and what to do, or not to do, so they do not appear? See image attached. I do used ArcObjects from Python. My script ...
4
votes
3answers
687 views

How to create Where Clause from user input via Python list?

I am trying to perform a query based on values in a Python list. The where clause will then be used in an Update Cursor, so that the rows NOT equal to the values in the list will be deleted. This is ...
1
vote
4answers
825 views

Get vector features inside a specific extent

The problem: I have a very large vector layer with many features and a much smaller raster layer in a defined region. I want to get only those vector features which are within the raster layers ...
1
vote
1answer
108 views

How to reopen a plugin-window in QGIS?

I am currently taking my first steps in playing around with programming a plugin in python 2.7 for QGIS 1.8. While my plugin does what it should, I would like to make it more userfriendly. At the ...
2
votes
1answer
159 views

How to change VB syntax to Python in Field Calculator?

I want to calculate a field, this is my working example in VB: "C:\Users\Admin\Desktop\Data\" & !Work! & "\1000_\" & !Data! & ".pdf" I'm slowly changing all my scripts to Python, ...
0
votes
0answers
16 views

Sextante Modeler Error “global name os is not defined” [duplicate]

I want to generate a model whic reclassify radter values. So i added Saga reclassify grid values tool to Modeler and saved the model. When i run the model i got this error both on Ubuntu OSgeolive 6.0 ...
5
votes
1answer
314 views

How to create polygons in ArcMap 10.0 using lat/long data from SQL Server 2008 database?

Forgive me if this is very basic, as I'm new to GIS work (though I've been a programmer for 10 years) and so I'm not really sure how to approach this, but here goes... Can I take a table with ...
9
votes
2answers
3k views

How to get raster corner coordinates using Python GDAL bindings?

Is there a way to get the corner coordinates (in degrees lat/long) from a raster file using gdal's Python bindings? A few searches online have convinced me that there is not, so I have developed a ...
0
votes
1answer
102 views

Error on rendering linestring

I am using Mapnik 2.0.1rc0 on a Windows 7 with python 2.7 32bits inside a GeoDjango App using xml. The datasource come from spatialite 4.0. My tiling script can render polygon and point features ...
0
votes
0answers
285 views

mapnik error - fatal flex scanner internal error--end of buffer missed

I am using Mapnik 2.0.1rc0 on a Windows 7 with python 2.7 32bits inside a GeoDjango App. I often got this error: fatal flex scanner internal error--end of buffer missed that makes python to crash ...
0
votes
1answer
776 views

Where Clause problems when all parts are user input variables

I have written some generic user ipnut code for a toolbox script (ArcGIS 10.0) but because everything is a variable I don't know how to write the SQL whereclause. Please can someone help and suggest ...
2
votes
1answer
570 views

Error 999998 in Arcpy 10.1

I found an RuntimeError: ERROR 999998: Unexpected Error when lunching Arcpy in my ArcGis 10.1 such as this: Runtime error Traceback (most recent call last): File "", line 50, in File ...
3
votes
1answer
329 views

AGS 10.1 geoprocessing service returning the wrong URL

I have an image export geoprocessing service that runs on ArcGIS server 10.1. It works by writing an image out to the scratch folder, and returning the location of that image. Basically just this: ...
1
vote
0answers
518 views

How to transfer the attributes of features based on their spatial relationship?

I'd like to check if a point feature class is placed on a line feature using python in ArcGIS 10.0. I have created a set of point features and placed them directly on a group of line features at ...
2
votes
2answers
323 views

How to determine the coordinates of the corners of the raster layer

How can we determine the coordinates of the corners of the raster layer? The image opens function QgsRasterLayer.
1
vote
2answers
156 views

How to interact layers with a nested loop?

I've dealing with the code below with such a long time. I have to show in a raster image the result of calculating the cost of the electricity for a solar plant. The thing is that I have to interact a ...
2
votes
1answer
444 views

Compare two Digital Elevation Model (DEM)

I would like to know what's the best method(s) to compare two DEMs without using any GUI soft like QGIS or ArcGIS. I'd like to do it in Python or C++, with GDAL or other similar lib. Does calculating ...
3
votes
3answers
2k views

Updating Attributes using Pyshp

Is it possible to update an attribute field in a shapefile using pyshp ? I went through their documentation and all they show is how to create new attribute rather than editing or updating an already ...
4
votes
2answers
385 views

Moran's I z-score in ArcPy

I have a ArcPy script to calculate Moran's I several times (50 to be precise). However, I am not interested in the Moran's I value, what I need is the z-score returned by the tool. Even though the ...
4
votes
1answer
122 views

How to return text from GP service?

So I've got a website that I want to extend by letting people look up postal/zip codes for an address they enter. I've already got all the addresses (with their postal codes) for the city in an ...
2
votes
2answers
328 views

Weird File Path Returning from Print Statement Causing ERROR 000732

I have created a python script in ArcGIS 10.1. My first parameter type is a 'Feature Layer' set to as a multivalue input. I was running my script quite well off of data from one of my drives (my ...
4
votes
0answers
396 views

Extracting x,y,z values from a postgis linestring to python using ogr

I am trying to load a postgis linestring into python (using ST_DumpPoints) and extracting x,y,z coordinates, which is working but extremely slow..and if i mean slow, i really mean it (yes, it takes ...
1
vote
0answers
562 views

How to calculate average value within a polygon(in Qgis with Python)?

Now I have a point and polygon shapefile and I want to calculate the points' average value within each polygons How to do it with python? I tried to find out but google gives me a lot of raster ...
6
votes
1answer
6k views

Calculate area within Python script in Arcmap

I am trying to calculate the area of a polygon within my Python script. I create a new polygon from merging two together, and I'd like to add the area of the resulting polygon to a field in the output ...
1
vote
1answer
125 views

How to save ArcGIS process output to variable?

I've created script in Python for ArcGIS that simplify Line, and make buffer from processed line. input = "input.shp" name = "bord" buffer = "buffer.shp" gp.SimplifyLine_management(name, input, ...
10
votes
1answer
176 views

How to save python session in QGIS?

After running a lot of scripts in QGIS' python console, I have more than 10 dictionaries and lists, and I need these for further analysis. Is there a way to save python session, with all these ...
51
votes
6answers
6k views

When to use ModelBuilder over Python scripting and vice versa?

I am new to Python scripting in ArcGIS but not new to ModelBuilder. I would like to know the benefits of Python vs ModelBuilder. When should we write Python script for GIS automation rather than ...
2
votes
4answers
2k views

Possible to add multiple fields in single arcpy statement?

I'm trying to add multiple fields to a table using arcpy and am wondering if it's possible to have multiple fields declared in the AddField management, and their values, separated by commas or ...
0
votes
1answer
182 views

How to save image to disk with with gdal_translate?

I do: import os from gdal import * filename = 'c:/rast.jpg' outputTif = 'c:/rastOut.tif' os.system('gdal_translate filename outputTif') but it returns "1". gdal_translate doesn't save the image ...
1
vote
1answer
337 views

How to add MS SQL table using python console?

I have MS SQL Server 2008 R2 database. How to add MS SQL Table using python console in QGIS?
1
vote
1answer
256 views

OWSLib and python3

Trying to install OWSlib-master (and 0.7.1) from https://github.com/geopython/OWSLib yields problems that ultimately seem to be related to python3 >c:\Python32\python.exe setup.py install running ...
0
votes
1answer
769 views

qgis plugin: “WindowsError: [Error 6] The handle is invalid”

OS: Windows 7 64bit GIS: QGIS 1.8 (qgis.org/downloads/QGIS-OSGeo4W-1.8.0-2-Setup.exe) path variable: GISBASE=C:\Program Files (x86)\Quantum GIS Lisboa\apps\grass\grass-6.4.3RC2 ...
1
vote
0answers
132 views

Using Python to Switch Layout Templates

Using ArcMap 10.1: Since there is not a way to control portrait or landscape of the layout view through python, is there a way to switch layout templates without opening a new mxd through python? ...
2
votes
2answers
322 views

Python Toolbox Raster Parameter Error

I borrowed a simple script I found online to clip a shapefile from the extent of a raster. It works perfectly from the ArcMap built in python command prompt. I modified is slightly to use in a tool. ...
3
votes
0answers
296 views

Field calculator error [duplicate]

NOTE: This problem is similar to one that was answered here: Why does Field Calculator return 0 values when decimals are expected? I'm relatively new to python, and am trying to run a simple field ...
0
votes
1answer
320 views

Using the API of QSpatiaLite plugin

I am using the popular QSpatiaLite plugin for QGIS. Since I am creating and modifying SpatiaLite tables directly with Python (using pyspatialite), I wonder whether I can automate tasks such as ...
3
votes
3answers
2k views

SearchCursor() fails to read feature class

First of all, I would like to apologize if this problem is trivial for you guys since I am very new to ArcPy and Python in general. I want write a script to read attribute table from a feature class ...
1
vote
2answers
244 views

How to handle adding a PostGIS layer in pyQgis without saving password?

I'm writing python plugin and trying to find the right way to add PostGIS layer on the map without storing user password. After adding layer on the map, I strip out the password from uri like this: ...
3
votes
1answer
385 views

Finding optimal network with python and network analyst in arcgis 10.0

Hello GIS StackExchange, I'd like to know if there's any way to find the shortest distance across the diagonals of a polygon. I am creating a network analyst solution to determine the most cost ...
9
votes
1answer
718 views

How to address the new “Task-Completed” QgsMessageBar in Python?

I am really amazed what huge steps the QGIS development has taken in the last months. The new iconset, the improved Print composer and many more changes to be seen in QGIS 2.0 are really awesome! ...
2
votes
1answer
168 views

Script to either rotate existing text element or insert graphic element

I have about 300 maps that contain a text element that needs to be rotated. I am pretty new to python but I have heard how great it is. This seemed like the perfect task for python but I have had no ...
0
votes
0answers
66 views

Replace Null Values Field Calculator [duplicate]

I am using ArcGIS 10 and have a polygon shapefile in which many of the numeric fields are Null. The polygon shapefile in question is produced by joining a polygon shapefile with a point shapefile and ...
2
votes
1answer
569 views

How to add one or more points to an existing polyline or polygon?

Using the following code, I make a polyline with two points. vl = QgsVectorLayer("LineString", layerName, "memory") pr = vl.dataProvider() vl.startEditing() fet = QgsFeature() ...
3
votes
1answer
2k views

Python GDAL: Write new raster using projection from old

If I read in a raster image as an array, then make some changes to the values in the array, how do I then save the array as a raster with the same projection information as the original array? In ...
2
votes
2answers
1k views

Merging many rasters using Python

I have a list of many many rasters. I want to have a simple and easy to understand script that takes this and merges it into one big mosaic. I found a similar question but the accepted answer adivices ...
2
votes
1answer
456 views

Am I over-complicating adding and then calculating fields? Suggestions for a better way? (Python)

I'm attempting to re-position a question I asked yesterday here. I am starting to think that the way I wrote my code just isn't the best way. Am I overcomplicating things? I know for a fact that ...
3
votes
1answer
299 views

Arcobjects: DisplayTransformation.FromMapPoint() transforms wrong

I want to transform map coords into page coords in ArcObjects in Python. So I do, say: >>> pApp = NewObj(esriFrame.AppROT, esriFrame.IAppROT).Item(0) >>> pDoc = pApp.Document ...
2
votes
1answer
158 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 = ...
3
votes
2answers
292 views

How to write an equivalent to MapBasic's CreateLine in pyQGIS?

I know this kind of question has been asked, in part, before - specifically: Seeing QGIS Python Commands and: How is object created as line using createline stored in .tab file? but this is a specific ...
2
votes
1answer
2k views

Incorrect field name resulted in RuntimeError: ERROR 999999 (Also, better code for adding and calculating fields)

This is the bottom half of my code (and it's been edited somewhat to share publicly). The code works perfectly fine when the fieldList has only three fields in it, but when I populate it with all 108 ...