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

learn more… | top users | synonyms

1
vote
2answers
176 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
409 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
452 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
384 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
101 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
177 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
189 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 ...
0
votes
1answer
379 views

how to make a join with sql server table

I have a question. I'd like to join .shp to table by using AddJoin_management. But I'd like to make join to sqlserver table (not to *.dbf). Is it possible to do? it should look something like this: ...
3
votes
1answer
282 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
764 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
296 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
833 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
121 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
270 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
233 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
258 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
337 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
287 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
99 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
434 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 ...
4
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, ...
1
vote
1answer
267 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): ...
4
votes
1answer
184 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
507 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
1answer
991 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 ...
3
votes
3answers
161 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
4
votes
1answer
603 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
63 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 ...
9
votes
4answers
7k views

using shapely: translating between Polygons and MultiPolygons

[EDIT: the solution to this was simply to use OGR to read shapefiles. See geographika's example.] In an ESRI shapefile, there is no distinction between Polygons and MultiPolygons. Furthermore, there ...
0
votes
1answer
107 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
5
votes
1answer
477 views

How to interpolate polyline or line from points?

We have a lot of points, but with no timestamps to create ways. For now, I've created a sample of the way the points traverse. It's in here, this way can be compared with a Google one. I haven't ...
2
votes
2answers
603 views

Calculate Percent coverage using another raster, with dif resolution and orientation

I have a 0.5 meter raster that defines presence or absence (cells are either 1 or 0). I have another 5 meter raster, which I created. I would like to calculate a percent coverage of the underlying 0.5 ...
3
votes
1answer
802 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
188 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 ...
4
votes
1answer
354 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?
6
votes
2answers
218 views

Add raster paths to shapefile with python (ArcGIS)

I have a problem and maybe someone is able to help me or give me some hints how to start. Situation: I have a lot of raster and of every raster I have the center coordinate. Out of this coordinate I ...
3
votes
1answer
75 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 ...
8
votes
2answers
1k views

How to buffer a vector shapefile using ogr python?

I am trying to learn how to use ogr in python using the country and populated places datasets from http://www.naturalearthdata.com/downloads/50m-cultural-vectors/. I am attempting to use filters and ...
3
votes
1answer
185 views

How to add Oracle database connection to AnalyzeforMSD script?

I use this script right now: import os, arcpy directory = r"C:\Project" for root, dirs, files in os.walk(directory): for myFile in files: fileExt = os.path.splitext(myFile)[1] if (fileExt ...
4
votes
1answer
363 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
309 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 ...
2
votes
0answers
370 views

Multiple ring buffer on point-shape error

I need to calculate multiple ring-buffers, but every time I try, arcgis produces a failure: Executing (Multiple Ring Buffer): MultipleRingBuffer Y:\GIS\RDY\clip\sn_clip.shp ...
1
vote
1answer
177 views

can't generate/display signed float values using python/gdal

I'm trying to create a raster with signed float values as the pixel values and display the results in MapWindow on windows. What is the proper gdal band type to use? I've tried both gdal.GDT_Byte ...
4
votes
5answers
933 views

Python loop Polygon to raster not working

I want to convert a large number of different shp polygons to raster in ArcGIS 10.1, using an existing field column "class" for the new raster classes. I am not very fluent in python but I thought ...
1
vote
1answer
193 views

calculating terrain elevation line

I found too many hits on the web to even see the right direction to go. I have to provide a small proxy server serving requests for a line of terrain elevation data between two coordinates. It is a ...
2
votes
1answer
640 views

Need help in Python script : Getting an unicode encode error

When I`m running a script (it checks to which database a mxd is connected) I get the following error: return codecs.charmap_encode(input,errors,encoding_table) UnicodeEncodeError: 'charmap' codec ...