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

learn more… | top users | synonyms

1
vote
1answer
648 views

import qgis.core problem with QgsFeature and QgsGeometry

I've tried several previous answers to similar questions - no luck. I run Win7. I installed QGIS 2.2.0 using the OSGeo4W 32-bit installer. Problem 1) from qgis.core import * failed. Solution 1) ...
1
vote
1answer
106 views

ogr2ogr/python overwrite PostGIS table

Using ogr2ogr command line I can overwrite or append to an existing PostGIS table like: ogr2ogr -f "PostgreSQL"-overwrite PG:"host=myserver port=54321 user=user dbname=mydbname password=mypassword" ...
1
vote
1answer
37 views

How to refer to a variable from the conditional statement in the ExtractByAttributes function in ArcGIS 10?

Trying to use the ExtractByAttributes for rasters so that I have multiple attribute values that I want to extract. This works fine: myraster = arcpy.sa.ExtractByAttributes("source_raster", "VALUE IN ...
1
vote
2answers
840 views

From coordinates find country using Python

I have tweets with coordinates. I'm trying to bucket the tweets by country using the coordinate information. I know that I can achieve this using some hosted web services but all of these have API ...
1
vote
1answer
296 views

How to plot street addresses and streets using Python/GIS?

I asked this on stackoverflow but did not get a really clear answer. I am not really familiar with GIS systems in python. I am looking for a library to do the following: Lets say I have a pandas data ...
1
vote
2answers
149 views

How to form SQL Expressions with mix of integer/numeric and text/string fields/values in ArcPy?

I am trying to create a query for the select by attribute function within a Python script.This is my current code. lot = '96' dp = 756421 lotFile = ...
1
vote
1answer
213 views

Why does OGR driver.Open() for File Geodatabase give AttributeError: NoneType object has no attribute Open?

There are a number of existing Questions that hint at a possible Answer to this Question, but none seem to be providing me with the solution to my problem: How to access feature classes in file ...
1
vote
1answer
101 views

Delete Turned Off (Unchecked) Layers from Arcmap with Python

I have about 100 figures that have been updated countless times and a lot of the old data was left in each .mxd but was only turned off (unchecked) and not removed. I would like to remove these ...
1
vote
1answer
137 views

create a pie shaped object in shapely and export to gis polygon object

I would like to create a pie chart-shaped polygon with concentric layers like so: I can create this simple object with: from math import sin, cos, radians from shapely.geometry import ...
1
vote
2answers
183 views

Iterate Through All Combinations of Features by Selection in ArcGIS Python Script

I have question about ArcGIS and python script. There are following sample code, So I would like to change Another Field , not OIDFieldName. Please let me know how to change Another Field. import ...
1
vote
1answer
51 views

How to read the count of the cells with data with non “no-data” values ,in QGis?

How to read the count of the cells with data with non "no-data" values ,in QGis
1
vote
1answer
478 views

Read and Export OSM Road Data as a Network of Road Segments [Adjacency Matrices]

I wish to extract from an OSM file a road network, and export it as an array (adjacency matrix) where the nodes are the road intersections and the edges represent the road segments. I don't want to ...
1
vote
1answer
791 views

OGR Layer Intersection

I am using what I would describe as the most primitive method of doing intersection with OGR. The short script below describes how I do it. Is there a best way of doing this? from osgeo import ...
1
vote
1answer
85 views

python scripts for accessing info from a postgresql database in case of a qgis application?

I am beginner and I need to know if I could access a postgresql database from python script made for a qgis application
1
vote
1answer
230 views

using GDAL/python to stack georeferenced images of different sizes

I am in the process of porting a code I wrote in IDL (interactive data language) to python but am running into a bit of a problem that I am hoping someone can help me with. The code goes like this: ...
1
vote
1answer
153 views

Map Layout Elements In New Layer Automated Using Python

I was wondering if there was a way to put a title and integer data from an attribute table in a new layer created in Python. I was able to create a new layer using copy features, zoom to the selected ...
1
vote
1answer
361 views

Why does ListLayoutElements give IndexError: list index out of range?

When trying to create a legend on ArcMap use the following Python/ArcPy code I received an error message: import arcpy mxd = arcpy.mapping.MapDocument(r"E:\cities\MyProject.mxd") df = ...
1
vote
1answer
242 views

Why am I getting “sequence size must match size of the row” error?

I'm trying to use an Insert Cursor to insert a point geometry into an existing point feature class. I'm finding the coordinate and appending them to a list called rowValues, ex: ...
1
vote
2answers
247 views

How to calculate peaks in a DEM

How could I extract all peaks from a DEM (large mountainous area)? Peak means something like: a pixel which is sourrounded by other pixels with smaler elevation numbers in a area arround the ...
1
vote
1answer
56 views

Is there a programmatic way to swap attributes on a feature?

I am still pretty new to python (and programming for that matter) but I believe there must be an easier way to do a certain task. My task is to flip road centerline directions. The centerlines have ...
1
vote
2answers
111 views

Difference between OGRGeometry and Geometry in C++ and python

According to the documentation, there is a python version of OGRGeometry's C++ class (http://www.gdal.org/ogr/classOGRGeometry.html) which is http://gdal.org/python/osgeo.ogr.Geometry-class.html ...
1
vote
1answer
94 views

Irrational feature ID behavior in a PyQgis script

I've written a script to determine the coordinates of a point shapefile and insert them into its attribute table. It works perfectly when the ID sequence of the indiviual features begins with 0, yet ...
1
vote
1answer
252 views

GDAL polygonize only certain raster values

I want to polygonize a raster file with GDAL. I only want to rasterize cells with a value of 0. Is it possible to specify that within the polygonize function or do I have to modify my raster before ...
1
vote
2answers
500 views

ArcGIS 10.1 crashes on use of python window

When I open the python window in either ArcMap or ArcCatalog (ArcGIS 10.1) as soon as I press a key it freezes the entire program and it crashes. It doesn't produce any warning, error, or pop up with ...
1
vote
2answers
181 views

No prj file output from qgis:reproject

I'm trying to reproject a vector layer using the 'qgis:reproject' algorithm in the processing/sextante module of QGIS, from Python. This kind of works, but the .prj and .qpj files created after ...
1
vote
1answer
288 views

Select by SQL in QGIS Python

In the GUI there is the Query Builder, but that does not seem to be easily available in Python. The processing (SEXTANTE) module has the qgis:selectbyattribute algorithm, but that only supports ...
1
vote
1answer
204 views

Cursor Update Python Script for Multiplying Several Fields against a Ratio (Real) in ArcGis

Disclaimer: Python Neophyte, Uber-reliant on GUI, working to wean... I have a Python script for replacing multiple Field values with another table value that was graciously provided by the inimitable ...
1
vote
1answer
297 views

Python scripts execution in ArcGIS Runtime WPF app

DEAR PEOPLE FROM THE FUTURE: Here's what we've figured out so far… I am facing a quite interesting requirement: "run python scripts within an ArcGIS Runtime app". checking the concepts in the ...
1
vote
1answer
153 views

Writing array to vrt

I would like to write an array from a single band image to a 3 band vrt where each band has the ColorInterpretation() tag of red, green, blue respectively. My code below; from osgeo import gdal ...
1
vote
1answer
61 views

How to select pixel with smallest number in stack raster using Python script in ArcGIS for Desktop?

I have 6 tiff file in ArcGIS which are identical in term of geometry (same frame, same number of row and column). The pixel value of each tiff file is integer and range from 1 to 4. So if I overlay ...
1
vote
1answer
339 views

ArcGIS 10.1 Converting a model tool to a script tool

I have recently created a model tool for a class project and my instructor would like it to be converted to a script tool for practice purposes. I have exported the script from my model and loaded it ...
1
vote
2answers
388 views

How do you get all the results from a Selection made by Attribute or Location using ArcPy?

Using arcpy I'm trying to get the results of a selection, or what is currently selected as a list. Basically I'm attempting to build an addin which on click will either perform an operation where I ...
1
vote
2answers
200 views

Using a different projection to calculate areas using the Field Calculator

I have a dataset that is in a WGS84_UTM projected coordinate system, can I force the Field Calculator to use another coordinate system when I use it to calculate areas using pythons ...
1
vote
1answer
151 views

ArcGIS, Edit Layer Extents with Python script

I would like to read and edit the Extent Values of each Layer in a MXD-file. My code: import arcpy mxd = arcpy.mapping.MapDocument(r"D:\Work\myInFile.mxd") for lyr in ...
1
vote
1answer
75 views

Field does not get updated with Geoprocessing Service

Can anybody tell why the field gets updated when I run this script in ArcMap but not when I run a geoprocessing service? Thanks #Import modules import os, sys, arcpy, traceback, arcgisscripting gp ...
1
vote
1answer
142 views

How to add ArcPy Feature Layer to ArcMap automatically?

With Python, how do I get either the MakeXYEventLayer_management or the MakeFeatureLayer_management layer that is temporarily created added to ArcMap automatically after the tool is ran, without using ...
1
vote
1answer
643 views

Subsetting a curvilinear netCDF file (ROMS model output) using a lon/lat bounding box.

I am attempting to get salinity data from one of the ocean models in our region and have run into a roadblock. This is ROMS model output in NetCDF form, but the grid is curvilinear (lon and lat arrays ...
1
vote
1answer
825 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. ...
1
vote
1answer
169 views

OGR: How to best use GetFeature on a selection?

I think the following is very confusing sel_str = "ND_14 = '108'" l.SetAttributeFilter(sel_str) l.GetFeatureCount() >>> 1 In a for-loop this gives me for f in l: g = ...
1
vote
1answer
385 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 ...
1
vote
1answer
172 views

How to get Quantum GIS display a line or polygon feature created by Python package pyshp

I am not sure if I have discovered a regression, or if I have not enough sleep. While I manage to create shapefiles with point geometries with pyshp, line and polygon features don't show up in QGIS. ...
1
vote
1answer
338 views

Help with formatting ArcGIS text elements with Python

I'm struggling with a formatting issue that comes from inserting text into a Text Element object in ArcGIS using Python. I want to print a table of values of which all but the last column are numbers. ...
1
vote
1answer
40 views

How to export Std Dev from Raster Dataset of DEM to classify current extent and execute Contour Tool with Python?

I want to create Countour Lines for a DEM which are based on a "STD dev" classificaion. My problem is that the "Std dev" is exported in an unknown type instead of a String. So the classifacation for ...
1
vote
2answers
527 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 ...
1
vote
1answer
170 views

How to make a virtual layer from ogr geometry?

I know how to do this: nodes = driver.Open(node_nav,0) node_lyr = nodes.GetLayer() node_lyr.SetSpatialFilter(None) But how do can use the layer methods on a geometry I created from scratch? ...
1
vote
1answer
116 views

Export some specific pages from data driven pages to pdf file by python

I need to export pages 14, 13, 23 and 24 of 26 pages of data driven pages to pdf file by python and then add the pdf file to the final pdf file by arcpy (python), any help please?
1
vote
1answer
84 views

How to create point features from 1-Many relationship?

I have an address point shapefile for buildings in a city. The point shapefile shows only a single point for each building; apartments are listed in a table called additional addresses. I need to ...
1
vote
1answer
135 views

Python: Grabbing X,Y coordinate from matching fields

Here is my table. What I am trying to do is write a python script to go over the Zip_Crid values. If there are matching values, I need to grab x1, y1, x2, y2 and put it in a new field. Haven't ...
1
vote
1answer
90 views

Stop custom attribute form from resizing in Qgis

When I open a custom attribute form for a feature in Qgis it always gets resized to the default size of the original Qgis attribute form. I've tried to set the sizePolicy in QT Designer to Fixed ...
1
vote
3answers
1k views

How can I translate Modis HDF To GeoTiff

I've a MODIS04 L2, and I want to extract band 8:Image_Optical_Depth_Land_And_Ocean. I use Quantum GIS to open this band, because Quantum GIS see this is not coordinates so this allow me to select ...