A version of the Python programming language

learn more… | top users | synonyms

7
votes
1answer
1k views

GDAL/Python: How do I get coordinate system name from SpatialReference?

In Python, using GDAL, I've extracted a raster's projection as a WKT string as follows: wkt = dataset.GetProjection() # wkt is ...
6
votes
2answers
565 views

Calling GRASS functions from external Python

I have GRASS 6.4.3svn installed in my machine running Windows 7. Also in my machine i installed Python 2.7.3 for Windows.Now i need to call GRASS libraries from Python and not within the Python shell ...
6
votes
1answer
340 views

Increasing speed of Python scripts using arcpy

Update 4/11/2014 It looks like the script was getting hung up on the Delete Features tool, so I switched to Truncate Table, as suggested in the answer below. I also removed the unused variables from ...
5
votes
1answer
329 views

How to do a separate Python installation with ArcGIS?

I see a lot of threads asking how you can have a separate Python installation (e.g. the Anaconda or Python XY distribution) and get it to work with arcpy, while not 'breaking' ArcGIS at the same time. ...
5
votes
1answer
1k views

How can I Setup Python to recognize QGIS

I want to use QGIS and work with Python out of the console, but I'm having troubles letting the system recognize the paths of some DLLs. Since I couldn't find a good answer on the web, I wonder if I ...
4
votes
1answer
90 views

ArcGIS 10.1 Anyway to make a script tool run immediatly upon opening

I have a script tool that creates an ArcSDE connection folder and copies data from the server to a new folder on the users computer. The tool has no parameters runs fine but when you open the tool it ...
4
votes
2answers
287 views

How can I define the layer CRS for a memory layer in pyqgis

how can I define the CRS for a memory layer from the qgis project settings vpoi = QgsVectorLayer("Point", "vectpoi", "memory") feature = QgsFeature() ...
4
votes
1answer
115 views

How to select all values by default in arcgis tool's multivalue parameter using python?

I am using ArcGIS 10.2 and have three parameters, Feature class, field and a multivalue parameter respectively in ArcGIS tool. I populate multivalue parameter with unique values of feature class on ...
4
votes
1answer
357 views

Issue on using Pyscripter with ArcGIS 10.2

Can someone please let me know how I can set the Pyscripter 2.5.3.0 x64 works with Python 2.7.3 which comes with ArcGIS? what I did was: 1- I installed the ArcGIS 10.2 2- I installed Pyscripter ...
4
votes
2answers
397 views

Gdal Python Bindings and File Geodatabase API

I'm trying to get python 2.7 to work with GDAL/OGR and an ESRI file geodatabase. There have been a few similar questions asked but the answers don't fully resolve my situation. I have installed the ...
4
votes
1answer
256 views

Personal shell launcher for PyQGIS

I have changed a shell launcher found at http://inasafe.linfiniti.com/html/id/developer-docs/platform_windows.html as to fit my wish: setting the system environment variables to be able to use PyQGIS ...
4
votes
1answer
357 views

Efficient computation of nearest distance for each point to closest polygon

I'm looking for a more efficient way to compute the nearest distance between features from 2 layers, in this example for each point the nearest distance to the closest polygon. Is there a more ...
4
votes
0answers
81 views

How can I create a form so the user has to be authenticated to access a project?

I have a login form in QGIS and when it is loaded, python gives me an error for, apparently, not recognizing the findchild part. This is due to the fact that the form isn't loaded before the script is ...
4
votes
1answer
200 views

Why does ArcGIS 10.1 Upgrade Geodatabase tool throw ERROR 999999: Error executing function?

I am trying to upgrade File Geodatabases using a Python script that runs fine until the step where it runs the Upgrade Geodatabase tool. The error is: "ERROR 999999: Error executing ...
3
votes
1answer
264 views

Arcpy Update Cursor (arcpy.da.UpdateCursor()) not saving changes to 'SHAPE@LENGTH'

Looked around and found other Cursor questions, but nothing dealing with updating 'SHAPE@LENGTH'. I am running ArcGIS 10.2.1 and have a multipoint shapefile that I am grouping into polygons based on a ...
3
votes
1answer
629 views

Import functions in python Add-In logic script

