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

learn more… | top users | synonyms

0
votes
2answers
1k views

How to round up/down an pixel value of a raster to a pixel value with 2 decimal places?

I have a raster (DTM) with floating points as pixel value. Now i want to round up/down the pixel values (to its next nearest value) to 2 decimal places. I use ArcGIS (with extensions) and tried the ...
0
votes
0answers
15 views

How to convert Integerized Sinusoidal Grid to lat long?

I'm trying to convert MODIS Integerized Sinusoidal Grid (0.25km/250m) to corresponding latitude and longitude. I found this tool to convert the data. I've written the algorithm for converting ...
0
votes
1answer
15 views

System locale settings error creating GRASS location from Python

I am trying to use GRASS 7 from Python without explicitly creating a location. I am starting with the script provided at the GRASS-Wiki. This script tries to create a new location in the /tmp/ folder ...
1
vote
0answers
53 views

Cannot run QGIS algorithm with python script without interface

I'm trying to run the QGIS 'intersection' algorithm from a Python script: (Working with Ubuntu) #!/usr/bin/env python # -*- coding: UTF-8 -*- import sys from qgis.core import * from PyQt4.QtGui ...
2
votes
1answer
305 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
18 views

64Bit Applications installed with QGIS/osgeo4w

Is python 64bit and gdal 64bit automatically installed when QGIS 64bit is installed via osgeo4w 64bit? I currently have a custom 64bit python and gdal setup on my pc. However, this setup causes some ...
2
votes
2answers
310 views

Convert DateTime field to Just Date in Label Expression

I have a DateTime field (ex: CreatedDate) and would like to only show the date with the label. How would I setup the label expression to do this using python?
6
votes
1answer
357 views

ArcGIS Python Security Concerns

I’m working for a large organization which are using ArcGis Desktop on some (windows) clients. The security requirements for the system is very strict, and a part of that is prohibiting the users the ...
0
votes
1answer
561 views

Polygon Neighbors Analysis script (ArcPy 10.1) producing erroneous results?

I'm struggling with a python script that is supposed to calculate a field for a polygon feature class. The calculation is of the average of a field value (P_TOT_DEV) for each of a given polygon's ...
63
votes
13answers
51k views

Installing GDAL with Python on windows?

Can anyone explain how to install GDAL/OGR with Python on Windows? I have Windows Vista and I have tried following the information on the website and it does not seem to bind the exe files for me. ...
2
votes
1answer
26 views

How to include QgsRasterBandStats in plugin

I'm making a plugin were i want to get the min and max value of a raster. When i tried the following code in the qgis python console it worked fine but in my plugin code i get the following error ...
0
votes
0answers
29 views

need to convert tiff and kml to geotiff

I'm looking to combine a tiff and kml file into a geotiff (this needs to be integrated into a program i'm writing, unfortunately not a one off). Due to dependency issues I can't use GDAL and it ...
1
vote
1answer
29 views

Does Gohlke GDAL break Command-Line GDAL/OGR in Windoiws?

I recently gave up trying to get the gisinternals versions of GDAL's Python bindings to work, and sought instead to use the 'gohlke' approach - getting the appropriate wheel from the UCI repository. ...
8
votes
2answers
177 views

How to set transparency to multiple raster values with Python

With the following code I can set 100% transparency to raster value 0: map=None for lyr in QgsMapLayerRegistry.instance().mapLayers().values(): if lyr.name() == "some_layer": map= lyr tr=None ...
1
vote
1answer
291 views

Calculate tree cover over certain area from raster data

