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

learn more… | top users | synonyms

3
votes
2answers
346 views

How to generate Buildings ID numbers inside parcels

In order to decrease manual data entry, I would like to automate a task to generate numbers for all buildings inside a parcel starting with 1. For example, I have 4000 parcels and each parcel has ...
2
votes
1answer
60 views

“unexpected indent” in the script

I'm using a QGIS 2.8 in windows 10. I have 2 scripts that are working separately but when I write both in just one script, it doesn't work. The 1st script is to load one raster to QGIs with a defined ...
3
votes
2answers
49 views

Distance Matrix of two datasets

I have two datasets of the same adresses, one geocoded with Google, the other with Nominatim. Now I want to compare address1 of dataset1 with address1 of dataset2, then address2 of dataset2 with ...
3
votes
1answer
141 views

How to add loading bar in QGIS Plugin development?

Every time i use tool or plugin in QGIS, i saw a kind of bar like this for indicating loading progress : The different between that bar and Progress Bar is that progress bar will increase until our ...
2
votes
2answers
322 views

Refreshing display for newly added labels with ArcObjects from Python?

I've added a shapefile to an MXD and Edited the symbolization of it with ArcObjects. Now I'm trying to edit the labeling with ArcObjects. I've successfully been able to edit the default class in the ...
1
vote
1answer
26 views

How do I get the feature from a single-feature OGR layer in Python without looping?

A while ago I asked why the 0 index in a OGR layer was not a feature and it turned out that OGR interprets the index as Feature ID and looks that up. Now I filtered a layer to have only one feature ...
1
vote
0answers
26 views

How to automatically run some scripts for QGIS python console by defining the python macros checkbox

I'm working with QGIS 2.8 in windows 10. I've defined the python macros checkbox to QGIS start and simultaneously run a script that has the same path from my "QGIS.qgs" file. In the Project>Project ...
1
vote
1answer
115 views

Closing QGIS custom form programmatically?

I have a custom form for entering and editing attribute values of a point shape file. I also added a button for deleting the actual feature. Deletion of the feature works fine and then I want to close ...
5
votes
2answers
301 views

Build Network Dataset with python comtypes

I know this isn't possible in arcpy, so I thought I'd give it a stab using comtypes. I am trying to translate some of the VB.NET code to create a network dataset from the help docs: ...
3
votes
1answer
75 views

Script that runs automatically from the QGIS Python Console when QGIS starts, using schedule tasks on Windows 10

I'm working with QGIS 2.8 and windows 10. Is it possible that after open QGIS using the schedule tasks from windows 10, I could open the python console and run a script within QGIS programmatically. ...
4
votes
3answers
1k 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 ...
2
votes
1answer
42 views

Plot shapefile on top of raster using plot and imshow from matplotlib

I need to plot a shapefile on top of a raster. I would like to use the python package rasterio and some combination of fiona or geopandas to load the shapefile. I found an example in the rasterio ...
1
vote
1answer
34 views

QGIS - Get Bounding Box of Map Extent in Stand Alone Application

I basically have the same question as this one : How to quickly calculate bounding box coordinates of a selected polygon with qgis However I am building a stand alone application in python and so ...
2
votes
1answer
216 views

Python-gdal create geotiff from array with colormapping

I am creating grayscale, single channel geotiff files from numpy arrays with the below module, but I would like to apply a fairly standard colormap to the data. I've tried three channels of R,B and G ...
1
vote
1answer
35 views

Question about Using r.mapcalculator in Python console

According to the following conversation: Using r.mapcalculator in Python console? I tried: ##NoData Background=name ##RASTERLAYER_BAND=raster ##nodatabackground=output raster import processing ext ...
1
vote
1answer
193 views

Using r.mapcalculator in Python console?

I'm trying to use the r.mapcalculator algorithim in a python script, but I'm having problems in using the r.mapcalculator to tranform a raster layer with float values into integers. Using the ...
2
votes
1answer
589 views

Automatic calculation in one attribute table based on values in another attribute table using python

I am trying to fill the fields of one gdb table based on some statistics over the attributes of another shape file. As it was not possible in ARCgis directly, I am trying to use python coe for this ...
1
vote
1answer
71 views

Installing GDAL2.1

