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

learn more… | top users | synonyms

1
vote
1answer
54 views

Locating 0-points multipart polygons using arcpy

By Running this piece of code: import arcpy arcpy.env.workspace = "C:\working\GEODATABASES\\tests.gdb" fcList = arcpy.ListFeatureClasses() for fc in fcList: with arcpy.da.SearchCursor(fc, ...
1
vote
1answer
66 views

Iterating over selected features in QGIS Processing

I used to be able to iterate over selected features using the following script in v2.0. import processing features = processing.getfeatures(layer) for feature in features: #Do whatever you need ...
1
vote
1answer
39 views

How to count the number of entries a user has selected in a multivalue field of a tool dialogue using Python and ArcGIS 10.2.1

I am currently creating a script that will read data in one (to many) Excel spreadsheet(s) and would like to know how to get a count of the number of spreadsheets entered by the user. The script will ...
1
vote
1answer
66 views

Raster calculation in for loop returning exit code -1

I've put together a python script that does some calculations on rasters by converting them to NumPy arrays, doing the math, then converting them back to Raster and applying all the same spatial ...
1
vote
2answers
113 views

How to create a Shapely LineString from two Points

If have two points, from which I want to create a straight LineString object: from shapely.geometry import Point, LineString A = Point(0,0) B = Point(1,1) The Shapely manual for LineString states: ...
1
vote
1answer
86 views

syntax error when using gdal in python console QGIS

When I run the following code in the python console in QGIS I get a syntax error: import osgeo.gdal gdal_rasterize [-b 1] [-burn 255] [-a Pixelkost] [-te 170000.2 168000.27 177999.8 177999.8] ...
1
vote
1answer
232 views

How to open a shapefile using Python in QGIS?

I have tried to open my shape files with the help of a tutorial (http://spatialgalaxy.net/2012/01/27/qgis-running-scripts-in-the-python-console/) but unfortunately I couldn't open my shapefiles for my ...
1
vote
1answer
52 views

Updating a Tool Validator Class from a CSV File

I have a CSV file which contains a list of clients and different project numbers and project names. This list is generated periodically. The list can contain multiple values for client name but ...
1
vote
1answer
61 views

pyshp problem with naturalearthdata-shapefile

trying to follow this example: https://code.google.com/p/pyshp/wiki/ShapeRecords entering the following code: import shapefile r = shapefile.Reader("ne_110m_admin_0_countries") sr = r.shapeRecords() ...
1
vote
1answer
61 views

Shapely WKT precision/rounding

I'm using Shapely's wkt.dumps function to get WKT from geometry objects. I can't seem to find a way to limit the precision of the coordinates. Any help is appreciated.
1
vote
1answer
78 views

Parsing metadata text files with Python

I am trying to use python to parse the .pvl metadata file from some GeoEye imagery. I would like to write a script that locates the productCloudCover and countryCode tags found within the .pvl. Does ...
1
vote
1answer
70 views

How do you set up XY Event Layer Parameters on ArcGIS Script Tool? (asking for user input)

I've made the XY Event Layer work through python script, but can't get it to work correctly as a python script tool on arc, asking for user input. Does anyone have any suggestions? This is the script ...
1
vote
1answer
68 views

My class using ogr to calculate distance is returning incorrect results away from the equator

In an answer to this question ustroetz kindly provided some sample code for use of ogr to do lat/lon distance and point in polygon calculations. I've created a Python class based on his example to do ...
1
vote
1answer
114 views

How to add the attributes of selected features to my new layer in pyqgis

I am trying to create a layer from the selected points coordinates. I am drawing a circle to the coordinate of selected points. I also need to add initial attributes of my selected features to my new ...
1
vote
1answer
99 views

Finding closest Intersection between line strings (PostGIS)

I want to find the distance between one point (excavation sites) and a line (rivers) for the cardinal directions. What I thought would be the easiest way is to draw lines between the excavation site ...
1
vote
2answers
125 views

Getting time dimension from a GRIB file

I have a GRIB file from NOAA that contains several variables for a specific subregion in Norht-East Atlantic. I'm using ECMWF grip-api Python library to parse the file. While I'm able to get the ...
1
vote
1answer
40 views

MakeXYEventLayer_management not creating final file?

I'm using python to generate x and y coordinates for the start and end of lines in Arc. I have successfully done this part but when I try and generate the nodes I have no idea where the output file ...
1
vote
1answer
265 views

How to create a dock widget correctly in QGIS plugin?

I am building a QGIS plugin and would like to use a dock widget. I have used QT creator to design the UI, with the object type being a QDockWidget. When the plugin is enabled in QGIS the dockwidget ...
1
vote
2answers
69 views

Separating a shapefile into separate shapefile based upon their features using a python script [duplicate]

I have a shapefile of a US. I need to make an individual shapefile for all the states in the US using a python in ArcGIS. How can I do it?
1
vote
1answer
124 views

Adding attribute list to combobox in a python plugin

I am developing a simple plugin at the moment which contains 3 combo boxes: comboBox_1 comboBox_2 comboBox_3 Combobox 1 & 2 lists the vector layers available, however I would like the 3rd ...
1
vote
1answer
45 views

Extract information of a raster overlayed on another raster with a lower resolution directly in python

I have two aligned rasters with the same extent, one has a resolution of 5 meters and the other of 125 meters. I would like to place the 5 meter one over the 125 meter one and assign to these smaller ...
1
vote
1answer
83 views

empty file geodatabase error (nowhere feature class)using arcpy [closed]

i want to import a python(2.7) script to arcmap 10.1 my script has 2 inputs variables one for workspace and another raster dataset and i want o convert input raster as feature class polygon . i want ...
1
vote
1answer
120 views

What do “count”, “mean”, and “sum” in QgsZonalStatistics mean?

I am working with Qgis and making some analytics of lightdata. I've used these commands: rasterfile = qgis.utils.iface.mapCanvas().currentLayer().source() vectorlayer = ...
1
vote
1answer
221 views

Import shp to Postgis using Python and ogr

I just export a Postgis Table to shp using this tips but I'm not able to import a shp to Postgis using the same library(ogr). Any idea? Thanks a lot f.
1
vote
1answer
77 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
34 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
361 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
172 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
89 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
162 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
84 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
96 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
158 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
41 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
305 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
420 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
79 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
159 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
95 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
243 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
164 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
183 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
51 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
92 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
89 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
2answers
220 views

Off by about 85 meters when converting NAD27 UTM to WGS84 lat/lon

Looking through other answers on converting to or from NAD27 CONUS, I don't see an answer that seems to fit my problem. I am creating paper topographic maps by layering information derived from USGS ...
1
vote
1answer
186 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
345 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
151 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
213 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 ...