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

learn more… | top users | synonyms

3
votes
2answers
274 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 ...
3
votes
1answer
272 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
2answers
199 views

How to create a line from more than two points?

I have a loop which calculates two points for each iteration (x3,y3) and (x4,y4). As seen in the code these two points are added for each iteration, which gives i-1 lines. Each line has a individual ...
5
votes
3answers
1k views

Server side clusterer for Google Maps

After doing a lot of research on different types of clustering coordinates (server side) I am still having problems with choosing the best approach for my project. My requirements: Ability to work ...
1
vote
2answers
1k views

python - Calculate field with part of file name

So I previously successfully used the sample code here: Model Builder - How to calculate Field using part of filename # Import standard library modules import arcpy, os, sys from arcpy import env # ...
2
votes
1answer
361 views

Calculate field result is float with Arc tool, integer with arcpy script

I am trying to calculate a field for some points within a python script using arcpy functions. (This is calculating the percentage visibility from a cumulative viewshed, if that matters.) # Process: ...
1
vote
1answer
218 views

How to calculate smallcircle on sphere

I use this python code to calculate a greatcircle: https://code.google.com/p/pyroms/source/browse/trunk/pyroms/greatcircle.py?r=39 After initializing the greatcircle I can calculate points on the ...
8
votes
1answer
921 views

How to read/write from/to QGIS project file using Python?

I'd like to save the project-dependent configuration of my Python plugin inside the QGIS project file. Is this possible and what are best practices to do so?
1
vote
1answer
1k views

How to change vector attributes values?

I want to change vector attributes values. i could not get the command fet.setAttribute indeed, it is mentionned in http://hub.qgis.org/issues/7223 that: "The QgsFeature instance now must be ...
5
votes
3answers
6k views

ArcGIS 10 Python split string

I am trying to use Python to split a string field into three new fields at the separator " - ". The field is in the format "a - b - c". So I initially had this in the field calculator for newFieldA: ...
6
votes
2answers
2k views

How to use QGIS Zonal Stats Plugin from Python Console?

