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

learn more… | top users | synonyms

9
votes
1answer
202 views

The role of '#' in a python 'if':

I recently exported an ArcGIS model to python and was reviewing the script and am confused by the following line: if TRU_W_DatableFeatures == '#' or not TRU_W_DatableFeatures: I can't seem to find ...
6
votes
1answer
892 views

Python equivalent of gdalbuildvrt

Is there a way to perform the same task as the gdalbuildvrt utility using GDAL Python bindings? So far I have not found any way to do this other than creating a vrt of a single dataset and manually ...
3
votes
2answers
735 views

How to filter out multipart polygons and then buffer?

I've written a small script trying to accomplish the task described in the question title. It basically looks like: in_fc = '...' # Some shapefile goes here # Get the fields (column names) of the ...
5
votes
1answer
411 views

How do you fix Overlapping Lines?

I have a line dataset that contains some lines where the "end points" are actually found in the middle of the line. In the image below, the nodes are shown in green and one of the end points in red. ...
5
votes
1answer
399 views

Error using con in Map Algebra in Python script

I am experiencing a painful problem in the middle of a Python script I am writing. When I get to a Map Algebra function, I have tried two different options and both return a different error. At first ...
4
votes
1answer
1k views

How to create polyline of varying distance from origin point using azimuth?

I am looking for a Python script that does the following: Uses a point (from a point shapefile) as the origin. Creates about 3 km line from point Based on an azimuth provided in the original point ...
2
votes
1answer
343 views

Getting SAGA-GIS Python Bindings without compiling from source

I am very new to SAGA-GIS, but I recently developed a workflow using SAGA for processing LiDAR data. Now I need to batch the process using Python. I installed SAGA from the Windows installer and I ...
5
votes
1answer
1k views

Dissolving specific polygons inside SearchCursor with Python in Arcmap

I have a layer with catchment polygons. For those that are smaller than a certain size, I want to merge with an adjoining polygon (namely the one downstream). In the attribute table I have a GridID, ...
1
vote
0answers
95 views

Why does the method partCount in ArcGIS always give back a value of 1?

Does anyone knows why method "partCount" in arcgis version 10.0 always gives me back value 1, even when I have object with interniorring or multipart object? partnum = 0 partcount = feat.partCount ...
3
votes
2answers
267 views

ArcGIS Calling Wrong fme.exe When Python Script Converted To An ArcGIS Script Tool

I'm using this this bit of code to execute a FME Workbench file through a Python script ... import os os.system("fme.exe P:\\Mapping\\Scripts\\FME\\Easements_ROW_Extract_From_CAD.fmw") However, ...
5
votes
1answer
2k views

How to Make a New Shapefile Based on Attributes of an Existing Shapefile?

In my last post I had an issue where I wanted to create multiple shapefiles based on only one attribute field (years). How to do it was answered in that post. I want to make that tool more dynamic so ...
0
votes
3answers
2k views

Why is SQLite python command not working?

I am fairly new to python and am writing a code to read imagery and insert them into an SQLite database but I get the following error cur.execute(statement, (index,fullpath,filename)) ...
2
votes
1answer
270 views

automate color palette generation?

I frequently am in need of color gradients that aren't readily available through ArcGIS or the ColorBrewer add-in. I find the process of manually creating gradients in Arc very tedious: saved custom ...
2
votes
1answer
118 views

How to get empty gdb using python

I have one gdb with lots of layer (~500) and to receive empty gdb I delete all records from layers. I Use deleterows / TruncateTable but for one layers take abaut 1-3 minuts. Is better way (faster) ...
1
vote
1answer
96 views

sa.fill creates NoData raster in standalone script ArcMap 10.0

I am trying to put together a geoprocessing workflow in Python, and I've hit a stumbling block with sa.fill. When run as a standalone script, the tool produces a raster composed entirely of NoData ...
2
votes
3answers
1k views

Creating new shapefile based on its attributes with python

I have a shapefile which has an attribute year. I used to generally copy and paste these features in the dataframe and then using the definition query just show polygons which were established before ...
3
votes
0answers
484 views