Here will be my sequence of command lines while trying to install gdal2.1 in a UBUNTU virtual machine. My virtual machine is a UBUNTU 16.04 LTS(64bit) I would need gdal2.1 and especially the Python ...
1
vote
0answers
47 views

How to implement a shoelace formula into Python 2.7.8 [closed]

Here's the image of the equation I'm using, it is a shoelace formula. I need help to point out what each variable represents and how to apply this in python script, math is not my strong-suit! From ...
4
votes
5answers
2k views

how to find close and parallel lines

I need help with script for QA of water network. I need to find all lines that are almost parallel and close to each other less then 2 meters. The script have 3 stages: add azimuth field and ...
4
votes
2answers
1k views

Select by attribute expression invalid in python

I'm not sure how my expression is failing. Any ideas? inPoints = "points.shp" i = 0 arcpy.MakeFeatureLayer_management(inPoints, "pts") arcpy.SelectLayerByAttribute_management("pts", "NEW_SELECTION", ...
0
votes
0answers
25 views

How to do a Python / Fiona / Shapely equivalen to an ESRI ArcPy SpatialJoin?

I'm a GIS noob, but I am trying to learn as quickly as I can. Please bear with me. How can I identify what structures from one layer are WITHIN in some body of water in another layer? My problem ...
0
votes
2answers
148 views

ArcGIS desktop won't import arcpy

I have arcgis 10.3 and I am trying to run a task using python but the python window within arcmap won't import arcpy. This never happened to me with 10.2.2. The error returned is: Runtime error ...
1
vote
1answer
215 views

midpoint of segments in QGIS determination

Gene thanks for your note on the problem yesterday ... This is a follow up to a question I posed before (How to find the middle point of a line in QGIS - Where to place input file name). Errors coming ...
3
votes
2answers
3k views

Conditional Statements in QGIS raster calculator?

What is the equivalent statement of the following expression in the QGIS raster calculator? Con(((Abs("DEM" - "FSMin") > 120) | (Abs("DEM" - "FSMax") > 120)), 1, 0) I have no problem ...
0
votes
1answer
181 views

How to connect mouseclick to map canvas in QGIS?

How to connect mouse click to map canvas in QGIS using python script? I have two lines of code to connect mouse click to map canvas: button.clicked.connect(self.onClicked) ...
1
vote
0answers
228 views

qgis python app how to add edit feature button? [closed]

I'd like to develop a QGIS Python app for plotting points and editing the attributes. I've started with the tutorials here: http://blog.qgis.org/?q=node/59 and read the cookbook ...
4
votes
0answers
27 views

Using QgsNewVectorLayerDialog

I am using QgsNewVectorLayerDialog for taking user input for creating a new shape file. When the user clicks OK i am reading the inputs selected by the user using the following code. dlg = ...
2
votes
0answers
48 views

Image stacking with Python/Gdal

I am trying to accomplish some image stacking task in python. I am not proficient in Python and was hoping I can get some guidance to get started. So I have large number of landsat images. Landsat ...
0
votes
1answer
35 views

Hide/Show leaflet markers based on specific values

I have a Python list of dictionaries with a number of IPs and "Scores" for each IP. I'm adding them to my front end map / leaflet using jinja2 like so: var map = L.map('map') ...
3
votes
5answers
3k views

ExportToJPEG() arcpy script failure

I'm attempting to writing a python script that will automate exporting a set of stock maps to JPEG from their mxd files, and I'm having some strange issues getting there. I've alternatively been ...
1
vote
1answer
108 views

QGIS python script loop for raster calculator

How can I write a QGIS script for making a loop of raster calculator through a set of rasters? I know I can read multiple raster by applying: lddLrs = qgis.utils.iface.legendInterface().layers() for ...
3
votes
3answers
53 views

How to add all “.dat” files (raster) into QGIS, in a defined directory and defined legend (style), using python code

I'm using a QGIS 2.8.3 in Windows 10. I've added just one raster ("dat" file) to the QGIS, with a defined legend, using the following code. If I wanted to add all the "dat" files into a directory how ...
6
votes
3answers
184 views

Remove multiple characters from string field using field calculator (python parser)?

Is it possible to remove more than 1 character from a string in a field using the field calculator? I know !file!.replace(" ","") removes spaces in a string, but is it possible to remove spaces ...
1
vote
2answers
50 views