I am using the Zonal Stats plugin in QGIS to extract raster statistics from overlaying polygons (I have shapefiles of species distribution and I want to extract environmental data from within each ...
2
votes
2answers
2k views

How to clip multiple raster datasets with county polygons?

The example below shows three raster (i.e. in black) and a single county polygon feature class. How can I clip/extract by mask the rasters by their corresponding county polygons (i.e. Edwards, Clark, ...
3
votes
3answers
822 views

Add date to feature class name?

I still working on my big project, big at least for me, but I am currently stuck on this: I have a lots of .shp, that I want to move to a gdb. While creating a feature class, I want to add date ...
0
votes
0answers
196 views

Help in GRASS/QGIS/Python

I have Idea about ArcGIS, and a bit of QGIS and zero programming knowledge, which I am trying for thesedays. I saw GRASS GIS and have started working with shapefiles, which are not being loaded... :( ...
1
vote
0answers
691 views

QGIS plugins with python dependencies [closed]

Problem: I have a Windows XP machine with Python 2.7.3 installed at ‘C:\Python27' and the scipy module installed at ‘C:\Python27\Lib\site-packages'. I installed QGIS 1.8 recently and started ...
3
votes
2answers
234 views

How do I tell GRASS where to find Python?

For some reason, when I start GRASS on my Mac it says that it has found Python 2.6.7. However, /usr/bin/python version is 2.7.2 and I can't find a lower version anywhere on my system. Potentially ...
5
votes
1answer
2k views

Cast arcpy result as an integer instead (arcpy.GetCount_management)

I am trying to get a number by counting how many points are in a shapefile. And this works (I think), except I then am running into trouble using that number somewhere else. Eventually, I'll be using ...
0
votes
0answers
330 views

Select record from table attributes in QGIS and Python

Can anyone tell how I can access to the attribute table of a shp and select a record from a specific row and column using Python (with console or a script). I've been looking for in the qgis API, but ...
1
vote
1answer
116 views

GeoDjango - Use GDAL python binding in the shell

I would like to use the GDAL python binding in my GeoDjango site. The aim of this is to use ogr2ogr capabilities in a script. I am on windows 7 so I have installed GDAL-1.9.2.win32-py2.7 downloaded ...
2
votes
2answers
999 views

get value from attribute table and change symbology with QGIS and Python

I'm newbie developing plugins for QGIS using Python, this is the first one and it is very frustrating hehe. Ok, this is the situation, I have a 1 point layer in QGIS. Its attribute table has 4 fields ...
3
votes
1answer
319 views

How to get pixel size of canvas in QGIS?

How to get pixel size of canvas in QGIS? It is possibly by python? I mean this read rectangle area.
1
vote
1answer
529 views

How to write a CSV from Python console in QGIS?

I am trying to write out a CSV file from a vector layer made up of points using the python console in QGIS. I've tried the following command: QgsVectorFileWriter.writeAsVectorFormat(layer_Map, Folder ...
2
votes
2answers
755 views

How to truncate file geodatabase tables with python?

Everything is in the title. I need to truncate file geodatabase tables (1 or all) with python. What is the code for that? Thank you in advance!
8
votes
1answer
665 views

Fastest methods for modifying attribute tables with Python?

A while ago, I wrote a quick Python function for converting an attribute table to a python dictionary, where the key is taken from a user-specified unique ID field (typically the OID field). ...
1
vote
0answers
418 views

Get the distance between 2 WGS84 GEOSGeometries

I currently want to check if 2 given GEOSGeometry objects of type Point are within 100m of each other. (length flexible) Looking at previous asked questions on this topic, most of the answers were ...
0
votes
1answer
97 views

What could I do to make QGIS find all the plugins?

I'm starting to use Ubuntu 12.10 and would like to get my QGIS running on it. Installation was fine but when I tried to add a package called Points to Paths the Plugin Manager was unabled to find it. ...
4
votes
1answer
1k views

How to merge many shapefiles in different folders?

Directory structure is basically as such: county\City\prep\POI\Completed\C1, ...C2, ...etc\ I'm trying to write a script to go through the *\Completed*\POIS.shp and merge them all together, at a ...
1
vote
2answers
185 views

How to acces features attributes when creating renderer?

I'm trying to customize the rendering of a point layer in QGIS using python. Thus I have written a renderer class as explained in the documentation ...
1
vote
1answer
423 views

Data Driven Pages, Graphs, and selections in ArcMap 10.1

Is it possible in python to create a selection set based on the extent from a Data Driven Page (DDP)? I have a layout view with a map and a graph. The graph is set to only plot the selected set of ...
2
votes
1answer
475 views

Spatial Join Python Command to summarize attributes

I am trying to run the Spatial Join function through the python shell in ArcGIS 10. When you do the point-and-click method of spatial join, you are given a tool window with an option that asks "How ...
2
votes
1answer
400 views

need help for script checking topology using ogr in python

My main goal is to create a new feature indicating if the line features intersect each other as well as if they are not connected to a feature. My problem is how to identify the intersecting and not ...
5
votes
1answer
1k views

How to deploy a QGIS Python Standalone Application with minimum installation size?

I am trying to create a Standalone QGis Application using python. I was able to create the nice looking shapeviewer application by following the steps here. Now I would like to deploy this in ...
1
vote
0answers
103 views

Creating Raster with values based on function output

I have a function that calculates a price based on the input slope and distance. I want to write the price to a raster as the rastervalue. How do I do that? OpenSource and ArcMap solutions would work. ...
2
votes
1answer
178 views

selectedFeatureCount vs featureCount?

I do from qgis.core import * layer = QgsVectorLayer(r"D:\file.shp", "boundingBoxes", "ogr") layer.featureCount() outcome is 428 layer.select(layer.pendingAllAttributesList()) ...
0
votes
2answers
135 views

Python dataSource Path

I have the following code: When I run it: conType = arcpy.mapping.ListLayers(imxd, "Construction_pt", df)[0] print conType.dataSource prints... "Database Connections\Edit - ...
1
vote
1answer
114 views

Importing arcgis.rand error from python shell

Not sure what's going on here with this module. Maybe a pathing issue? If I import the module from the python window in ArcMap it works. If I import it in a script, and use that script in a ...
0
votes
1answer
203 views

Accumulate value loop [closed]

I am new to Phyton and currently trying to get my first script to work. Could someone tell me what is wrong with this code: total = 0 def accumulate(increment): global total if total: if (total ...
3
votes
1answer
294 views

Setting Band Statistics on Raster Image (GeoTIFF)

After doing calculations on a raster and saving it, the image statistics are wrong and need updating. I find examples saying that this should do the job, like in this example: ...
3
votes
1answer
826 views

How to set up QGIS print composer options from the python console?

If I have a print composer called "ABC", I would like to "tell" its composer that I would like to update "Map 0" to simulate the "set to map canvas extent" button activation update certain text ...
3
votes
2answers
313 views

How to call gdal_retile from Python code?

I am trying to call gdal_retile from my Python code like this: import gdal_retile and in main: gdal_retile.main("-v -r bilinear -levels 4 -ps 2048 2048 -co \"tiled=YES\" -targetDir pyramid ...
3
votes
1answer
840 views

qgis.core import error

I would want to use the Qgis api for custom desktop application. When I imported the qgis.core module, I get the following error >>> import qgis.core Traceback (most recent call last): ...
1
vote
0answers
144 views

Couldn't load SIP module - python disabled

Recently my QGIS started refusing to load SIP module, from day to day without any significant changes in the system (I'm on Windows7 x64). Message thrown at startup: Nie można wczytać modułu SIP. ...
2
votes
1answer
275 views

Mysterious Invalid Syntax in Field Calculation

I'm trying to calculate a field in Model Builder using the Calculate Field tool. I'm using the following code block and expression in the calculation, but am getting an "invalid syntax (, line 1)" ...
2
votes
1answer
234 views

Python Code: Help with Printing a Message from an AddMessage Result? [duplicate]

I have written a code to count sheets or pages in an mxd. How would I print a message before the display of the count result? For Example: the count is 11. I want it to display "Sheet Count : 11". My ...
3
votes
1answer
277 views

How to check if geometry is M aware?

I am trying to determine whether my shape file that I pass is in M-aware (has M value). I keep getting an error Attribute Error: 'Polyline' object has no attribute 'hasM' Not sure what I am doing ...
10
votes
2answers
1k views

Why is this simple arcpy script so painfully slow?

I have a simple arcpy script to update a field in a point shapefile with info from the polygon feature that it is within. It takes 9 minutes to do 100 points in arcpy but a spatial join in arcmap is ...
0
votes
0answers
357 views

How to use raw_input() in QGIS python console?

I'm hoping to use raw_input() inside a loop to prompt the user when s/he wants to continue running the script. However, I'm getting an error: Traceback (most recent call last): File ...
1
vote
1answer
288 views

Rpy2 Unable to Load in Fresh QGIS Install

after installing qgis the a message given below is shown Unable to load the plugin: Unable to load required package rpy2. Please ensure that both R, and the corresponding version of Rpy2 are ...
2
votes
0answers
102 views

Custom python datasource to QGIS

I'm working on a homebrew spatial feature data format, and using Python to write it's API. It occoured to me that use some tool like QGIS to display my data would be very nice to have, for debug/test ...
5
votes
3answers
438 views

QGIS Gazetteer query without adding data to canvas

I have a PostGIS database with 30 million gazetteer points, each have an X Y coordinate. I want to query this and then zoom map to location. However, I dont want to add the data to the project because ...