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

learn more… | top users | synonyms

2
votes
2answers
527 views

Find index location of a lat/lon point on a raster grid in ArcPy

This question has been confusing me for a while, and I'd love y'all's help. I'm trying to find the index location on a raster (in terms of column and row#) of a specified lat/lon point. My first ...
2
votes
2answers
211 views

Get Index for a group QGIS Python

I am trying to add new layers into a specific group which I can get to work if I know the index but how can I get python to fid the index of a group so it can load the new layer into the group ...
2
votes
1answer
323 views

How to assign values to field using if/then logic involving multiple fields?

I want to run a field calculation on a string field named [territory] that first looks at a string field [majr_src] to see if there is a value other than "NONE", if so [territory] = [majr_src]. If ...
2
votes
1answer
501 views

How to refresh Catalog window from ArcMap using Python?

I am running my script from ArcMap and I have the Catalog window open on the side. I delete some extra files in the end of my script but I have to refresh the Catalog window to see them go. So I ...
2
votes
1answer
796 views

How to use GROUP BY with arcpy.da.SearchCursor in file geodatabase?

fc = "C:\Users\AuxS3-4\Documents\ArcGIS/Default.gdb\Malla" fields = ('OBJECTID','Sentido','Carriles','idMalla') sqlclause=(None, "GROUP BY Sentido") cursor = arcpy.da.SearchCursor(fc, ...
2
votes
1answer
573 views

ArcGIS 10.0 get sde information out of .mxd

The overall goal here is to iterate through several directories of .mxd files and document which SQL Server instance of SDE they are pointing to, with the database name and feature class names. All ...
2
votes
2answers
88 views

Setting ProductCode for python script (Citrix environment)

I have set up a python script in ArcToolbox for our users. However when running it with ArcView 10.0 licensing the script fails with: ERROR 000824: The tool is not licensed I think it's an ...
2
votes
2answers
73 views

Accessing features via arcpy

i try to use arcpy to accessing the features of a shapefile. I tried to use a searcheCursor, like that: cursor = arcpy.da.SearchCursor(Points, ["SHAPE@XY"]) for row in cursor: x, y = row[0] ...
2
votes
2answers
584 views

Interpolation iteration using ArcGIS- arcpy

My current project requires interpolation of state level weather data. Approximately 5 years of daily data needs to be interpolated. I still need to figure out the best interpolation method. However, ...
2
votes
1answer
194 views

Model or Code to query all feature classes in geodatabase by selecting by attribute

I have a geodatabase that has 60+ feature classes that each contain records for 60+ locations. I need to export all records from each feature class for a specific location. In each FC there is a ...
2
votes
2answers
236 views

Group and export to pdf based on an attribute field using DDP - Python Script

Using Python, I want to export a map series. Each series needs to be grouped based on an attribute field which is not being used in DDP settings (page num, page index etc...). For example: my ...
2
votes
1answer
128 views

GDAL local files VS ftp files

I can successfully get raster information when the raster file is located on my local file system: import gdal from gdalconst import * filename= "MOD11A1.A2012193.h11v11.005.2012196013534.hdf" ...
2
votes
3answers
2k views

Python script for identifying duplicate records (follow up)

I am trying to calculate a field that marks duplicates and sequentially numbers them. I am using the code below that I found here: Generating sequential numbering for duplicate values in a field ...
2
votes
1answer
863 views

How to import sextante(processing) for QGIS 1.9 (2.0)

In the current QGIS development snapshot the SEXTANTE toolbox has been merged into QGIS and is now known as "processing". This is a good step, but the previous import command doesn't work anymore. ...
2
votes
1answer
65 views

arcgisscripting in CGI script

I'm trying to write a Python script that imports arcgisscripting (stuck on 9.3.1 here) which is then run as CGI by a web app. It runs fine from the Windows command line but as soon as I drop it into ...
2
votes
1answer
489 views

ArcGIS 10.1 Python script to snap points to lines

I have 2 Feature Datasets in a geodatabase. One dataset contains bus routes and the other contains bus stops for each route. I want to create a script that will snap the bus stops to the vertex of the ...
2
votes
2answers
730 views

Fiona ImportError: DLL load failed

I've been using the great Shapely/Fiona combo successfully on Linux, but now i need to create a kind of production environment on windows and theres only one problem. When i try to import fiona, i get ...
2
votes
1answer
171 views

Using Sum() or something similar with CalculateField_management and FieldLists

I need some help with using variables with CalculateField_management tool. I've tried several different scenarios but don't seem to have any luck. What I have is a list of fields containing water ...
2
votes
1answer
97 views

How to set default bad layers handler in the python plugin?

I am trying to write a python plugin for QGis. My python plugin will copy a template qgis project into data catalog with ESRI shapefiles. Because data catalogs can vary in its content there will be ...
2
votes
1answer
267 views

Using update cursor on a field with a domain

I have been replacing field calculations with python update cursors in many of my work flows and today I ran into a problem. The fields being updated have an attribute domain. so now, when I ...
2
votes
2answers
168 views

Why does QgsSpatialIndex::nearestNeighbor(point, 1) sometimes return 2 lines?

I'm trying to get the closest line to a point using pyQgis in a plugin. The active code file is this: http://pastebin.com/TDzmsKVM When I request the closest line (only 1) nearestIds = ...
2
votes
1answer
320 views

ImportError: No module named qgis.core

I am on Ubuntu 13.04. I get the following error message - Traceback (most recent call last): File "analyse.py", line 1, in <module> from log import shelve File ...
2
votes
1answer
323 views

how to loop grass command in python and put variable in output file

first day Grass programming with python scripting; first prob; simple I want to reclass the same raster several times; and save the file with the value loop variable at the end ... can not get it ...
2
votes
1answer
484 views

Combining polygon geometries with python and QGIS segfaults

I am trying to combine polygons, using Qgis 1.8, and every time I run this script in the python console, I get a segmentation fault. Here is the script: from PyQt4.QtCore import * iface = ...
2
votes
2answers
661 views

Geopy Error with Reverse Geocoding

I am using Geopy. I get following error for the code. I have using the same code as on https://code.google.com/p/geopy/wiki/ReverseGeocoding from geopy import geocoders g = geocoders.GeoNames() ...
2
votes
1answer
391 views

How to “Merge Selected Features” with python?

I have been looking for the answer to this question for some time now, but can't seem to find it! My problem is straight forward: I have one layer It contains lots of features (only polygons), say ...
2
votes
1answer
509 views

Python code: Using Search Cursor to find missing values in attribute table between two layers in one MXD

I need help! I am writing a program that will look through the table of a station layer and then go to the annotation layer and list all the missing values. For Example: The station layer has a field ...
2
votes
1answer
328 views

OGR - Weird GeomType -2147483645 on polygon shapefile

I am trying to import a shapefile (multipolygon) in an app with ogr but I got an error about invalid geom type. If I inspect the data with ogr like this: datasource = ogr.Open("c:\\temp\\data.shp") ...
2
votes
2answers
295 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. ...
2
votes
1answer
1k 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 ...
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 ...
2
votes
1answer
473 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
274 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
198 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 ...
2
votes
2answers
1k views

How to make editable polygons in Google Maps?

I've just recently started learning Google maps, JavaScript, etc., and have a few questions about a project that I'd like to do. I'm wanting to take some ESRI shapefiles, convert them to KML, and then ...
2
votes
1answer
290 views

Copy two datasets that particpate in the same relationship class

I have an ArcSDE GDB that looks something like this: ++ GDB +++++ Dataset1 ++++++++ FeatureClass1 ++++++++ FeatureClass2 +++++ Dataset2 ++++++++ FeatureClass3 ++++++++ FeatureClass4 +++++ Table +++++ ...
2
votes
1answer
113 views

What is causing sr.lock on tables after looping?

The following code puts an sr.lock on each table in my List. What’s causing my tables to lock up? I understand my script is reading or opening my tables temporarily to perform the ...
2
votes
1answer
687 views

Using Python in the Field Calculator, how do I refer to a field in another shapefile?

I want to compare the changes in geometry between two shapefiles (of election districts in NYC. One is from 2001 and the other 2005). I am attempting to calculate a new field in the 2005 shapefile ...
2
votes
1answer
134 views

How to get a list of all projections that are currently available in QGIS via the PyQGIS-API

i'm building a QGIS-Plugin and i want the user to choose a CRS out of a combobox in which the coordinates he would enter into some textfields are represented, so these can be converted into another ...
2
votes
1answer
75 views

Python code for locking elements in Layout view

Is it possible to lock elements in layout view in Python? I know it is possible in the production cartography extension from ESRI but all I need is the funcionality to lock elements. I am wondering if ...
2
votes
1answer
192 views

Dissolving stream orders using Python rather than VB script?

I've been trying to dissolve streams, using orders programatically and I came across this VB script. The reason is that if I use ArcGIS dissolve, it merges the confluence of the same orders. I would ...
2
votes
1answer
535 views

Why does Merge then Dissolve return ERROR 000732: Input Features: Dataset … does not exist or is not supported?

I'm not sure why I'm running into this problem. I thought it might have something to do with the merged file being locked or open, but I don't see a "LOCK" file being created in Windows Explorer. ...
2
votes
1answer
80 views

remember QGIS instance

it would be absolutely great if someone could help me with the following problem: I have a simple Python-Plugin that starts another executable in a subprocess. From within this application (which ...
2
votes
2answers
338 views

arcpy.mapping.AddLayer invisible layer

I'm having a bit of a problem with a script on a particular machine. ========================================================== import arcpy,sys class AddLayer(object): ''' classdocs ...
2
votes
2answers
573 views

How to import qgis.core to python IDLE?

I try to follow the step in How to import qgis.core to python app? to import qgis.core with Python Shell. But when I type set PYTHONPATH=C:\Program Files (x86)\Quantum GIS Wroclaw\apps\qgis\bin it ...
2
votes
1answer
317 views

How to upload a shapefile to geoserver using cURL and replace file?

In the sequence of this: How to upload a shapefile to geoserver using cURL? which was properly solved, I now need to be able to replace the existing file, cause my process is to be repeated every ...
2
votes
1answer
520 views

How to add a progress bar to a python plugin?

I would like to add some type of progress bar to my Qgis python plugin. Can someone point me to an example?
2
votes
1answer
100 views

Listing installed QGIS plugins via PyQGIS

Can you please tell me how I can programmatically (or from the console) access the loaded plugin list? I tried: QgsProviderRegistry.pluginList() but got: TypeError: ...
2
votes
1answer
331 views

python multiprocessing error in QGis (Windows)

I have this error when I try to use Manager() from python multiprocessing library. (Just start QGIS open Python console and execute the two following lines) >>> import multiprocessing ...
2
votes
1answer
271 views

How to get all attributes from a non geometry PostGIS layer with Python in QGIS?

I want to extract all attributes from a non geomety layer in QGIS with Python, but there is only the function uniqueValues(fieldIndex) More specific: I have a postgresql table which is loaded into ...