I am running into an error. I have a set of functions which I want to import in the python Add-In script at the time of execution, but when I built Add-In with "import stats" line then tools are ...
3
votes
1answer
294 views

Pasing multivalue parameter using arcpy

I am trying to get my head around how multivalues derived from the arcpy command GetParameterAsText gets looped through a script. Could some please provide a sample script that does the follow basic ...
3
votes
1answer
141 views

Using update cursor in a while loop to perform analysis on individual polygons gets stuck on first row

I am working through an open courseware project from PSU found at https://www.e-education.psu.edu/geog485/node/145 I am trying to use an update cursor in a while loop to perform an analysis on ...
3
votes
1answer
603 views

How to style a layer from console?

I am new to the QGIS python console. I am trying to load a raster layer from the console, set the crs and a specific style from a qml file. layerPath = os.path.join(raster_dir,raster_name) fileInfo = ...
3
votes
1answer
74 views

Reading zipped ESRI BIL files with Python

I asked the question below on StackOverflow, but haven't received any feedback there yet: I have precipitation data from the PRISM Climate Group which are now offered in .bil format (ESRI BIL, I ...
3
votes
2answers
327 views

Concatenate only when all fields to be concatenated have values

I have two fields that I want to concatenate. Field1 contains null values and Field2 has values for every record. I want to concatenate only when both fields have values. I tried using a function ...
3
votes
1answer
57 views

Conditional formatting for Advanced Label Expression in ArcMap

I am trying to do some conditional formatting in order to highlight specific criteria. The main error I keep getting is that there are no features found. I've done a simple label with the exact same ...
3
votes
1answer
347 views

ArcGIS 10.1 Python Script tool wont read string variable in SQL statement [duplicate]

I am working on a simple script tool that selects features from a .shp and creates a new output with only those features. Basically the user specifies(from a drop down list) the county and the ...
3
votes
2answers
4k views

Read specific column and row value from a text file using Python [closed]

I have a text file as following: 1.25 177. 1.50 220. 2.00 272. 5.00 427. 10.00 556. 25.00 763. 50.00 916. ...
3
votes
2answers
570 views

How to draw rectangle to clip layers using python addin in ArcGIS 10.1?

I want to clip rasters in data view using interactive rectangle (to define Area of Interest) and add them to current dataframe. Following is a piece of code which is not returning anything. Any ...
3
votes
3answers
353 views

Sqlite, Python 2.7 and Spatialite