Batch Converting ASCII into Feature Classes using shapefile lists [closed]

Problem. I have 413 ASCII files totalling 4 billion points, and my system cannot handle converting them to MULTIPOINT so that I can generate Terrains. Therefore I would like to create 12+ subsets of ...
4
votes
1answer
422 views

How to best organize files for a large arcpy script tool?

I am writing a lengthy arcpy tool and am working with multiple python scripts, simply for organization's sake. Everything runs well when I run it from the command line, but now that I am starting to ...
4
votes
3answers
3k views

Why does arcpy.ImportToolbox() not work in ArcGIS 10 (SP5) when calling custom model for topology?

I have an arcpy/python script using ArcGIS10 and using a custom toolbox and model. The toolbox has an alias of defaultTopo and my model within the toolbox is called AddRuleToTopologyModel. This model ...
5
votes
2answers
1k views

Why does this simple Python OGR code create an empty polygon?

Please excuse my ignorance...I am new to Python OGR. I am trying to create a simple square polygon and fail...this produces an empty polygon. Where did I go wrong? from osgeo import ogr driver = ...
6
votes
1answer
354 views

How to detect a GDAL/OGR 'Warning'?

When I run a batch script using a GDAL/OGR program, I can detect if an error occured by checking ERRORLEVEL for the value 1. When using GDAL/OGR in python or .NET, I get an exception when an error ...
5
votes
1answer
1k views

Python: find a method to calculate the “inner centroid” (also known as labelPoint in arcmap) of a polygon

i am looking for a method to compute the X,Y coordinate of a inner point (also known as labelPoint in arcmap) of a (irregular) polygon. I am try to find a solution without the use of ArcGIS module ...
2
votes
1answer
490 views

arcpy.AddMessage and codepage problems

Some times in my tools I need to output Cyrillic text via arcpy.AddMessage function. Previously in 10.0 it was very easy. I had .py file of the tool saved in UTF8 codepage. This code wrote messages ...
7
votes
2answers
946 views

Does QGIS have something like the MS Office macro recorder?

I would like to use python console in QGIS to automate tasks. Is there something like a macro recorder in MS Office to get the python commands?
5
votes
2answers
1k views

How to create a shapefile consisting of 2 lines using Python OGR?

How would you create a shapefile consisting of 2 lines using Python OGR? First line is no problem, but how do you reuse MyLine and Feature objects to create the second line? Ultimately this will ...
6
votes
3answers
259 views

Are there any open source Python modules compatible with arcpy that will allow complex SQL queries?

I am trying to handle string (non-geometry) duplicates in a large attribute table of a shapefile without having to convert to gdb and back or connect to a postgres db. I need to be able to use a count ...
4
votes
3answers
426 views

Is there anything faster than a cursor in ArcGIS to calculate records?

What is the most efficient (fastest) way to calculate records in a layer in ArcGIS? Is there anything faster than the Cursor in ArcGIS?
1
vote
0answers
471 views

How do I find the pgAdmin connection parameters?

I need to create a connection from arcmap to pgadmin using a python module because of an arcpy script, but I am unsure of how to get the pgadmin connection parameters. I think it may be some kind of ...
2
votes
1answer
400 views

How do I select * rows of multiple columns in one query using Select by Attributes within ArcMap?

I am trying to convert a psql query string into arcpy formatting for an UpdateCursor where expression parameter: '''SELECT ...
3
votes
2answers
311 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
756 views

How to pragmatically upload a shapefile to geoserver using cURL? I'm having problems

I'm building the curl command in a python script, but when I run the script I get this error: * Connected to localhost (127.0.0.1) port 8081 * Server auth using Basic with user 'admin' > PUT ...
2
votes
2answers
688 views

Python: “Import Script” greyed out

I have a tool that I created from a Python script which I update from time to time. Usually I will right-click the tool and choose Import Script, but lately this has been unavailable, as shown below: ...
0
votes
0answers
157 views

Can I do full SQL expressions through the “WHERE” clause in UpdateCursor?

Run as a standalone python script for a shapefile in a toolbox on ArcMap. For example: psql_url_pop = '''SELECT shapefile.NAME_# + shapefile.WIKI_URL FROM public.shapefile''' rows = ...
3
votes
1answer
656 views

