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

learn more… | top users | synonyms

0
votes
1answer
54 views

Clipping GeoTIFF file by GeoJSON?

What is the best way to clip geotiff file by geojson? 1) Make a OGR file (e.g. shapefile) .shp from .geofile like this: { "type": "Feature", "properties": { "id": 1 }, "geometry": { "...
2
votes
1answer
20 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
5 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
0answers
11 views

Update data in attribute table based on value in separate column, same row

I am trying to update data in one column of an attribute table based on data in another column to update the same row. For example, if one value in a column has the state abbreviation "HI" then ...
1
vote
1answer
28 views

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() ...
1
vote
0answers
15 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 ...
1
vote
0answers
21 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 ...
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
10 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
16 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
71 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
21 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
21 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
36 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
29 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
567 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
34 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
31 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
186 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
56 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
9 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
44 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
51 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) ...
1
vote
0answers
15 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
0answers
22 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,...
2
votes
1answer
40 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
97 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
61 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
33 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
212 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
187 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 ...
3
votes
1answer
345 views

Import error when utilizing QGIS's Python Init function

Based on the answer to Referencing Qt UIs external to plugin with python. I'm trying to utilize the "Layer Properties / Fields / Python Init function" to execute a file (test_file.py) that is located ...
3
votes
2answers
61 views

Geopandas Polygon to matplotlib patches Polygon conversion

Unfortunately geopandas plotting is extremely slow and takes a lot of resources, hence I would like to use instead matplotlib for plotting. When I use pure Fiona to open and read the shapefile I ...
1
vote
1answer
27 views

Fixing python error in QGIS Freehand raster georeferencer plugin?

I am using QGIS 2.8.9 stable release in the 32bit form on a Windows 7 64 bit compatible PC. I want to use the Freehand raster georeferencer plugin. It installs without difficulty but when I try to ...
9
votes
2answers
876 views

Histogram Matching using Python to improve mosaicking process of multiple overlapping rasters?

I am trying to do histogram matching using Python to improve the mosaicking process of multiple overlapping rasters. I am basing my code on that found at: http://www.idlcoyote.com/ip_tips/histomatch....
0
votes
1answer
43 views

Python new packages installation with ArcGIS interpreter?

I would like to introduce some functions derived from scipyin my code. Since I also need arcpy, I use the Interpreter installed inside ArcGIS, whose directory is: (C:\Python27\ArcGIS10.3\python.exe). ...
2
votes
1answer
32 views

QGIS or PostGIS auto-split long line features

I have a dataset of LineStrings in a postgis enabled database and would like to automatically split any feature longer than a certain threshold (say 1 mile). I am aware of the Split Feature tool in ...
3
votes
0answers
70 views

Using ogr2ogr in python?

I found this helpful post that got me started using ogr2ogr in python: Using ogr2ogr to convert GML to shapefile in Python? as well as this one: How to convert ArcGIS Server JSON to GeoJSON? I am ...
3
votes
1answer
30 views

AddRaster using pyqgis

I am able to attach a raster by using python console using the command shown below. qgis.utils.iface.addRasterLayer('D:/Work/dt0017810q.tif') But, when the same image/raster path is read from a ...
9
votes
4answers
8k views

Using ogr2ogr to convert GML to shapefile in Python?

I am trying to convert a GML to an ESRI shapefile using ogr2ogr utility in a python script. I have successfully installed the GDAL/OGR package via osgeo but I am now struggling to find/understand ...
1
vote
1answer
67 views

Force Python GDAL/OGR to flush changes to disk

I am trying to write a simple list of features and export it as a KML file, adding one extra attribute: in this case trafficability. However, ogr is failing to flush the data to disk when I run the ...
1
vote
1answer
119 views

mosaic rasters with gdal_merge.py

I want to mosaic 2 rasters "rasa" and "rasb" using gdal_merge.py . While running the code, it produces an error " No input files selected". Can somebody help me to find the error in the code? ...
-1
votes
0answers
37 views

How to get the nearest building to a point in Openstreetmap Python [closed]

my goal is to get the distance to the nearest building from a point using Python and OpenStreetMap database. I already know the use of overpass API for obtaining the buildings around a certain point, ...
3
votes
1answer
29 views

How to check if a geoserver layer is raster or vector using gsconfig

I am using gsconfig and python in order to retrieve information regarding some geoserver layers. What I am trying to do is to find out if a specific layer is raster or vector. I read online that I ...