Last year Hansen et al. published Global Forest Change map as set of raster data available in TIFF format. Basically those are 30-meters resolution satellite images with pixel values ranging from 0 (...
2
votes
1answer
51 views

How to remove all layers from a group

I want to remove all layers from a distinct group. root = QgsProject.instance().layerTreeRoot() the_group = root.findGroup("my_group") parentGroup = the_group.parent() I think I have to loop the ...
1
vote
1answer
42 views

How to tranform MODIS tiles into lat/long?

I'm trying to get the vegetation index nearest to a particular lat/long. I'm getting the data from here which is 250-meter spatial resolution hdf file. The globally gridded projection is split in 36 (...
0
votes
0answers
39 views

float() argument must be a string or a number, not 'zip' Python

While running the basic example of cKDTree, why I am getting the error again and again. from scipy import spatial x, y = np.mgrid[0:4, 0:4] points = zip(x.ravel(), y.ravel()) tree = spatial.cKDTree(...
10
votes
6answers
1k views

Is there a faster way in python of finding the smallest number in a field?

Using arcgis desktop 10.3.1 I have a script which uses a search cursor to append values to a list and then use min() to find the smallest integer. The variable is then used in a script. The Feature ...
5
votes
1answer
711 views

import arcpy yields “TypeError: This object does not support enumeration”

Similar to Enumeration Problem with Eclipse and ArcGis 9.3, with Arcgis v10 I no longer seem to be able to run python scripts from a command shell. Entering the same code into an interactive python ...
8
votes
1answer
461 views

How to debug a QGIS python plugin with popups?

I'm trying to write a python plugin for QGis. I'd like to debug some DB queries and I need a way to display the result. I thought about using a popup to display it, but I don't know how to show a ...
2
votes
0answers
16 views

Unable to compile using make test(windows)

While trying to compile my test plugin I encounter this error. At the moment i can't figure out why it isn't working. I m using a windows and try to execute the command in OSGeo Shell. I typed in ...
5
votes
0answers
51 views

Sending a https request from a QGIS plugin using urllib2

I'm developing a QGIS plugin that needs to send https request to an API. I have to use urllib2 (see below if you want to know why I don't just use the requests package) The first request I need to ...
2
votes
2answers
37 views

Find common borders of features and get their attributes using fiona and shapely

I would like to find neighboured features in a shapefile using fiona and shapely. As shown in this answer http://gis.stackexchange.com/a/95595/62250 it's easy to get common borders between features. ...
11
votes
1answer
994 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 ...
3
votes
2answers
489 views

GDAL with GEOS support, pandas and VTK using python on Windows?

So far I have been using OSGeo4W shell (or OSGEO install) as really convenient way to use python together with additional packages, namely gdal, shapely, numpy, scipy and matplotlib. I was happy till ...
1
vote
1answer
49 views

How to filter out layers with QgsMapLayerComboBox?

I am using Qt Designer 4.8.5 to develop a plugin (with QGIS 2.14.3-Essen). I recently started to use QgsMapLayerComboBox widgets instead of the conventional Combo Box widget. However, I want to ...
3
votes
1answer
76 views

get log of internal functions called by qgis

Is there a way to know which internal python functions are used by QGIS? e.g., when I click on "add vector layer" button I would like to know the functions that are called by QGIS. It would simplify ...
1
vote
1answer
217 views

Need python code example - setting a combo listbox to Null

I want to be able to set the value of a field to Null using python, but I get an error. I am using arcpy.CalculateField_management
3
votes
1answer
505 views

How to check if geometry is M aware?

I am trying to determine whether my shape file that I pass is in M-aware (has M value). I keep getting an error Attribute Error: 'Polyline' object has no attribute 'hasM' Not sure what I am doing ...
3
votes
2answers
1k views

Unzip a file using python caller in FME 2011

The idea is to download a zipped file from a website and unzip it using FME 2011. I have attached a screenshot of FME workbench which is not working.
2
votes
1answer
252 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 ...
2
votes
2answers
814 views

Error 999998 in Arcpy 10.1

I found an RuntimeError: ERROR 999998: Unexpected Error when lunching Arcpy in my ArcGis 10.1 such as this: Runtime error Traceback (most recent call last): File "", line 50, in File "c:\...
3
votes
1answer
284 views

How to clip a Oracle query layer directly in a Python script?

I have a query layer directly running from ORACLE database in a MXD. I want to clip this layer with a layer being created in another MXD in a Python based tool. My question is to do this clip ...
1
vote
2answers
55 views

Point Click for Coordinates - Stand Alone QGIS in Python

I am implementing a stand alone version of the answer to this question > How to programatically check for a mouse click in QGIS My code is below. The code compiles without error, and the toolbar ...
1
vote
1answer
39 views

Writing geoJson from rasterstats

How would I write a proper geoJson, readable by a GIS, from the results of the rasterstats package? stats = zonal_stats("somePolygons.shp", "someTif.tif", ...
0
votes
0answers
43 views

NumPy to GeoTiff for use with Gdal

I have a few NumPy arrays: lat, lon, and 6 data bands. I'd like to convert these to GeoTiff and then apply the gdalwarp function, based on a specific projection, to each band. Is there a standard way ...
1
vote
0answers
332 views

How to integrate QT User Interface with QGIS Python Plugin?

I created a very simple python program using GDAL to calculate the summary and reduction between two raster value like this : import os from osgeo import ogr, gdal from gdalconst import * ...
1
vote
1answer
268 views

gdal_proximity distance to meters

I followed the answer given in this topic for searching the distance to the nearest coastline given a lat/lon coordinate. The distance output obtained is in degree (I think) but I need the distance ...
5
votes
1answer
490 views

Select and copy attributes features in ArcMap using Python add-in tool?

I'm trying to add a tool to an add-in toolbar to select features from an existing feature class and copy attributes to another feature class,from point to point. TopoHeight_Field_Name='Comment' def ...
3
votes
1answer
486 views

How do I smooth edges of polygons in QGIS?

Is there a built in function or plugin I can use to achieve smooth lines for my polygons instead of the blocky ones I have now?
2
votes
1answer
19 views

AttributeError: 'SpatialReference' object has no attribute 'ImportFromESPG'

I am trying to create a spatial reference using ImportFromESPG and this is what is returned: AttributeError: 'SpatialReference' object has not attribute 'ImportFromESPG' Code and error are copied ...
4
votes
2answers
130 views

How to update raster pixel values based on another raster with conditions in QGIS?

I have 2 land cover rasters. I want to update parts of the first raster with values from the second using QGIS. The workflow should be like this: 1. Select values equal to 30 and 34 in the first ...
1
vote
0answers
32 views

Find and filter points within a variable radius

I have a set of projected spatial points (x,y,id,dist,value) that needs to be filtered. For each point I have to find the other ones falling within a variable distance. For each selection, I need only ...
3
votes
1answer
95 views

How to convert multiple csv files to shp using python and no arcpy?

At my internship, I have been asked to learn Python on the job. Its been a rough road never having coded before so please forgive me if my problem is elementary. The Lightning CSV files I am ...
1
vote
1answer
48 views

Why are there my_form_open() Python functions in my QGIS project file?

I have a project open with 6 layers (MapInfo .tab format), have set the style for each layer and added labels for 1 of them. So for a simple project the .qgs file is about 2000 lines long and among ...
1
vote
2answers
7k views

KeyboardInterrupt doesn't work when arcgisscripting module is loaded

The KeyboardInterrupt exception -- thrown when Ctrl-C, or Ctrl-Break on some machines, are pressed in a Python console window -- is commonly used to gracefully break out of long-process loops, ...
1
vote
1answer
24 views

Updating a raster using a shapefile [closed]

I have a huge raster file and want to increment all the values within a relatively small shapefile by 1 in Python. Speed is of critical importance, as I have to do this many times. I have been ...
1
vote
1answer
75 views

How do I fill a Field Combo Box with vector layer fields in QGIS?

I am new to python and I am trying to write my first plugin for QGIS. Earlier I asked this question to find out how I could populate a combobox with point vector layers (and nothing else). I've been ...
1
vote
2answers
49 views

Rpy2: how do I use the function 'as' (r library methods) in python?

I want to coerce an object of class Raster Layer to class SpatialPixelsDataFrame since that is required as input for the function autoKrige from the r library automap. However, when I try to use as ...