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

learn more… | top users | synonyms

2
votes
1answer
53 views

How to set “draw line inside polygon” using Python?

In the QGIS properties of a layer I want to activate "draw line only inside polygon" for a specific layer, but using Python. I don't want to use the GUI for it. Can this be done? I set the line ...
0
votes
0answers
7 views

Is there a Python equivalent to QGIS Raster Calculator's “file1.asc” AND “file2.asc”

I would like to script a calculation equivalent to QGIS Raster Calculator's "file1.asc" AND "file2.asc". I have 18 data raster files which I would like to do the equivalent of ADD to each of five ...
1
vote
2answers
61 views

How to read geographic coordinates when the Shapefile has a projected spatial reference

I have a polygon Shapefile and want to read the polygon's vertices using OGR and Python. The reference system of the file is projected. However, for further processing I need the geographic ...
0
votes
0answers
17 views

How to burn geometry to raster without shapefile, just from list of coordinates?

I have a list of coordinates points(x,y) of some multipolygon like this: [[x1,y1][x2,y2][x3,y3] ... [xN,yN]] Also can convert between lat/lon and UTM coord systems. When we use gdal.Raesterize like ...
0
votes
1answer
240 views

Can't get the correct version of GDAL installed to use ReadAsArray without getting error in Python

Using the instructions here . . . https://pythongisandstuff.wordpress.com/2011/07/07/installing-gdal-and-ogr-for-python-on-windows/ I downloaded the following files: GDAL-1.11.1.win-amd64-py2.7.msi ...
3
votes
6answers
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 ...
7
votes
2answers
2k views

Automating batch load of multiple GPX files into PostGIS

I've got 50+ GPX files that I would like to "batch load" into a PostGIS database. All of the track_points data would be loaded into a "track_points" table (with typical GPS fields like lat, long, ...
0
votes
1answer
975 views

ArcPy SelectLayerByAttribute Error and how to control GP output layer name

I have a rather long script that first references an SDE feature class (non-versioned) to perform an attribute selection based on a SQL selection. I've been unable to figure out why the script will ...
1
vote
0answers
24 views

How to implement a Plotting widget into already existing PyQt4 Interface

I am using Python, PyQgis for about one week and already built a plugin for GIS 2.14 which is -so far- working pretty well. As my next step I want to add a widget to plot data to my already existing ...
1
vote
1answer
33 views

QGIS: startup.py executed twice?

To test something I have a very simple startup.py file in my .qgis/python folder: import qgis qgis.utils.iface.actionShowPythonDialog().trigger() print "Welcome chump" Python console launches fine,...
1
vote
1answer
46 views
+50

How to define border colour for rule-based style using PyQGIS?

I use the following to create a Rule-based style for a given layer which includes defining a label, expression and colour fill: from PyQt4.QtGui import QColor layer = qgis.utils.iface.activeLayer() ...
5
votes
2answers
1k views

How to remove all selection from all registered layers using QGIS plugin?

I want to remove all selection from registered layer in QGIS using Python. I tried to clear the map canvas using: self.iface.mapCanvas().clear() self.iface.mapCanvas().refresh() but the ...
1
vote
1answer
29 views

SAGA GIS work with python API error

I want to work with python API and SAGA GIS. I am very new with this work. The first step I find one module for example Slope, Aspect, Curvature and I take with right click one python script. python ...
3
votes
0answers
48 views

How to handle large tables in QGIS using python?

I'm currently writing a plugin that calculates values based on a QgsVectorLayer's attributes. To display and print the values I'm using a QgsComposerTextTableV2. I have several problems with my ...
2
votes
1answer
236 views

Plugins crashing with “No module named qgsprojectionselectionwidget” in Windows?

