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

learn more… | top users | synonyms

6
votes
4answers
991 views

Code to open web browser crashes ArcMap when run from a Python add-in

I created an ArcMap Python add-in using ArcGIS 10.1 to open a webpage after the map is clicked. It opens the page but then ArcGIS crashes. import arcpy import pythonaddins import webbrowser class ...
3
votes
2answers
179 views

VB Script or Python for Field Calculator when using greater/less than?

What I have: I have 4 fields for my address ranges. L_ADD_FROM, R_ADD_FROM, L_ADD_TO & R_ADD_TO (all in DOUBLE field type). What I need: The lesser value from L_ADD_FROM and R_ADD_FROM to ...
3
votes
3answers
1k views

How to measure minimum distance between objects in two layers using arcpy?

I am working on an alien species analysis looking at the spread of a species from the mainland to islands in an archipelago. I am doing the analysis using arcpy and I have succeeded in isolating risk ...
0
votes
1answer
127 views

40k+ points from Shapefile, clustering them and populating on Google Maps/Webapp

I just started a new Python/Django webapp job related to GIS (and i'm totally new to GIS). Here is my task and what i have found so far, and i am stuck as to finding out what's the best way or the ...
0
votes
0answers
29 views

How to query a WMTS layer with a point layer in QGIS?

With the "identify" tool it is possible to query WMTS layers. Then, you can copy the acquired attributes and afterwards the clicked coordinates, then create a CSV file with attributes/coordinates. Is ...
1
vote
0answers
45 views

How can I extract the measurelength, highmeasure and lowmeasure of routes in ArcGIS

I'm trying to create road Routes in ArcGIS, which traditionally have been created using workstation. I've managed to write a Python script to do this, however, unlike ArcInfo, the attributes ...
3
votes
1answer
312 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 ...
1
vote
0answers
23 views

Odd Error in Metadata Script

So I developed a script that traverses through a root directory, and any subdirectories and catalogs layers files. Then exports these layer files' FGDC metadata and outputs them to a folder. The code ...
3
votes
2answers
63 views

How to trigger a Python script from an ArcGIS Desktop “save” operation?

Similar to the question Run a Python Script when opening an MXD, I'm looking for a way to run a Python script that is triggered when the "Save" command/button is pressed. I've read the Creating a ...
5
votes
1answer
156 views

How to create a python plugin in QGIS 2.4.0?

While I am learning to create a python plugin in QGIS 2.4.0, I have followed the proceedure expalined in ...
1
vote
3answers
58 views

Calculate field management not working within customized Python tool in ArcGIS

I am trying to make a custom made Python Script tool which I would like to use in Model builder. I am using the arcpy.Calulate_field_management function (simple reclass function as an example), but it ...
1
vote
1answer
39 views

ArcMap: Unknown Spatial Reference fix with GDAL/Python

I have a .tif file that I created with Python and when I open it in ArcMap it says it doesn't have spatial reference information. Is there a way to set the spatial reference with GDAL if I have a .prj ...
3
votes
2answers
166 views

Spatial Classification

I am not sure what to call my problem. From this image, I have a set of classified polygons (colored). I would like a way to classify the white polygons in the image. I don’t have any attributes to ...
1
vote
0answers
83 views

How to create an expression using the arcpy.SearchCursor? [closed]

Example: On the basis of the table which is not defined by the number of columns and rows, you need to evaluate expressions as shown, using the arcpy.SearchCursor .... First, create a list of ...
0
votes
0answers
23 views

How to merge grd files programmatically, ideally in Python?

We currently get LIDAR data from the field in grd format. Sometimes this data is overlapping. This data gets fed into a python program that does some analysis. What I'm after is some way of ...
5
votes
1answer
810 views

Python equivalent of gdalbuildvrt

Is there a way to perform the same task as the gdalbuildvrt utility using GDAL Python bindings? So far I have not found any way to do this other than creating a vrt of a single dataset and manually ...
1
vote
0answers
33 views

QGIS actions - get currently selected attribute column (with python?)

I'm trying to open files dynamically through actions. A simple example would be: Action name: OpenLink from PyQt4.QtCore import QUrl; from PyQt4.QtWebKit import QWebView; myWV = QWebView (None); ...
0
votes
1answer
51 views

Running Grass7 in a conda environement

I have Anaconda Python Distribution (Python 3.4.3 :: Anaconda 2.1.0 (64-bit)) installed on Ubuntu 14.04. I would like to create a conda environment for running Grass 7. To do that I used: conda ...
0
votes
1answer
61 views

Inserting row into table and then updating it in sum of each column using ArcPy?

My problem is the following: I have a table with an unknown number of columns (n) Use arcpy.ListFields create a list of columns and generates Field name list Then, using arcpy.da.InsertCursor create ...
2
votes
1answer
172 views

Is it possible to run a search cursor on a multipart feature class?

I have a multipart feature class of cities. I want to run a search cursor on a cities feature class where: one city is selected and a select layer by location is run to select all parcels that are ...
0
votes
2answers
80 views

ArcGIS field calculator: Calculating a new field using multiple fields with python

Basically, I have a large polygon data set that has soil data for an area and I want to assign numeric values to the data based on soil texture text values (e.g. SIL=4, CLY=7, ...). However, the soil ...
0
votes
0answers
23 views

Password Caching in ArcMap using Oracle accounts

The issue I'm looking for help with is that we have several Oracle accounts through which we host data. For example we have ACCOUNT@ORAC and ACCOUNT1@ORAC (these are made up names as I don't to ...
5
votes
2answers
237 views

Cancel event in Python Gp tools with arcpy

In GP-tools written in C# (ArcObjects) we can listen for the Cancel-event and react on that. I wonder if there is anything similar in Python GP-tools applying arcpy. I googled that issue and the only ...
1
vote
1answer
18 views

Trouble updating attributes of a layer based on another layer's attributes if features intersect in python, QGIS

I am trying to assign attributes from features in one layer that intersect features in another layer. When I run my code, I do not get an errors but it does not update the attribute field as I am ...
0
votes
1answer
96 views

Grass 7 on Ubuntu 14.04. Can't start Grass

I attempted to install GRASS GIS 7 on ubuntu 14.04 using these instructions. When I call grass70 from the command line I get a welcome message and a prompt to continue. I then get two error messages: ...
3
votes
2answers
61 views

Calculating unique ID value for a field in QGIS using python

I am trying to calculate a unique ID field for a vector layer in qgis, using python. I found some code to calculate attribute values, and tried to increment the value in the expression, but it doesn't ...
1
vote
1answer
37 views

Trouble importing NumPy in GRASS. Architecture

I can't get GRASS to work on my system, and after doing some digging I think it is related to me using 64-bit python. I'm not really sure. I get this message... This module requires the ...
1
vote
1answer
41 views

Get a point value with psycopg2 and PPyGIS

I'm trying to setup a basic working postgis setup with python ppygis package. >>> import psycopg2 >>> import ppygis >>> connection = psycopg2.connect(database='spre', ...
21
votes
6answers
899 views

How to buffer raster pixels by their values?

The pixels to the left represent tree locations and their associated crown radii (i.e. pixel values ranging from 2 - 5). I would like to buffer these raster pixels by their crown radius value. The ...
0
votes
1answer
37 views

window map (in pixels) given a window size (in miles) for a particular map resolution

i'm a noob when it comes to gis so just had a quick question. i searched for this question...and it seemed like the questions were arcgis specific. i'm using python and basemap for my analysis. ...
3
votes
2answers
192 views

Is there a function to select a region of a map for further processing with Python?

I would like to select a map's region in QGIS for further processing with python console. Ideally I would like to select the region with a mouse drag (like Gimp crop function) and then e.g. analyze ...
1
vote
1answer
63 views

how to find that two polygon boundaries are connected?

I am working on a Geo database where there is a layer with many polygons. i want to find that which polygons boundaries are connected so that i can create new layer from that polygons and which ...
1
vote
1answer
34 views

Exploding multipart features in qgis using python [duplicate]

I want to explode a multipart layer to singlepart in python. I see through the qgis gui there is a way to do it under vector--geometry--tools--Multipart to Singleparts.. which does what I need, I just ...
1
vote
1answer
84 views

How to store attribute values from a custom form into shape file?

I have created a custom form (for mapping bird species in the field with different attributes like species, type of observation, number of birds, date, ...) with some python logic. One important ...
0
votes
0answers
18 views

Refreshing QGIS view [duplicate]

I've written a short python script for use in QGIS (currently using 2.8.1) to set the CRS for all loaded layers to OSGB 1936 / BNG. The script correctly sets the CRS but I have to manually scroll ...
1
vote
0answers
19 views

Merge CSV file to Vector Layer using common attributes in QGIS python scripting [duplicate]

I have a vector layer and a delimited text (csv) file -- they both have the common attribute attribid -- how can I add the columns of the csv file to the vector layer merging on the the attribid key ...
1
vote
1answer
34 views

Trouble buffering a vector layer in QGIS with PyQGIS

I am working on a script that imports a .csv layer that has lat long coordinates, which I then want to buffer in feet. I've created a vector layer from the .csv file and tried to set the coordinate ...
4
votes
0answers
49 views

Python IDE complete code autocompletion [closed]

I am seeing that code completion in both PyScripter and PyCharm is not complete, compared to the code completion you get in the interpreter window. In PyScripter, if you add arcpy to the code ...
2
votes
1answer
204 views

How to use SAGA ShapesToGrid via Processing in a Python plugin?

I run these lines in my code: vectorlayer_vector = ftools_utils.getVectorLayerByName(inputLayer) Elevation = self.lineAttrib.currentText() cellSize = int(self.linePix.value()) outPath = ...
3
votes
1answer
72 views

Intersecting lines get crossings

I have a set of lines representing bus lines. Some of the lines are overlapping and take the same roads. I am able to extract the nodes. However I am interested in extracting only crossings like ...
3
votes
1answer
47 views

pymodis download issues

I'm trying to download and process MODIS imagery using pymodis. I have Python 2.7.8 (Spyder), numpy 1.9.1 and gdal 1.11.1. I've also installed WXPython. I originally tried to use the ...
2
votes
0answers
193 views

Link QGIS to Anaconda Python Distribution: Spyder, iPython Notebook, pip, scikit-learn

I have Anaconda as my primary Python distro, and want to route Python related QGIS scripts through it. With Anaconda, I have Spyder, can easily install packages with pip, and can launch a iPython ...
2
votes
1answer
79 views

Using ArcPy to Read from Excel Spreadsheet to Python Dictionary

How would I go about creating a script that reads a specified excel spreadsheet and places the values in a dictionary? I have read about the xlrd library and how the library in such endeavors to read ...
2
votes
1answer
418 views

Help with scripts for processing raster files with the raster calculator in QGIS

I am trying to process some raster files using python scripts in Qgis 2.20, and I have been having trouble finding any documentation on using raster calculator in scripts being run in the processing ...
1
vote
1answer
54 views

Python Code for generating random points not working!

I am trying to create some code to generate 10 random points within a vector layer's districts: layer=iface.activeLayer() import ogr import sys import random from shapely import wkb, geometry ...
6
votes
1answer
288 views

How to compute Straight Skeletons using Python?

Is there a Python package which provides an implementation of a Straight Skeleton algorithm? I'm aware that the open source (C++) project CGALcontains an implementation but it seems like ...
1
vote
1answer
28 views

Getting error in running ExportReport Python code in ArcMap

i am unable to generate pdf report using ExportReport function of Arcgis 10.2. getting error of IOError: Could not open report template tried different template files but still getting this error. ...
1
vote
1answer
67 views

arcpy.da.UpdateCursor - How to update last column from Field Name List?

examples: for field in arcpy.ListFields(fc): if field.name != 'Hi': arcpy.AddField_management(fc, 'Hi', 'FLOAT') else: print "kolona Hi vec postoji" with ...
2
votes
1answer
516 views

Converting Tab to Shp Using OGR2OGR with Python on linux

First i downloaded http://svn.osgeo.org/gdal/trunk/gdal/swig/python/samples/ogr2ogr.py and i am importing this. How can i get ogr2ogr to run in my script? nothing seems to be working and i not sure ...
0
votes
1answer
642 views

OSRM API - nearest point fed into routing

I am using the OSRM API to (1) determine the nearest point on a road segment from a give random point with http://server:5000/nearest?loc=_lat_,_lon_ The returned coordinates are used then as an ...