Python is an open source interpreted programming language used in many GIS programs.
1
vote
0answers
43 views
Using Python to Switch Layout Templates
Using ArcMap 10.1: Since there is not a way to control portrait or landscape of the layout view through python, is there a way to switch layout templates without opening a new mxd through python? ...
2
votes
2answers
48 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. ...
3
votes
3answers
131 views
Field calculator error [duplicate]
NOTE: This problem is similar to one that was answered here: Why does Field Calculator return 0 values when decimals are expected?
I'm relatively new to python, and am trying to run a simple field ...
0
votes
1answer
70 views
Using the API of QSpatiaLite plugin
I am using the popular QSpatiaLite plugin for QGIS. Since I am creating and modifying SpatiaLite tables directly with Python (using pyspatialite), I wonder whether I can automate tasks such as ...
1
vote
1answer
108 views
Why does Add Field to Layer File give “ERROR 000840: The value is not a Feature Layer”?
I'm trying to add a field to a layer file, but it always gives an error. What I did was making a closest facility layer and save the result as a layer and after that I tried to add a field, but then ...
2
votes
3answers
114 views
SearchCursor() fails to read feature class
First of all, I would like to apologize if this problem is trivial for you guys since I am very new to ArcPy and Python in general. I want write a script to read attribute table from a feature class ...
0
votes
1answer
54 views
How to handle adding a PostGIS layer in pyQgis without saving password?
I'm writing python plugin and trying to find the right way to add PostGIS layer on the map without storing user password.
After adding layer on the map, I strip out the password from uri like this:
...
3
votes
0answers
60 views
Finding optimal network with python and network analyst in arcgis 10.0
Hello GIS StackExchange,
I'd like to know if there's any way to find the shortest distance across the diagonals of a polygon. I am creating a network analyst solution to determine the most cost ...
6
votes
1answer
118 views
How to address the new “Task-Completed” QgsMessageBar in Python?
I am really amazed what huge steps the QGIS development has taken in the last months. The new iconset, the improved Print composer and many more changes to be seen in QGIS 2.0 are really awesome!
...
2
votes
1answer
49 views
Script to either rotate existing text element or insert graphic element
I have about 300 maps that contain a text element that needs to be rotated. I am pretty new to python but I have heard how great it is. This seemed like the perfect task for python but I have had no ...
0
votes
0answers
34 views
Replace Null Values Field Calculator [duplicate]
I am using ArcGIS 10 and have a polygon shapefile in which many of the numeric fields are Null.
The polygon shapefile in question is produced by joining a polygon shapefile with a point shapefile and ...
2
votes
1answer
76 views
How to add one or more points to an existing polyline or polygon?
Using the following code, I make a polyline with two points.
vl = QgsVectorLayer("LineString", layerName, "memory")
pr = vl.dataProvider()
vl.startEditing()
fet = QgsFeature()
...
1
vote
1answer
59 views
Python GDAL: Write new raster using projection from old
If I read in a raster image as an array, then make some changes to the values in the array, how do I then save the array as a raster with the same projection information as the original array?
In ...
1
vote
2answers
165 views
Merging many rasters using Python
I have a list of many many rasters. I want to have a simple and easy to understand script that takes this and merges it into one big mosaic. I found a similar question but the accepted answer adivises ...
2
votes
1answer
134 views
Am I over-complicating adding and then calculating fields? Suggestions for a better way? (Python)
I'm attempting to re-position a question I asked yesterday here. I am starting to think that the way I wrote my code just isn't the best way. Am I overcomplicating things?
I know for a fact that ...
2
votes
1answer
40 views
Arcobjects: DisplayTransformation.FromMapPoint() transforms wrong
I want to transform map coords into page coords in ArcObjects in Python. So I do, say:
>>> pApp = NewObj(esriFrame.AppROT, esriFrame.IAppROT).Item(0)
>>> pDoc = pApp.Document
...
0
votes
1answer
51 views
How to save after using fet.setFeatureId in pyQGIS?
By using the following code, I want to change the id of the line when saving the line. But the setFeatureId command, gives a false when doing the commitChanges(). Any idea how to change the id?
vl = ...
3
votes
2answers
90 views
How to write an equivalent to MapBasic's CreateLine in pyQGIS?
I know this kind of question has been asked, in part, before - specifically: Seeing QGIS Python Commands and: How is object created as line using createline stored in .tab file?
but this is a specific ...
2
votes
1answer
98 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 ...
1
vote
1answer
78 views
How to store selected attributes of vector layer using PyQGIS
I'm following this PyQgis workshop:
http://www.qgisworkshop.org/html/workshop/python_in_qgis_tutorial2.html#accessing-data-attributes
I have a point layer shapefile. I want to be able to retrieve and ...
2
votes
2answers
99 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 ...
0
votes
1answer
98 views
How to clip raster by multiple polygons in multi rasters?
Using QGIS, I want to clip a raster by multiple polygons contained in a single shapefile. I read that gdalwarp can clip my raster by multiple polygons BUT the output is a single merged clipped raster. ...
1
vote
0answers
54 views
Is there a way to call the clip function in QQGIS from the python console?
Is there a way to call the clip function in QQGIS from the python console? It is found under geoprocessing tools in the vector menu.
0
votes
2answers
97 views
How to add a column in QGIS via python
I have a point shapefile and a polygon shapefile in QGIS
now I want to use the point shapefile's value add to polygon shapfile(be a column in the end)
there are colors with each value
and make the ...
11
votes
1answer
314 views
Teaching Python to Land Surveyors
Does anyone have any good examples of using Python to automate or simplify common surveying tasks?
I'm teaching a Python/ArcPy lab this week for a GIS class. There are a number of surveying ...
12
votes
1answer
228 views
How can I utilize NumPy arrays to optimize big data geoprocessing?
I'm interested in learning how to utilize NumPy arrays to optimize geoprocessing. Much of my work involves "big data", where geoprocessing often takes days to accomplish certain tasks. Needless to ...
-1
votes
1answer
96 views
How to write Process Dialog log information to a text file in ArcGIS?
I have created a custom model. When this model is run, it shows a process dialog which has some log information. I want to write that log information into the text file for further analysis. Does ...
0
votes
1answer
29 views
using ZonalStatisticsAsTable in python script
I use a python script in which the function ZonalStatisticsAsTable is called. In ArcGIS9.3 it all worked fine. Our company just went to ArcGIS 10.1 and now it doesn't work anymore.
When looking ...
1
vote
2answers
129 views
python - Calculate field with part of file name
So I previously successfully used the sample code here: Model Builder - How to calculate Field using part of filename
# Import standard library modules
import arcpy, os, sys
from arcpy import env
# ...
2
votes
1answer
88 views
Need help assigning values to field using OGR in python
I've got a similar question to this one How to programatically populate a shapefile field with polygon areas in OGR?, but the solution doesn't seem to be working for me. I am trying to import a ...
2
votes
1answer
62 views
Calculate field result is float with Arc tool, integer with arcpy script
I am trying to calculate a field for some points within a python script using arcpy functions. (This is calculating the percentage visibility from a cumulative viewshed, if that matters.)
# Process: ...
3
votes
0answers
99 views
Python Script Crashing Inconsistently on Arcpy Batch LayerToKML script
I put together a script to take a TIGER shapefile of all census tracts in a state, select the census tracts by each county, and export them into individual county-level kml files.
The problem is that ...
1
vote
1answer
29 views
How to calculate smallcircle on sphere
I use this python code to calculate a greatcircle:
https://code.google.com/p/pyroms/source/browse/trunk/pyroms/greatcircle.py?r=39
After initializing the greatcircle I can calculate points on the ...
1
vote
1answer
71 views
View HTML field data with QT4 browers as a QGIS Run Feature Action Tool
I've successfully populated a sqlite table with an HTML-encoded-table as a field attribute, and so there is literally a Table within a single field value in sqlite, for each record. This is going to ...
0
votes
0answers
30 views
Slicing / Cutting a Polygon / Polygon List based on another geometry
I currently use GeoDjango (GEOS, GDAL, PROJ4), I have rather medium set of polygon data (buildings).
To streamline them to a client efficiently (client has a limited viewport) I only want to send the ...
0
votes
1answer
46 views
Change ID for each line in vectorlayer in python
I am creating a vectorlayer with lines by doing this in python:
for i in frange(1, noOfPoints, 1):
polyLine = line()
polyLine.AddPoint_2D(minE,minN - addEastRange +(i-1)*linespacingEast)
...
0
votes
2answers
67 views
Python Addin Toolbar only works once
I am writing Python Addins for ArcGIS. I call a Python Toolbox, the Addin tool only works once in ArcCatalog when picked. If you pick it again nothing happens.
import arcpy
import pythonaddins
import ...
1
vote
2answers
80 views
How to change vector attributes values?
I want to change vector attributes values.
i could not get the command fet.setAttribute
indeed, it is mentionned in http://hub.qgis.org/issues/7223 that:
"The QgsFeature instance now must be ...
1
vote
2answers
150 views
PyQgis overwrite shape file and adding layer to Qgis
I am creating a shapefile in python by:
driver = ogr.GetDriverByName('ESRI Shapefile')
datasource = driver.CreateDataSource('c:/temp/toke2.shp')
layer = ...
0
votes
0answers
34 views
How can I use NZLoad using python or arcpy script?
I have CSV file which has millions of feature class record merged with some metadata information which I want to load into Netezza database. I have tried it using insert query but it is very very ...
0
votes
0answers
88 views
Help in GRASS/QGIS/Python
I have Idea about ArcGIS, and a bit of QGIS and zero programming knowledge, which I am trying for thesedays. I saw GRASS GIS and have started working with shapefiles, which are not being loaded... :( ...
1
vote
0answers
118 views
QGIS plugins with python dependencies [closed]
Problem: I have a Windows XP machine with Python 2.7.3 installed at ‘C:\Python27' and the scipy module installed at ‘C:\Python27\Lib\site-packages'.
I installed QGIS 1.8 recently and started ...
3
votes
2answers
58 views
How do I tell GRASS where to find Python?
For some reason, when I start GRASS on my Mac it says that it has found Python 2.6.7. However, /usr/bin/python version is 2.7.2 and I can't find a lower version anywhere on my system. Potentially ...
4
votes
2answers
103 views
Python Script to convert a mass of KMLs to a single fGDB
I have a mass of KML files, approx 350+ that I need in a single fGDB. I lifted a string of code from ESRI help to attempt to do this - I got it working to the point of creating all the individual ...
1
vote
1answer
87 views
Cast arcpy result as an integer instead (arcpy.GetCount_management)
I am trying to get a number by counting how many points are in a shapefile. And this works (I think), except I then am running into trouble using that number somewhere else. Eventually, I'll be using ...
2
votes
2answers
88 views
What Python package to use to calculate midpoint?
I asked a question earlier about how to calculate a midpoint. I was wondering if there is a Python library that does this alreay?
3
votes
0answers
108 views
Python coding question, looping through feature classes, AddField, CalculateField, then errors (might be schema lock)
This is not a SDE question. File GDB.
Hi, I have a general question on looping through feature classes in a file geodatabase. I have (attached) a python script that adds a ton of fields and ...
0
votes
0answers
93 views
Select record from table attributes in QGIS and Python
Can anyone tell how I can access to the attribute table of a shp and select a record from a specific row and column using Python (with console or a script). I've been looking for in the qgis API, but ...
1
vote
1answer
50 views
GeoDjango - Use GDAL python binding in the shell
I would like to use the GDAL python binding in my GeoDjango site. The aim of this is to use ogr2ogr capabilities in a script. I am on windows 7 so I have installed GDAL-1.9.2.win32-py2.7 downloaded ...
0
votes
0answers
59 views
arcpy Add Feature Class to Terrain error. LiDAR Processing Script
So here's another one for you ever so helpful StackExchangers (is that right?) Anyway, I'm writing a script to convert lidar data (in .las format) into a terrain without going through all the ...





