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

learn more… | top users | synonyms

2
votes
2answers
201 views

image segmentation of RGB image by K means clustering in python

I want to segment RGB images for land cover using k means clustering in such a fashion that the different regions of the image are marked by different colors and if possible boundaries are created ...
1
vote
0answers
39 views

rasters written with gdal show up with units of meters when they should be degrees

I have some SMOS soil moisture data packaged in a netcdf format distributed by "cp34-bec". I have been able to use GDAL to extract this data as a raster layer, using a projection i think is ...
2
votes
1answer
29 views

Redirect remote shell command output to ArcMap geoprocessing tool display?

I have a Python script that runs a shell command on a remote server (using the Fabric module). When I run the tool in the debugger, I see all the output scrolling, as the command can take hours to ...
0
votes
0answers
32 views

why did my python mysql script stop working, with error on fetchone()?

This code was working a couple weeks ago, then without changing anything, it started throwing an error. Here's the code: #Query climate table sFrom = dateIncrement.strftime("%Y-%m-%d ...
1
vote
1answer
40 views

Python: how to set a different output folder

I want to transform some vectors to rasters in my folder but I have difficulties setting the output folder. The following code only allows me to output to the original database. I hope to output all ...
1
vote
0answers
47 views

PyQGIS Standalone Crashes python.exe when zooming out too far / Process finished with exit code -1073741819 (0xC0000005)

I have the following PyQGIS Standalone App which is working fine so far. One little problem is that if I zoom out to the MaxExtent(by scrolling the mousewheel) the app crashes python.exe so that the ...
2
votes
1answer
40 views

Error: Algorithm not found (QGIS)

I wrote the following code using QGIS'API. import os from qgis.core import * import qgis.utils prefix_path = os.environ['QGIS_PREFIX_PATH'] QgsApplication.setPrefixPath(prefix_path, True) ...
2
votes
1answer
46 views

How to add a message bar to custom canvas?

There is a simple code to add message bar to main window in QGIS: iface.messageBar().pushMessage("Hello","World") My question is how to add bar to my custom canvas canvas = QgsMapCanvas() in ...
1
vote
0answers
79 views

import qgis.core problem with QgsFeature and QgsGeometry ImportError: DLL load failed: The specified procedure could not be found

I've tried several previous answers to similar questions - no luck. I've tried everything, nothing seems to work. This is the error I'm getting Traceback (most recent call last): File ...
0
votes
0answers
27 views

Pythonw has stopped working when running arcpy.SubsetFeatures_ga

