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

learn more… | top users | synonyms

3
votes
2answers
348 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
868 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
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)" ...
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 ...
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 ...
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 ...
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 ...
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 ...
5
votes
3answers
441 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 ...
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, ...
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): ...
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
627 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
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 ...
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
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 ...
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
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
5
votes
1answer
527 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 ...
3
votes
1answer
875 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 ...
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?
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 ...
8
votes
2answers
2k 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 ...
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 ...
2
votes
0answers
393 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
190 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
1k 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
209 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 ...
5
votes
2answers
382 views

Exit Python script in ArcGIS 10.0

I have a script with an bail-out function like so: def die(): from sys import exit exit() Occasionally in the script I check a condition and exit if necessary. This works great in 10.1, ...
2
votes
0answers
125 views

Convert geojson labels MBR to MapInfo text object

Im using Dymo (https://github.com/migurski/Dymo/) to generate automatic point labels placement. The output of Dymo is a geojson containing MBRs of the positioned labels with the names of the labels in ...
5
votes
1answer
157 views

Cursor only completes one loop

I am at the end of my rope here. This cursor runs fine for one iteration and then stops. It doesn't throw an error, it just completes. There are 3,000 rows in my table, so I don't know why it would do ...
7
votes
2answers
4k views

How to create a checkbox parameter in a ArcGIS custom Python tool?

I am working on creating an ArcGIS tool from a Python script I am writing. I am wondering if it is possible to have a checkbox parameter. Basically what I want to do is have a parameter where the ...
3
votes
1answer
3k views

How to set the Output Extent (Environment Setting)?

I'm a bit confused as I'm trying to figure out how to set my output extent before creating Thiessen Polygons in a loop of ~100 points shapefile. (ArcMAP 10.0 - Python) for i in range(3,51,1): ...
0
votes
1answer
510 views

How to update element text in arcpy.mapping? [closed]

I have a problem updating a map element text (named element1) in a map document using the following code: a1 = '"' + ("element" + str(1)) + '"' for elm in arcpy.mapping.ListLayoutElements(mxd, ...
2
votes
1answer
504 views

Intersection of convex polygons on a spherical surface

There are a number of algorithms available for the intersection of two convex polygons, but I am interested in an algorithm to find the intersection of two convex polygons on the surface of a sphere, ...
1
vote
1answer
798 views

how to install networkx python in QGIS

How to install and how to compile networkx python on QGIS? I always get an error that no module named networkx in the console of QGIS I copied the file networkx in C:\Program Files\Quantum GIS ...
3
votes
1answer
883 views

Help with Python script for exporting mxds into pdfs!

I have written a python script to export my mxd into a pdf (not using data driven pages). I am getting the error that my mxd path is incorrect! I have included my script below. Any help would be ...
2
votes
1answer
1k views

Python - read shapefile .dbf for encoding

I've written a python script that formats a .shp such that its fields structure matches my office's database view in order to ingest the data of said shapefile. This original shapefile was encoded ...
3
votes
2answers
184 views

How do I detect solid fill tiles in mapnik?

I'm using mapnik (python api) to render a very simple map where land polygons are black and water is white. There are no other features on the map. I'd like to detect if my tile is completely solid ...
1
vote
2answers
236 views

Batch set value/calculate field inside Cursor

I am matching data using a cursor, where one of the final steps is filling in a new attribute, match, with a value calculated during the cursor. This matching is done to an ID field in the original ...
6
votes
3answers
787 views

Classifying point coordinates to countries or continents?

I have about 50 000 points (latitude and longitude), and I would like to find out in which country each of the points is located. It does not need to be super precise, though. (Or actually I only ...
2
votes
1answer
563 views

Update Layer with python, error attribute renderer

I am attempting to automate symbology using python, and ArcMap 10.0. I am importing this script into a toolbox, which I run from arcmap Currently I am getting two errors: 1) LayerObject: Set ...
6
votes
1answer
2k views

How to transform a selected multipart feature into singlepart features while editing in QGIS?

There are several questions and respective answers for how to make a multipart features Layer into a singlepart features one using QGIS: How to break a single polygon into multiple polys? How to ...
8
votes
2answers
789 views

How to remove spikes in polygons with ArcGIS 10/Python?

In the picture below you can see a polygon layer, representing steep slopes, extracted from a TIN. The polygons have a lot of spikes in them. I would like to remove these spikes while the rest of the ...
1
vote
1answer
185 views

How to use QgsVertexMarker in a python plugin?

I am trying to display a vertex marker for a QGIS python plugin I am writing. I am getting a the following error... 'NameError: global name 'QgsVertexMarker' is not defined' canv = ...