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

learn more… | top users | synonyms

0
votes
0answers
2 views

Replace non-ASCII characters in QGIS Field Calculator

I want to replace all non-standard characters from fields in a dbf table in QGIS. From http://stackoverflow.com/questions/20078816/replace-non-ascii-characters-with-a-single-space I see we can use ...
0
votes
0answers
9 views

Remove date from beginning of filename, add to the end [on hold]

I have a group of files I'm trying to database (with improper naming conventions starting with dates) i.e. 20160524_Whatever_Whatever I'd like to remove the date and _ and append it to the end of the ...
0
votes
0answers
11 views

When I open the software this message showed “Import Error No module named osr” . I am using QGIS 2.6.0 version

This is the image of the error that occurred. I was able to use the software, but I'm bothered by the error.
0
votes
0answers
12 views

How can I obtain selected value from QGIS using python algorithm?

I'm writing an algorithm in python for QGIS and i have a function which uses a value from a selection. The problem is that when i select a value the script give me the error that the local variable ...
0
votes
0answers
19 views

Creating a polyline with a specified slope

I would like to create a road (polyline) starting from a point, with a specified slope, until reaching the top of a hill (or going out of the DTM Raster). The dowstream slope of the DTM must always ...
3
votes
2answers
112 views

Can this Be Recoded to Be More Efficient with Respect to Processing Time?

I'm very new to GIS but have been asked to parse through any given ESRI GDB file-folder without using any ESRI product. I've been trying to focus on using Fiona and Shapely as these seem to be ...
1
vote
1answer
25 views

How is it possible to programmatically export current view as georeferenced image with QGis?

I found the this to export the current view as image. The following code works and was accepted as answer. c = iface.activeComposers()[0].composition() image = c.printPageAsRaster(0) ...
1
vote
0answers
9 views

pyd error install qgis 2.14

I removed qgis 2.10 so i could install qgis 2.14. But when i try to install 2.14 i get errors on python .pyd packages. Every time it is a different pyd causing the error. I had this problem with ...
0
votes
0answers
32 views

SAGA GIS API ERROR (import saga_api)

I want to use saga api on my Idle with Python but I have problems. First I have Windows 10 64 bit, I install SAGA GIS via OSGeo4W64 64 bit, and I have Python 2.7.11 64 bit. I follow steps for the ...
1
vote
1answer
23 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
24 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 ...
2
votes
1answer
58 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 ...
1
vote
1answer
30 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 ...
3
votes
2answers
43 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 ...
1
vote
0answers
45 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
1answer
37 views

Read from TIF overviews using rasterio

I'm reading a window of a tif using rasterio. How do I utilize the available overviews to get a down-sampled version of the data instead of reading at the true resolution? Right now I am reading a ...
3
votes
1answer
70 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. ...
0
votes
0answers
23 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 ...
4
votes
0answers
26 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 = ...
1
vote
0answers
40 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 ...
5
votes
2answers
48 views

How to use current layer name in FME PythonCaller?

In a PythonCaller (FME 2014 SP4 in Data Interop in ArcGIS 10.3), I'd like to do some conditional processing based on the layer that I'm currently processing. I'm feeding in a text file of layers ...
1
vote
1answer
32 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 ...
1
vote
1answer
61 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 ...
6
votes
3answers
178 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 ...
2
votes
1answer
30 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 ...
-5
votes
0answers
38 views

Is it possible to enter this formula [closed]

I'm not sure if this is the appropriate place for this question but the above formula can I write it in python or not and if so would anyone have an example possibly for the formula
0
votes
0answers
22 views

Resampling geotiff images? [closed]

I am trying to resample an image (geotiff) to a 5 m x 5m resolution using python. I am new to gdal and not sure how to go about it. Using gdal.ReprojectImage is what I should be doing, It would be ...
3
votes
3answers
51 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 ...
5
votes
1answer
59 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 ...
0
votes
0answers
50 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
40 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 ...
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. ...
4
votes
2answers
67 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 ...
1
vote
0answers
27 views