I'm currently trying to subset a shapefile into training and validation files. When I run the following line of code, python crashes. I'm using ArcGIS 10.1. arcpy.SubsetFeatures_ga(current_shapefile, ...
0
votes
1answer
35 views

Semi Automated Classification plugin (QGIS) error when trying to create ROI

When I try to create a new ROI through Semi-Automated Classification plugin (SCP) for QGIS, I keep getting a message saying: "It appears that SciPy is not correctly installed. Please, see this page ...
2
votes
1answer
25 views

problem deleting shapefiles because still in use by arcpy cursor [duplicate]

I have a function outputTblContents which contains def outputTblContents ( path ): rows = arcpy.SearchCursor(path, fields="alpha; beta") for row in rows: print("{0} => ...
2
votes
1answer
72 views

PyQGIS standalone script does not work. Error “QGraphicsScene::addItem: item has already been added to this scene”

I try to test a PyQGIS standalone script which should just show one Shapefile. Sounds pretty simple but does not work. Here is my script: from PyQt4 import * from PyQt4 import * from PyQt4.QtCore ...
1
vote
1answer
52 views

“Browse” button returns python error in QGIS

I use the latest version of QGIS (2.8.2) in MAC and have se the default Python version 2.7. Moreover, I have installed all the required python modules and GDAL. It was working before, but now, when I ...
0
votes
2answers
71 views

Remove first seven characters from field string using Field Calculator

I wrote an expression/codeblock that removes the words "Nearby:" from the field value string if it has it. Codeblock: import string def splitme(s): if s[:7] == "Nearby:": aList = ...
0
votes
1answer
42 views

Generating elevation 'database' from NED IMG data

I'm starting to work with the NED 1/3 and 1/9 arc-second data. I've been using gdal in Python and QGIS to do some basic conversions of the raw .IMG data from USGS. My goal is to get elevation data of ...
0
votes
2answers
53 views

Calculate field in modelbuilder

If vb code is also possible I could give that a try aswell.
1
vote
1answer
49 views

Adding Vertical Reference in Python to ArcGIS feature dataset

I am creating a python script to generate a terrain. In the process I am creating two feature datasets. However, in order to successfully create this FD, i need both horizontal and vertical datums. I ...
0
votes
1answer
40 views

Can't get the where clause in Select layer by attribute working!

I am trying to develop a script that searches for a particular ID in a user selected field. To this end I have used the select layer by attributes tool to search for a derived number in a field ...
0
votes
0answers
24 views

Is it possible to save a dxf in memory

Following on from my question here, when I run the ExportToCAD tool arcpy.ExportCAD_conversion(listOfLayers, formatRelease, location + fileFormat, "Ignore_Filenames_in_Tables", ...
1
vote
1answer
72 views

How to differentiate between land and sea in python?

I'm going to plot some positions of ships, and thus see which areas (out at sea) where there is no vessels, however, if I do this in an ordinary geographical area defined by a square, all the land ...
1
vote
0answers
92 views

Using gdal_merge to merge a large amount of files (in pairs)

I'm new to python and how it can be applied to gis. I have a large amount of MODIS files to go through and I've already extracted, reprojected and converted to GTiff the bands that I need from each ...
1
vote
1answer
66 views

Setting PYTHONPATH for compiled QGIS version on Linux

I'm trying to set the PYTHONPATH in order to be able to load the qgis classes in a python console (not the QGIS Python one). I followed some resources I've found (PYQGIS Cookbook, and others) but I ...
1
vote
1answer
89 views

How to register “events” for linear referencing in pyqgis?

Is there an easy solution for recording events for a line crossing borders of zones in a polygon layer? I need to implement this in python using QGIS, thus pyqgis. The image attached illustrates what ...
1
vote
1answer
107 views

How to select polygon features that intersect a line feature using pyqgis?

Is there an easy way to select all features in a polygon layer that intersect (overlap) a line feature? I need to implement this in python using QGIS, thus pyqgis. This code illustrates what I am ...
0
votes
1answer
43 views

Get Data for ArcPad extension and python

Is it possible to call the 'Get Data for ArcPad' extension using python? If so would someone be willing to share their code?
3
votes
3answers
75 views

How do I compare two features to test if they are identical?

What is the most efficient method for determining if two features (points, lines, or polygons) are geometrically identical? I'm not concerned about a square figure that contains eight vertices (four ...
1
vote
2answers
36 views

Adding new field and populating with shapefile name

I have a set of shapefiles that need a new field adding to them called "Policy_Ref". I then need to update this field with the shapefile name. However when I do, it uses the full title, including the ...
1
vote
1answer
34 views

What tool would be best for getting the max value out of Identical ID rows?

As the title may imply I want to keep the maximum value in field2 for several identical IDs in field1, the others are deleted for example this table: Field1 Field2 14772 1 14772 4 14766 3 ...
7
votes
1answer
312 views

Python toolbox works in ArcToolbox and in Python console, but not in ArcCatalog

I have a set of Python tools in a Python toolbox (.pyt). They are broken into multiple files and modules and have been functioning correctly, but now I'm seeing inconsistent behavior on multiple ...
1
vote
0answers
20 views

Accessing elements Linestring and points from a DGN file and displaying both layers on QgsMapCanvas

I am using PyQGIS APIs to develop a standalone application which currently display's map data layers on QgsMapCanvas from .shp, .tif, .dgn files. I am able to do it for .shp and .tif but not for .dgn ...
0
votes
0answers
28 views

Implementation of script for bus waiting stops

I've tried to add waiting time in bus stops in several ways (elevation fields, sub-segments, etc), but nothing worked. I'm now trying to use this script I've found in Internet: if (SourceID of ...
2
votes
3answers
160 views

Using .len() in IF THEN statement in ArcMap field calculator

I have a string field with values of varying lengths (1-4). I need each value to have a length of 5 characters by adding zeros to the value until the length equals 5. For example: 123 needs to ...
3
votes
1answer
47 views

add text value to attributes

this is a novice question I have an attribute field that's missing a piece of information, i'd like to amend the attribute field like below: This is the current attribute field: "V:\Building & ...
2
votes
1answer
45 views

Landsat Surface Reflectancce product Python packages

I have to work with numerous Landsat surface reflectance product that I downloaded from http://landsat.usgs.gov/CDR_LSR.php. The product comes with a QA data with information on clouds and shadows ...
0
votes
2answers
59 views

Applying symbology to a layer with python, How to only have symbology in TOC that the sub layer has

i am trying to apply a symbology to multiply layers that i have created from one feature class. The original feature class is used to create several sub layers see layer loop this involves using ...
2
votes
2answers
125 views

QGIS/Python script to generate random points many times

Good day. Can anybody provide a simple code to be run in the Python Console of QGIS (I am using 1.8 Lisboa) to generate X number of random points (say e.g. 5000) over a certain global shape of ...
1
vote
0answers
43 views

If then statement in model builder

I have a model that adds several fields, two which are manual inputs (County Name and User). I am manipulating several parcel layers (approx 90 counties). In my model, one field takes the state and ...
2
votes
2answers
61 views

Map canvas overlay layers QGIS

I built my own map canvas inside a plugin in QGIS and I want to add two layers (one by one) in order to overlay the two. I have this code: fileCI = "....\plugins\teste\test.shp" fileInfo = ...
1
vote
2answers
68 views

ignore Null Values when iterating through fields with python

So far I have a code which iterates through Fefature Classes and ignores all fields of type String, Geometry and OID. I now try to add some lines which tell python to ignore all NULL values when ...
1
vote
0answers
48 views

import qgis geoprocessing tools in python os x 10.9.5

I'd like to use the python bindings from qgis, but in a standalone project. I need the geoprocessing tools for vectors. I updated QGIS (Wien - 2.8), python (3.4.3), etc. However, it always ends with ...
1
vote
0answers
59 views

QGIS python originalName() does not return actual original layer name

I am writing a Python QGIS Plugin, using QGIS version 2.6 as the basis for development. When loading data into the canvas programmatically, I am trying to maintain the spatialite table name as the ...
1
vote
1answer
77 views

What resampling method is used in gdal_merge?

I am using the gdal_merge python script to merge rasters that have slightly different, though similar, input resolutions. The documentation advertises that it can handle different resolutions, and in ...
1
vote
1answer
41 views

Labeling layers with Python in QGIS. LinePlacementFlags

How could I set LinePlacementFlags with Python in QGIS? My code is something like: palyr = QgsPalLayerSettings() palyr.readFromLayer(layer) palyr.enabled = True palyr.fieldName = "attribute" Then ...
1
vote
0answers
52 views

How to automatically generate pour points along stream network?

The following screenshot shows the results of a water flow analysis where I identified stream order via the Strahler method in ArcGIS. Now I need to generate watersheds for 2nd order streams and ...
0
votes
1answer
65 views

arcpy.da UpdateCursor where_clause

I am trying to get a where_clause working on a UpdateCursor (arcpy.da). I can get it to work fine with a SearchCursor, but for some reason the same clause throws a RuntimeError: General function ...
2
votes
0answers
67 views

Using Python to iterate through directory to create event layer and perform kernel Density for each file?

I am new to Python for ArcGIS, but have been using ArcGIS a while. I have a large directory of tables with point data. For each file of each folder I want to create a kernel density layer. I have ...
1
vote
0answers
34 views

Execute GRASS command within qgis phython console

We try to calculate catchments with the r.water.outlet function from python console. To do so we use the following code: import processing rlayer = QgsRasterLayer("/my/path/DrainageDirection.tif", ...
1
vote
1answer
55 views

If/then python for classifying existing field values to a new field

I'd like to have a tool or quick python script to classify an existing number field to a new text field. For example I have a roads layer that has a type identifier as a coded number and I would like ...
0
votes
0answers
61 views

Configuring Python to avoid conflict with ArcGIS for Desktop (ArcPy)?

I am trying to find the best way to configure a new version of python in my computer (windows) so that I do not have any problem with the python version that I have with ArcGIS. Is there anyway to ...