Using Python to execute merge of rasters Linux

I need help with a python script to iterate merge (gdal_merge.py) of rasters: For each folder located in /home/geodata/sentinel2/ look in subfolder IMG_DATA and merge the three rasters with ...
4
votes
2answers
71 views

How to populate QTableWidget via plugin?

I am attempting to populate a QTableWidget by adding rows, this is done by the user clicking on the add button: I have the following code to try and insert rows but nothing is happening: def ...
8
votes
3answers
183 views

Increase Tiles Caching Speed (TileStache)

I am serving vector tiles using TileStache, I have everything set up like I want. My data is stored in Postgres and I am using the VecTiles provider to serve GeoJSON tiles. I want to cache all my ...
7
votes
3answers
923 views

Disambiguate messy place names in python (preferably on local machine)

I have list with several million place names that come from Flickr profiles. Users provided these placenames as free text, so they look like this: Roma, Italy Kennesaw, USA Saginaw, MI Rucker, ...
4
votes
1answer
45 views

How to insert a variable into a tool script

I am a bit new when it comes to Python programming. I'm trying to run the GRASS r.sun plugin tool to calculate the global irradiance for my chosen area for the whole year. The problem is that r.sun ...
0
votes
1answer
573 views

ArcPy Mark ALL duplicated values

I'm sorry if this is too similar to other posts but I'm an arcpy newbie and I can't quite get what I need. I have accomplished this task in the field calculator (thanks to another post here, but I ...
3
votes
1answer
56 views

Error when using arcpy.ArcSDESQLExecute() to connect to SQL Server - ArcGIS 10.4

I am able to connect to a MS SQL Server 2012 geodatabase with the arcpy.ArcSDESQLExecute() when using the .sde connection file pre-created in ArcGIS. I am not able to connect to a MS SQL Server 2012 ...
2
votes
1answer
564 views

FME - Use Python Caller to Set Search Envelope in Another Workspace

I have an FME workspace which has a number of different workspaceRunner transformers. The first workspaceRunner launches a workspace which buffers a pipeline and outputs the bounding coordinates to a ...
2
votes
1answer
35 views

Change which default python install runs .py scripts a the command prompt

I have 3 installations of python on my machine currently, the ArcGIS install, the QGIS install, and an Anaconda install. The Anaconda is the on that I use predominantly. If I run a .py script ...
2
votes
0answers
35 views

Rasterizing Shapefile, using other shapefile as Mask

I have a shapefile (ShapeY) of European extend and want to rasterize each time only a certain area of the shape (ShapeX) (i have the shapes indicating the prevailing extend) with python and QGis. ...
5
votes
1answer
60 views

How to save qml style including function in QGIS?

I made a style which needs function to work. In my particular case it is calculating azimuth between nodes of rectangles to display "direction". The problem is, if I save the style, the function ...
2
votes
1answer
276 views

Using Spyder IDE to develop python for Grass GIS, get 'ImportError: No module named grass.script'

I am trying to use Spyder IDE to develop a python script using python library from grass-6.4.3. I run the script below, and get 'ImportError: No module named grass.script' I am using python 2.7, ...
0
votes
0answers
55 views

Connect two points with fixed longitudinal slope over DEM - QGIS

Is it possible to connect two points with fixed longitudinal slope over DEM terrain or connect points with maximum longitudinal slope? Make road line between two point, for example 7% or make it with ...
2
votes
1answer
200 views

Pyqgis: “a.geometry().intersects(b.geometry())” wouldn't find any intersections but should. Why?

I am teaching myself pyqgis and try to find those polygons in one layer that intersect with polygons in another layer. It seems very trivial, and on GIS.SE are several similar questions that are ...
2
votes
2answers
2k views

installing exifread for photo2shape plugin

I've already seen Error loading plugin photo2shape even after installing exifread module and Error installing Photo2Shape QGIS 2.6 for Mac, and other forums, but can´t make it work. First I installed ...
0
votes
1answer
26 views

Fiona does not specify CRS

I try to write a geoJSON from a shp with the fiona package. Works, but fiona does not include the CRS information. with fiona.open(path) as shp: takeCRS = shp.crs takeSCHEMA = shp.schema ...