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

learn more… | top users | synonyms

1
vote
1answer
2k views

Delete first two letters from a string field

I'm looking for a field calculator python statement to delete only the first two letters of string entries. For Ex: !Name!.strip([0:2]) I know this syntax is incorrect. Thanks a lot
6
votes
2answers
268 views

Increasing search radius of nearest neighbors for Nibble tool?

I am working with a raster map vegetation types. I have about 20 types with unique raster code values that can be sorted into three classes: vegetation types I want to expand using the nibble ...
1
vote
2answers
197 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 ...
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 ...
3
votes
1answer
324 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: ...
4
votes
1answer
204 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
962 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 ...
1
vote
0answers
163 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
285 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)" ...
6
votes
3answers
2k views

Creating square grid polygon shapefile with Python?

I have the following coordinates minx, maxx, miny ,maxy = 448262.080078, 450360.750122, 6262492.020081, 6262938.950073 I wish to create a square grid of size 1 m using python. import math ...
2
votes
1answer
189 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()) ...
2
votes
1answer
237 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 ...
2
votes
1answer
354 views

How to begin with tool development for GRASS gis or QGIS GRASS

I wanted to begin with customized tool development in Grass GIS or QGIS grass. How should i begin in to develop the tool. I search a lot in google search engine for begin with tool development in ...
2
votes
2answers
978 views

Where exactly are qgis.gui and qgis.core located?

I'm trying to create a standalone qgis app using pyqgis, i'll be deploying it by copying the install folder of qgis and source folder of my app, and so for the testing purposes i copied qgis install ...
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
419 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 ...
2
votes
1answer
355 views

OGR CreateLayer returns TypeError

I'm trying to create a shapefile layer based on the spatial projection of an already existing raster. (Ultimately, this will be used in gdal.Polygonize to get a shape from my raster data.) However, I ...
5
votes
1answer
154 views

Why are z-values replaced with zero after in_memory use in Python?

My script takes separate 3D feature classes, calculates a field, appends to a target feature class, and then deletes the originals. This is a huge data processing task of over 4700 mass point feature ...
1
vote
1answer
296 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 ...
3
votes
1answer
310 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 ...
2
votes
2answers
237 views

Issue while running grass from subprocess

I have a map based web application using geodjango. I needed to display the crime hotspots within a selected polygon area. I found that v.kernel is very good for generating heatmaps/hotspots. So in my ...
2
votes
1answer
169 views

Can not import qgis.core in python

I installed OSGeo4W. I have no other Python version on my computer. I can import osgeo. But when I try to import qgis.core I am getting the error: >>> import qgis.core Traceback (most ...
35
votes
10answers
10k views

What are some resources for learning ArcPy?

I would like to learn ArcPy, but I do not know quite where to begin. Does anyone have any good advice on where I should start to learn ArcPy?
5
votes
2answers
2k views

ArcGIS script tool: Can you have an input parameter set to optional and have the tool work when an input is not provided?

I'm building a script tool that processes shapefiles ( GPS data collected on weekly basis). The tool is set up to take an input for each shapefile ( in this case Sewer, Storm, Sign). On some days, ...
2
votes
3answers
997 views

Python code : Help with using Search Cursor and Messaging the Total Count of Items from Field in Layer that was Searched

My program works but it is not displaying a message of the total sheet count found in attribute table that the search cursor searched through. For Example: It goes through the mxd chosen by user finds ...
2
votes
1answer
497 views

How to transform KML from lon-lat to UTM (E-N), using Python?

I have a lot of KML files set as lon-lat (geographic coordinates) and want to set them as UTM (E-N) and WGS84 with Python (using arcpy, ogr, or gdal) Does anyone knows how to do this?
1
vote
1answer
161 views

How to run “create mask” from the console?

There's a plugin called "create mask" for qGIS and trying out some simple scripting from the Python console. I would like to call it after I select the vector features I want, then do more related ...
1
vote
1answer
272 views

Change coordinate system in multiple MXDs ArcGIS 9.3 using Python

I have to loop through some folders which may contain *.mxd files and change their coordinate system. I already found this piece of Python which should do the trick for ArcGIS 10.x (from here): ...
0
votes
1answer
1k views

'Exceptions.NameError' > “Name 'sheet_count' is not defined” Error in Python Code

I know this is something simple but for some reason I am having trouble remembering. In my code I am getting a name is not define for sheet_count. This means I would have to define at top correct. For ...
2
votes
2answers
119 views

How do I create a network from connected links

I have a bundle of links in 'some' networks. I need to find out which ones are connected to each other i.e. I need to find out which links are not connected to the 'main' network. I have been working ...
3
votes
3answers
165 views

QGIS Python Intro Text

After reading replies regarding starting a mapping business, I think I'd better read a Python book. Any intro-level Python books to recommend? Mila
3
votes
1answer
629 views

Using field mappings to remove fields from a merged table

EDIT: Soreted, thanks :-) I'm trying to combine a (large) number of tables into a merged table, keeping only certain fields. I've tried the below, but it still gives all the fields. Any ideas? ...
0
votes
3answers
1k views