I am trying to spatially enable my sqlite database: import sqlite3 db = r'c:\temp\mydata.sqlite' conn = sqlite3.connect(db) conn.enable_load_extension(True) cur = conn.cursor() cur.execute(r"SELECT ...
3
votes
2answers
308 views

How to control state of buttons in Python Add-In?

I have bunch of buttons to perform separate tasks within a Python Add-In. Buttons are greyed out and required to be enabled after initial tools run. In the following example, tool1 is turned off after ...
3
votes
1answer
115 views

Where can I find a python GDAL 1.8.0 package?

I have python 2.7.4 installed on my RHEL 5 machine along with gdal-devel-1.8.0 and gdal-1.8.0. I tried to install the GDAL 1.9.1 package available on python's page ...
3
votes
0answers
85 views

How to extract zipped shapefile and check its shape type using arcpy module without writing on disk

I have a zipped shapefile saved on my disk. I want to extract it in memory and check the shape type. I'm using arcpy module and want to stick to only default modules comes with python installation. I ...
3
votes
1answer
145 views

Can folder connection in ArcMap Catalog window be added using python?

I have created a set of general scripting tools for map automation etc. in one of my tools a geodatabase is created in the workspace folder the script points to. Just out of curiosity is there any way ...
3
votes
0answers
95 views

Why are my raster mean and standard deviation -1?

I have a set of about 25 rasters whose descriptive statistics I have been examining. The data in the rasters were calculated in Python and the rasters were created using Python-GDAL. In all but one ...
3
votes
0answers
199 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 ...
2
votes
4answers
55 views

How to Add (+) up integers in a field and print a total count in pyhton 2.7

I'm a complete beginner to python. I have what I hope to be a simple question. I want to run a bit of script in IDLE so that it adds up all figures in a table under attribute name "Tot_Aff". When I ...
2
votes
2answers
1k views

Combining Python and QGIS out of console

I was wondering if it's possible to use Python and QGIS out of QGIS environment (namely, avoiding the use of the console). I'm pretty new to QGIS, I've been always using ArcGIS 10.1. What I am looking ...
2
votes
3answers
80 views

How do I insert the string field and calculate it in Python?

Hello I am trying to insert a code that force a column Sum_Acres_ to add a comma to display like this 300,000 from 300000.456 Here is my sample I wrote from a ModelBuilder and export it to python. ...
2
votes
1answer
127 views

Field Calculator: return two or more field value

I trying to return three field values in same If Statment and conecate them, but i Get NULL value insted of the conecated fields getClass (!InDiameter! , !OutDiameter! , !TheridDiameter!, ...
2
votes
1answer
299 views

Python getting area of multipart features with SearchCursor()

I am tasked with programatically getting the area of each individual part of a multi-part feature. I have a script already to read each individual part and print its XY coordinates and it works fine ...
2
votes
1answer
93 views

How to declare folder name as global?

I have asked similar question at stackoverflow but posting here as well since it involves ArcGIS and python Add-In. Following code shows first step where i have to declare output folder as global so ...
2
votes
2answers
73 views

python add fields that may have NULL values

I would like to use python to calculate a field (short integer) using other fields (short integer) present in the table. In some cases these fields may have NULL values for one or more of the fields. ...
2
votes
1answer
59 views

ArcGIS 10.1 Upgrade Geodatabase Check Version

Hi I am trying to check the version of filegeodatabase before upgrading to 10.1, I have a list of file geodatabases and some of them are already in 10.1. Can anyone suggest me how to update only those ...
2
votes
1answer
284 views

OGR Python bindings

When I try to access one of the GRASS vector files through Python OGR bindings, it gives error: Here is the script code in Python 2.7.3 IDLE (GUI) in Windows 7. from osgeo import ogr ds = ...
2
votes
1answer
144 views

Why does ogr's CreateLayer() return None?

Why does ogr's driver method CreateLayer return None? I'm using python 2.7 with gdal 1.9.1. path = r'D:\_tempAuto' out_shp = '%s\test_OGR.shp' % (path,) driver = ogr.GetDriverByName('ESRI ...
2
votes
2answers
369 views

Automatically download Modis image using python script

I need download Modis imagery automatically from the website: https://earthdata.nasa.gov/. I found this link: http://gis-techniques.blogspot.com/2010/06/getting-modis-image-automatically-from.html ...
2
votes
1answer
43 views

How to determine if a raster has rowattributes?

I have a raster file which is the result of extract by mask geoprocessing tool. If it has no rows then I take it as no overlap between input raster and shapefile. Following is the way I am reading it ...
2
votes
1answer
33 views

raster landuse calculation

I want to calculate the counts of each landuse type based on the unique landuse code from each raster datasets. Raster dataset consists of six major landuse and their unique codes are below: 1) ...
2
votes
2answers
354 views

Run Python child script using Python Add-In button class?

I have a Python script which I want to execute using Python Add-In button class. Right now, I am using following: class child(object): """Implementation for Toolbar_addin.button2 (Button)""" ...
2
votes
2answers
302 views

Quick way to make a convex hull

I am using Python and ArcGIS 10.1. Is there a function or very quick way to extract points out of point feature class into an array without looping through a search cursor (as I have millions of ...
2
votes
2answers
399 views

Help with Python and adding a grouplayer to arc, renaming it from a folder name, then adding layers to it from that folder

I am trying to use os.walk to go through a directory tree, pull out all the .shp files in it, create a grouplayer in the mxd, rename the grouplayer the folder name, then add the layers from that ...
2
votes
1answer
341 views

Python Script that calls the Voronoi Polygons Function?

I've been looking to see if there was a way to call Voronoi Polygons function found in Vector/Geometry Tools, directly from the code but I have not found one. Does this currently exist? Is there a way ...
2
votes
2answers
132 views

Invalid Username When Developing a QGIS Plugin on Mac

On a fresh Mac OSX 10.8 install, I've installed Quantum GIS from Kingchaos binaries and it's running fine. I'm trying to develop a plugin for QGIS using Plugin Builder. The skel that Plugin Builder ...