Unable to set background image of Qframe using python [closed]

Unable to set background image of Qframe using python following code works fine in centos but in window 7 not even its did not show any error ...
1
vote
1answer
104 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 ...
0
votes
1answer
36 views

Python to Postgres insert Geometry syntax

Having trouble creating geom columns and inserting geometry lat lng values into postgres table Is my syntax correct in creating the point geometry fields? st_makepoint is the point constructor. ...
1
vote
1answer
36 views

How to do a Spatial Join after opening a GDB file with Fiona?

After I successfully open up an ESRI GDB file/folder with Fiona, what open-source Python package should I use to do a spatial join? I was told Shapely is not the appropriate package for this. I am ...
3
votes
1answer
48 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 ...
1
vote
1answer
41 views

tiff to shapefile using GDAL - slow speed

I am converting a 500MB .tif file to .shp file using GDAL. I am using the following: gdal_polygonize.py .tiff file -f “ESRI Shapefile” out.shp However, I abandoned the first attempt as in 12hrs it ...
3
votes
0answers
24 views

GDAL gdal_polygonize.py TypeError

I am using GDAL to convert a .tif to .shp file. gdal_polygonize.py input.tif -f “ESRI Shapefile” out.shp However this does not work and results in: Traceback (most recent call last): File ...
1
vote
0answers
28 views

Is there any way to connect features (entities) of dxf to database in python?

I'm using gdal, ezdxf, sqlite python packages and sqlite ODBC driver. They work fine, and in AutoCAD I can easily manually connect to my dbase.sqlite (read only) using _DBCONFIGURE and _DBCONNECT ...
3
votes
2answers
70 views

How to add support for FileGDB (Esri file gdb API) driver in fiona?

There has been a tons of questions on that but none of them solved my problem. I have a machine with: Windows 7 x64 Python 3.4.3 x64 gdal installed: gdalinfo --version --> GDAL 1.11.4, released ...
3
votes
0answers
44 views

GDAL RasterIO performance in C++ vs ReadAsArray in python/numpy

I'm currently writing optimisations for a raster viewer program which uses gdal as it's base. It's currently written purely in python, and has some major speed issues which cause problems when we are ...
1
vote
0answers
18 views

Nominatim address locator does't give longitude

I'm trying to geocode my addresses based on this tutorial: http://www.digital-geography.com/geocoding-addresses-in-arcgis-the-other-approach/#.VzMq_IR97Rb But Whenever I use Nominatim geocoder it ...
0
votes
0answers
35 views

Drawing contour with python QGIS?

I have one point layer and one contour layer and I was trying to draw a line around one contour, making a circle but not a uniform one, it has to have an irregular shape. I cannot find a tool that ...
0
votes
0answers
27 views

point in polygon starting with csv and shp in python

I have a csv file with two sets of lat/lon points - the first set of points is represented by columns V1(lon) and V2(lat), and the second set of points by V3(lon) and V4(lat) (the csv does not have ...
2
votes
0answers
28 views

Non-zero error with ImportFromEPSG() in GDAL/OSR/Python

I'm currently getting an error when testing ImportFromEPSG() on my GDAL. import osr testSR = osr.SpatialReference() testSR.ImportFromEPSG(4326) #this returns value of 6 print ...
3
votes
1answer
32 views

How to get connection info from an .ags connection file?

I am working on a Python script to manage ArcGIS Server services (publish new services, update existing services, delete old services, etc.) in batch across multiple environments (e.g. dev, test and ...
0
votes
1answer
24 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 ...
1
vote
2answers
38 views

Latitude/Longitude to city and zip, batch convertion

I have ~10 mln lat/lon points, and I need to extract city and zip code from them. I can do this with OpenStreetMap using the Nominatim API (using something like ...