How to hide/show QGisVectorLayer from Python code?

Once created a layer, how can I hide/show it? I can enable/disable rendering of a specific layer by selecting the checkbox through QGIS, but I need to do it programmatically from python code. How can ...
3
votes
2answers
195 views

Where can I get public transportation route information for USA?

I'm trying to find a list of public transit route information, mainly location of bus and train stops for the US. I've looked around at some of the Google products and openstreetmap but can't find ...
1
vote
2answers
109 views

Distribute gridded data to corresponding subbasin boundaries?

I have one ArcGIS shapefile of my river basin consisting of many subbasin. Another shapefile showing the location of gridded points over the whole basin (Its latitude and longitude are used as file ...
3
votes
3answers
645 views

How to make Field Value constant size(length) by appending zeros towards the end?

I have been racking my brain, but I can't seem to find a solution to appending my field values in my .dbf to correspond with the values of my feature's attribute table. All I need to do is to append ...
2
votes
1answer
958 views

rtree python polygon index

Sorry for a very basic questions about rtree. I would like to check whether the point is inside the polygon and the distance (point to the nearest point in polygon) as well. I was thinking about ...
7
votes
3answers
2k views

GDAL and Python: How to get coordinates for all cells having a specific value?

I've got an Arc/Info Binary Grid---specifically, an ArcGIS flow accumulation raster---and I'd like to identify all cells having a specific value (or in a range of values). Ultimately, I'd like a ...
4
votes
1answer
358 views

Is it possible to run an arcpy execute SQL method without connecting to any database or server?

I want to simply process a layer by writing a tool script in a toolbox without having to connect any database, so I think I may have to set up a workspace environment in ArcMap, but I'm not sure if I ...
1
vote
0answers
278 views

How does QGIS execute Python plugins?

I am trying to run a python script from within a python plugin. The script runs a CGIHTTPServer in a separate thread. It works as expected when executed from the command line and i can issue requests ...
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
2answers
927 views

How do you create a button in ArcGIS and have it run code?

I'm brand new to ArcGIS and have only a year or two of programming experience. I know Java and a little C#. I have a Java app that processes geographical data. I need to have a button in ArcMap that, ...
18
votes
3answers
6k views

How to call gdal_translate from Python code?

Is it possible to use some gdal API to call gdal_translate from Python code? I do not mean simply executing the gdal_translate.py from the file system, but rather call it somehow in code so I do not ...
1
vote
1answer
572 views

How to change cursor shape in pyQGIS?

I noticed that PyQGis has QgsMapToolPan() and QgsMapToolZoom() functions, and the cursor shape on the canvas will change to a hand (for pan), magnifying-glass(+/-) (for zoomIn / zoomOut). I have a ...
2
votes
1answer
321 views

Why shapefile loaded in canvas always appear in random color?

I created the simple frame .UI file, compiled with pyuic4, and tried the ShapeViewer.py to load the shapefile "world_borders.shp". However, the map is always loaded in different random colors every ...
2
votes
0answers
196 views

projection discrepancy with gdal (1.9) and proj4

I boiled the problem down to that python example: import sys try: from osgeo import gdal from osgeo import osr except: import gdal import osr if __name__ == '__main__': version_num = ...
11
votes
2answers
6k views

How to export only certain columns to a CSV file in ArcGIS?

I've written a python script using arcpy which outputs a polygon feature class into a File Geodatabase. I have added a function to export the attributes to a separate CSV file. I am using the code ...
5
votes
1answer
1k views

How to remove a vector QgsVectorLayer from QGis python plugin

I managed to add QgsVectorLayer in QGIS through a python plugin, for example: vl = self.iface.addVectorLayer(uri.uri(), layerName, self.dbConn.getProviderName()) But how can I remove 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 ...