Summarize values per row using field calculator via Model Builder

I think my problem is easy to solve, but so far I couldn't find a solution. I have a Feature Dataset created with the Union tool in Model Builder and now try to sum up all values of one specific field ...
2
votes
0answers
105 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 ...
2
votes
2answers
2k views

Extract coordinates from vector layer in PyQgis

In Qgis, I have made a polygon, and from that polygon I have made a vector grid via research tools-> vector grid. The grid covers the entire polygon. Now I want to extract these grid points in the ...
4
votes
1answer
645 views

Programmically Populate Value List in ArcGIS Tool Interface

I'm just trying to set up the parameters in a tool I've built in ArcGIS. What I want to do is read in a feature class or table and get the values in a specific field called "SITE". The field contains ...
1
vote
0answers
66 views

Python Program for “QC of PDFs Created from Data Driven Pages”

I need some help. I am fairly new to Python. I found a sample code and I need to change a couple things in it for it to work. I need it to make sure that all PDFs were created from the Data Driven ...
11
votes
1answer
3k views

How to find differences between shapefiles?

Every month I have to QA/QC some streets data for an entire county (over 47,000 records). The first step is to compare the two files. Currently, I'm using a tool that was created in house via VBA ...
0
votes
1answer
108 views

How Could I Calculate Shortest Path ?

I am working on QGIS - 1.8 Version and frequently getting an error while using Road Graph and Shortest Path Opetions. Kindly Suggest or provide solution.. With Regards Prashant Persai
2
votes
1answer
707 views

How to refresh a Combobox Add-in in ArcGIS 10.1

I need to refresh the value in the combobox after an event from other tool in the same add-in (ARCGIS 10.1. Python). I've changed the value of the combobox with the code: combobox.value = val and I ...
5
votes
1answer
341 views

How do I write XML metadata with Python?

Some Python software I have written generates raster files via GDAL. I would like the software to create an XML metadata file for each raster so that I can include details about how the raster was ...
4
votes
1answer
196 views

Programmatic raster-vector calculation

I currently use GRASS' r.mapcalc to find the difference between vector and raster data using a loop and temporary files and layers. Is it possible to do the core calculation between raster with a ...
3
votes
1answer
876 views

Arcpy does not execute “CopyFeatures_Management” to write a featureclass to an ArcSDE database

I have some problems with my Python script. The script gets an JSON with different information about images. The information includes general information about images and also the gps position of ...
2
votes
1answer
213 views

Select and zoom python script

I am attempting to make a simple select and zoom python script for my address points. Currently the script will complete successfully but will not select or zoom to the entered point. I am using two ...
3
votes
1answer
80 views

Python program for “Comparing total number of pages of an mxd to total number of PDFs created from that mxd”!

I need some help on my program. I have the parameters set to ask user to pick an mxd and the folder where those data driven PDFs are located. I started with Search Cursor to create a list from the ...
1
vote
2answers
1k views

Select Layer by Location - Arcpy - Why are my inputs being interpreted as invalid?

I am working on a tool in a python toolbox and am totally confused about what is going on and causing my select by location operation to fail (Error 000368). I am trying to select the features in one ...
4
votes
1answer
390 views

Arcgis Stop Working with my Loop Scrip (Could Be Memory)

I am having issues with my scrip, because it makes my computer very slow after 15 loops arcgis 10.1 and explorer.exe crashes. But instead of this, i can see my 15 pdf files saved correctly and i need ...
4
votes
1answer
329 views

Slow performance on splitting a shapefile by attributes

I've tried to develop some workflows with the ArcPy module for splitting a shapefile based on the unique values in a specified field. The code works as expected except one thing I am not able to ...
4
votes
1answer
399 views

How change border line to no pen with python console?

From Python console I load a shapefile with qgis.utils.iface.addVectorLayer. How I can remove border lines (change to no pen) in the active layer?
1
vote
1answer
454 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 ...