My Python QGIS plugin works on Ubuntu (at least for me, and all fatal bugs reported so far are solved), but when I run it on QGIS installed from the official 2.10.1 64-bit installer for Windows (on ...
0
votes
1answer
34 views

Write GeoJSON As Feature Object in Postgis

I'm trying to create a geofence/circle from a lat/long set and I'm close except that the GeoJSON that PostGIS creates differs in structure from the client library that our front-end uses. Here is my ...
1
vote
2answers
290 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 ...
2
votes
1answer
10 views

SyntaxError with custom function using QgsFeatureRequest.setFilterExpression

def get_subsel(layer,filter): layers = iface.mapCanvas().layers() for lyr in layers: if lyr.name() == layer: request = QgsFeatureRequest().setFilterExpression(filter) ...
0
votes
1answer
61 views

Clipping GeoTIFF file by GeoJSON?

Input GeoJSON file: { "type": "Feature", "properties": { "id": 1 }, "geometry": { "type": "Multipolygon", "coordinates": [[[ [27.397511483867362, 44.161117466010516], [...
1
vote
1answer
40 views

Install GDAL python package in virtualenv on mac

I'm trying to instal the GDAL python package, preferably in a virtual environment, but when I try "pip install gdal", I get the following error: extensions/gdal_wrap.cpp:3085:10: fatal error: '...
2
votes
1answer
26 views

Creating an Interrupted Map With OGR, Mapnik and PIL

I am trying to create a simple interrupted Sinusoidal map with Python using OGR, Mapnik and PIL. The general idea is: Make 6x 60 degree sinusoidal maps For each one, make a mask to make it gore ...
1
vote
0answers
23 views

How to change which python GDAL is “connected” to?

I would like to use GDAL with Python 2.7 on Ubuntu 14.04. I have installed gdal-bin and python-gdal from UbuntuGIS following their instructions. However, importing GDAL (from osgeo import gdal) only ...
4
votes
4answers
6k views

How can I fix “ImportError: No module named qgis.core”?

First of all, I'm using Python 2.7.3, QGIS 1.8 (Lisboa) on Windows 7 pro 64 bits. Now let's go to the actual question: I have written some code (Python) that works well within the QGIS built in ...
1
vote
0answers
16 views

Convert and plot python basemap and netCDF file in UTM zone 45N

I have a netCDF file with precipitation output for one year. I have a problem with aligning the basemap and netCDF file, and plot them in the same coordinate system. The netCDF file covers the ...
0
votes
1answer
17 views

Parsing error with field calculator [on hold]

I am trying to do a simple calculation that populates a field based on a set of acreage figures. I am using if/else if statements with acreage ranges. Here is the python script I came up with. def ...
2
votes
1answer
85 views
+50

How to use Qt3 Support widgets in QGIS plugin?

Similar to this post: My plugins crashes with “No module named qgsprojectionselectionwidget” in Windows. Except I would like to also use Qt3 Support widgets (in particular, a Q3ButtonGroup). However, ...
1
vote
0answers
22 views

batch convert geojson to shapefile [duplicate]

I have a directory full of geojson files that I need to convert to shapefiles for editing in QGIS. As far as I have searched, there are no resources in GIS StackExchange that explain how to do this ...
1
vote
0answers
23 views

Segmentation fault in readasarray

I am running the following code and get: Segmentation fault (core dumped) I have no clue why, I have been using the functions many times before and now suddenly this happens. Sometimes it happens at ...
1
vote
2answers
40 views

Values extracted from NetCDF not matching original raw data

I am working with monthly rainfall data from University of Delaware which is available as a NetCDF from NOAA and raw text from UDel's homepage. I would prefer to use the NetCDF format but when I ...
1
vote
1answer
32 views

Array written by GDAL with Python script has numbers read as “nan” by QGIS?

I would like to write an array to a geotiff with Python script using the GDAL module. When I try to do something simple like copying an existing GeoTiff via reading it to an array, then, writing to a ...
1
vote
1answer
569 views

How to select and zoom in features from a QGIS Python Plugin

I'm very new to Python. I'm trying to find a way to select and zoom to the features from a QGIS layer. I've created a plugin and built a custom form. I have 3 values from the form which I need to ...
0
votes
0answers
36 views

Can Qgis read or access to WKT column on ms acesss?

On my ms access .mdb table, linestring (WKT) column are called from add vector layer selected database with odbc connection link. It is Successful but can't directly access lines from ms acess ...
2
votes
1answer
249 views

gdal_calc works but I get a Python error at the end of each process

I have a problem while using gdal_calc by a .bat file. Here is the code : call "C:\OSGeo4w64\bin\o4w_env.bat" gdal_calc -A"D:\tuilage_script_1\tuilage\ndvi\4_810000_6370000_820000_6360000_ndvi....
1
vote
1answer
45 views

Dynamically move map canvas and main window using PyQGIS

I am trying to create plugin that will open new window with some layer, Dynamically "pan" my window, when main window is pan. So boundingbox coordinates should be the same in both windows. I need new ...
1
vote
1answer
188 views

Couldn't load plugin PRISM due an error when calling its classFactory() method in QGIS1.8 inWin8

When I load a plugin in QGIS ,met some problems : I had tried copy other Python27's files to QGIS's Python 27 file but it still does't work. Couldn't load plugin PRISM due an error when calling ...
1
vote
1answer
57 views

gdal/python WriteArray working for 8-bit but not 16-bit

I'm trying to use GDAL/python API to open a raster, do some math, then write the two resulting arrays as rastes. One is to be an 8-bit raster and the other 16-bit signed. However, only the 8-bit ...
1
vote
0answers
12 views

Getting the activeLayer() in Eclipse

I've been working on a plugin in python for qgis. I'm using Eclipse-pydev with remote-debug. I believe I'm set up correctly; I've followedthe Cookbook instructions completely. When starting remote-...
0
votes
0answers
11 views

gdalwarp fails based on output filename? does it have to do with my using -t_srs?

I am so confused by what is going on with my gdal warp. From my terminal I can enter a command for it: $gdalwarp -t_srs '+proj=ortho +datum=WGS84' test_imagery/Maui/OBS_IMAG.nitf testout3.tif ...
1
vote
1answer
50 views

GDAL python cut geotiff image with geojson file

I wrote the function which cutting geotiff image by bounding box. First image is original. At second you can see result off my code. I don't use gdalwarp or any console utilities. But I have no idea ...
2
votes
1answer
53 views

Python to create new fields in many layers / QGIS

I have a number of line layers on which I need to perform the same task: add 4 columns with the start and end points of each line. The expressions that I use to do this are: $xat(0) $xat(-1) $yat(0) ...
2
votes
1answer
43 views

Clip raster with shapefile and set a value outside the mask

I want to clip a raster using a shape file with the command: gdalwarp -cutline INPUT.shp INPUT.tif OUTPUT.tif from this answer. However I want to set the pixels outside the mask to a particular ...
3
votes
1answer
101 views

GDAL Python cut geotiff image

I was stuck for 2 or 3 days. I have read many lectures from RS/GIS Laboratory of Utah State University. Also I read «Python Geospatial Development» book and many docs from gdal.org. So, my problem ...
1
vote
3answers
62 views

Writing an if then statement for if a parameter is selected (not Null) in Model Builder

I have a tool I'm trying to create in model builder. I have run into a problem as I have basically no experience with python. I'm trying to basically use the calculate value tool and an if then ...
5
votes
2answers
207 views

Field Editor with Python: select by attribute & open table (QGIS)

I want to search on number values (>, = etc.) within a column and open table for the selected ones. It's an easy task within field calculator, but I want to see how it's build up with the python ...
5
votes
2answers
2k views

how would one get the end points of a polyline?

I am attempting to write a script to get the end points of a series polylines, and then use those end points to create a polygon. I'm not sure which tools to begin to use on this project. I would ...
1
vote
2answers
34 views

python gdal - libgdal.so.1: undefined symbol: sqlite3_column_table_name

I just reinstalled my python environment (and my whole Ubuntu). In python (or IPython), when loading geopandas: import geopandas as gpd or when I import fiona: import fiona I get this error ...
5
votes
1answer
3k views

ArcPy replaceDataSource

I'm attempting to replace a datasource in an outline map frame using ArcPy. The rest of the script seems to run OK, but after the script has run the datasource the datasource of that layer shows an ...
4
votes
1answer
219 views

Adding QGIS-specific Python interpreter to Eclipse?

I was following the steps from QGIS Python Programming CookBook to add qgis interpreter to eclipse, however I went into the following error in step 8: "See error log for details. No output was in the ...
0
votes
0answers
32 views

QGIS Custom Query Plugin

I am very new to QGIS plugin development. Is it possible to create a custom form (Field will be fixed and User can select only operator and enter value for field) to do custom attribute expression ...
1
vote
2answers
189 views

Error Installing GDAL python package on a MAC

I'm trying to install the [GDAL python package][1] on a Mac (OSX Yosemite) with python 2.7.9 and GDAL 1.11.3. When I try $ sudo easy_install GDAL I get a number of errors ending with: error: Setup ...