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

learn more… | top users | synonyms

1
vote
1answer
35 views

GRASS scripting for producing multi-band raster

I am trying to loop the r.sun function within a Python script. Anyway, I seem not to understand how I can stack the raster maps each loop would produce into a single multi-band raster (preferably in ...
1
vote
2answers
41 views

How to take cosine squared of raster using python

I have an equation y = cos^2(x) where x is a raster. How can I write this equation in python?
1
vote
1answer
89 views

ExecuteError: Failed to execute. Parameters are not valid. ERROR 000732: Layer Name or Table View: Dataset L does not exist

Hi I am trying to create a loop so that each layer is produced in its own map. This is my code: import arcpy path = "C:\Users\Et\Documents\ArcGIS\Default.gdb" mxd=arcpy.mapping.MapDocument(path ...
1
vote
1answer
80 views

Could not open/read USGS raster file

I could not open/read the following .img file. The document below says it is a raster file. http://edc2.usgs.gov/1KM/land_sea_mask.php I tried to open it using many ways such as Q-Gis software, and ...
1
vote
1answer
24 views

To count the number of grid cells in a polygon

Is there a way ArcGIS could count the number of 15 seconds interval grid cells within a polygon after digitizing that polygon. This should appear in a field in the attribute table.
1
vote
2answers
51 views

Store result from gdallocationinfo as variable in python?

I'm trying to find the cell value at various locations in a set of rasters so I can count the number of real values (aka not 'NoData') that occur at all the locations within each raster. The various ...
1
vote
1answer
52 views

How to get coordinates of line

I am working on Qgis python console. I want to draw a line in the center of two parallel lines..For this purpose firstly i have to store the coordinates of those two lines in a variable so i can apply ...
1
vote
1answer
40 views

Issues with FME and the ArcInfo licence

I have ArcInfo 10.2.1, Python 2.7 and FME 2013 SP4 installed on my Computer. I want to run a python script I exported from ModelBuilder (where it ran without issues) and imported in FME as shutdown ...
1
vote
1answer
146 views

Importing file geodatabase (GDB) to table of contents (TOC) of ArcMap?

I have a geodatabase with several feature dataset and feature classes associated with it respectively. I would like to create a .mxd where the Table of contents consist of group layer and each group ...
1
vote
1answer
59 views

Creating multiple Feature Datasets from table/list using ArcPy?

How to Create multiple Feature Datasets from a table/list. I can create a single feature dataset in a geodatabase with this python code. import arcpy from arcpy import env env.workspace = ...
1
vote
1answer
50 views

QGIS raster calculator using abs() function

Is it possible to use the Abs() function in the raster calculator in QGIS? I've tried it, but it didn't work.
1
vote
1answer
40 views

Handling KML/CSV with geopandas - DriverError: unsupported driver: u'CSV'

I'm trying to import a dataset of UK postcode districts UK postcode districts from Google Fusion tables into geopandas with the aim of splicing it to a dataset of house prices. The problem is that ...
1
vote
1answer
63 views

Extract Values to Points between rasters and point shapefiles of the same name

I have a task of extracting raster values to point shapefiles, which is simple enough, but only where the raster filename is identical to the shapefile. For example, I have shapefiles "G1", "G2", ...
1
vote
1answer
48 views

Problem with variable for arcpy.select_analysis whereclause

I have a problem with the whereclause on python for arcpy.Select_analysis. I try to use a variable for condition: for row_stat in rows_stat: % for calculated the variable"maxi" ...
1
vote
1answer
80 views

Cannot load postgis layer from sql string in pyqgis

I'm trying to load a layer using the following code in qgis python console: sql = "(select the_geom, ID from mytable)" uri = QgsDataSourceURI() ...
1
vote
1answer
181 views

How to merge Shapefiles from multiple folders into Geodatabase Featureclass?

I have a question regarding the merge of a lot of folders, which has a lot subfolders, which has the shapefiles stored. I would like to merge all those in one geodatabase. So I thought to use a ...
1
vote
1answer
29 views

Adding some background information to a layer

I have 2 Python Qgis plugins. The first plugin is creating a QgsVectorLayer via the ogr dataprovider. The second plugin is offering some services on the features in the layer. I need to pass some ...
1
vote
2answers
72 views

Is there any efficient way to create a raster with pixel value representing a unique id calculated based on pixel lat/lon?

I have 10m raster for each state in US. Current pixel value represents something. I want to have 'same' raster but pixel size representing a unique id calculated based on pixel lat and lon. I am ...
1
vote
1answer
67 views

Summary statistics on attribute table

I've got a polygon feature class with attributes fields y2010, y2011, y2012, y2013, y2014, country The 'year' fields contain counts of an event occurrence, which can be 0 or > 0. The 'country' field' ...
1
vote
1answer
56 views

Convert list of coordinates to OGRGeometry or WKT

I am using a Visvalingam-Whyatt simplification script and the output is a list of coordinates such: [[[[-10885205.10690245 3525662.26531131] [-10885369.01690829 3525374.0741439 ] ...
1
vote
1answer
72 views

Python Geospatial development book error?

I am currently reading Python Geospatial Development by Erik Westra but I am stuck at the first hurdle where the book suggests that the easiest way to install gdal onto a windows machine is using ...
1
vote
1answer
48 views

Controlling Python Version from ArcGIS?

I am writing a VB.net console application that calls ArcGIS Desktop 10.1 ArcToolbox geoprocessing tools from my code. Some of these tools use Python syntax and I am encountering a problem that I ...
1
vote
2answers
148 views

How to merge dbf files(zonal statistics as a table) in GIS environment.?

I am not very savvy at using Python. Actually I have around 1000 output files from using the tool zonal statistics as table in ArcGIS. The names of the files are jan_60, feb_60......dec_13. These all ...
1
vote
1answer
184 views

Erdas python scripting help

I want to write scripts for Erdas in Python. I downloaded some Python examples here but I could not make much. Where can I get the full Help material for Erdas python scripting?
1
vote
1answer
152 views

How to create an Erdas batch list file (.bls) using Python?

How can I generate the Erdas batch list file (.blf) using Python? For example, I want to run a 5x5 median filter in the Batch Command Editor using a subset of images within a folder. Erdas provides ...
1
vote
2answers
85 views

Cropping aerial image using Python?

How can I crop an area from an aerial image knowing the latitude and longitude of the image's corners and also the cropped section? I have a LiDAR scan and I and want to crop an image overlay to fit ...
1
vote
1answer
50 views

How To Turn Off Map Drawing When Using Python in ArcMap?

I have a Python script that creates layers in ArcMap. The script works fine, but when a new layer is created a map is always automatically drawn, which makes the script take longer to process. I ...
1
vote
1answer
73 views

How to get a Layer as ILayer (ArcObjects)

I had asked this question previously which I think will work. But as I am new to this, I can't figure out how to get a Layer as an ILayer object to pass to the method that's in my previous questions ...
1
vote
1answer
77 views

How to use Fields in the Field Calculator? [duplicate]

I'm using the Field Calculator in ArcMap and I need to create a unique ID for every storm drain in my county. An ID Should look something like this: 16-I-003 The first number is the municipal number ...
1
vote
2answers
107 views

Set parameter of field from number to string with python

since I realised python is a very useful tool in ArcMap I dont want to do any workarounds anymore. I have a field with is numeric, but I want to perform this calculation in the field calculator on it ...
1
vote
3answers
124 views

Merging many to one data rows in arcpy [duplicate]

The dataset 'left_right_merge' at the bottom of my screen shot shows the dataset that I'm currently working with. The NODE values indicate a single point feature, but is duplicated with many ...
1
vote
2answers
95 views

csv to shp python and formating a row

I´m doing a script to convert csv to shp, but I want to format one of the columns. It´s a string then I´d like to format like this a[8:10]+' / '+a[11:16]+' UTC' being a the value in the column. ...
1
vote
1answer
139 views

Creating a Simple Join Script in Python

I'm trying to create a simple join script in python from an arcgis model, where the only steps are joining a map to a table to produce a map with the table's properties. The attributes joined ...
1
vote
1answer
208 views

How to make a Python script that does a task in QGIS?

When I run this code in QGIS Python console it works fine, but I want want to run it from an external Python script. What I want the script to do is: 1- Open QGIS 2- Run this code 3- Close QGIS from ...
1
vote
2answers
129 views

Open source, Python option for Arcpy's Con tool?

I'm wondering if there is a method to perform a function similar to Arc's Con tool, using open source options in python. I have two rasters, one that shows locations of clouds and the other is just a ...
1
vote
1answer
81 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
80 views

Error: Algorithm not found

I wrote the following code to start using QGIS APIs. in a very short script seen below, the "Error: Algorithm not found" is thrown and "print processing.alglist()" is showing none. Any idea why this ...
1
vote
1answer
156 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
54 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
148 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
248 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
136 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
481 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
74 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
91 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
112 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
186 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
171 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
107 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
254 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 ...