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

learn more… | top users | synonyms

1
vote
1answer
43 views

Using a for loop to execute a query in arcpy

I'm trying to provide the breakdown of fire detection for an area by sorting of confidence levels. The dataset has 12 files (one for each month in a year) with fire records which all have a column ...
3
votes
1answer
53 views

Force OGR to use specific driver for input format

How could one force ogr2ogr to use a specific format to read input files? Out of the box ogr2ogr automatically chooses from it's long list of formats, which most of the time is great. However today ...
1
vote
2answers
49 views

How to add “0” to multiple parts of text value in Field Calculator with Python

I have values in a text column that are as follows: 000_100 100_200 ... 1000_1100 1100_1200 I want it to read: 0000_0100 0100_0200 ... 1000_1100 1100_1200 I want all values to have the ...
0
votes
1answer
67 views

if-else logic expression in field calculator

I want to calculate the value of a new field using an if-else condition with field calculator in modelbuilder. Want I want to do is as follows: if my new field is empty, then use the expression ...
1
vote
1answer
46 views

How to call Exelis ENVI tools with python and ArcGIS?

I am writing a script for geopocessing landsat data using ArcGIS 10.3. But ArcGIS doesn't have tools for landsat calibration (converting from DN to reflectance) and ENVI have this tool called ...
0
votes
0answers
14 views

GDAL2Tiles crash

GDAL2Tiles seems to crash after generating tiles and no google viewers are generated, but only openlayers. This is the code I run: os.system("gdal_translate -of VRT -a_srs EPSG:4326" + ...
0
votes
0answers
16 views

Radiometric Indices error

I have successfully included otbApplicaton in my python code. Tested the otb inclusion it is working fine. I am using the following code to generate NDVI output from the landsat image. from sys ...
2
votes
3answers
89 views

Read HDF4 data using python

I am now working with VIIRS/NPP Active Fires by using python gdal. But I cannot read the data inside the files. Filename = "NPP_AVAF_L2.A2012019.0600.P1_03110.2014057125956.hdf" Here is some ...
0
votes
1answer
26 views

Problem calling qgis2leaf outside the QGIS

I am a computer programmer starting with PyqGis-Python, and I’d need to automatize the creation of a webmap using the plugin of qgis2leaf from a QGIS Project. I have reached to call “import ...
0
votes
1answer
30 views

Calculate area of a raster for an irregular polygon in PostGIS

I have a number of polygons with irregular shapes (i.e. non-rectangular) and want to calculate their areas after I have converted them to rasters. Here are my steps: Convert my geometry to a ...
2
votes
2answers
105 views

How to use `layer.getFeatures()` in a standalone script?

I am following the QGIS Cookbook and this post where it concerns reading attributes from layers. I would like to exploit this method and implement it into a standalone script. Essentially, I want to ...
2
votes
1answer
41 views

use gdal python bindings from the QGIS folder in a custom script

I have QGIS installed (on Windows) and can import this line from the QGIS Python console: from osgeo import gdal When I try the import in a python file it doesn't work Traceback (most recent call ...
1
vote
1answer
50 views

Python - Projecting different shapefiles in the same folder

I have a few shapefiles in one folder with different coordinate systems but would like to use one of them as a template dataset. Is there a way to use python to filter out the shapefiles already in ...
0
votes
2answers
49 views

QGIS from console: raster algebra

I'm newbie to programming in pyqgis. I need to perform a simple "GeoTiff * A" type of calculation(where A is a constant), but I am struggling to do so. I tried ...
1
vote
1answer
39 views

Calculate date field using date variable and time attribute in a feature class

I have a string variable (fileDateString) with the date in this format: 20150404 In my feature class there is a text field with time in twenty-four hour UTC format. There is also 2 leading spaces ...
0
votes
0answers
27 views

ST_MakePoint returns an error when using Python

I am trying to use ST_Point or ST_MakePoint to create points from a table of latitude and longitudes coordinates. However I am consistently getting an error even when trying the examples. For example ...
0
votes
0answers
32 views

Search Address (Geocoding), Analyze intersecting underlying layer and return text results

What would the process be for going about accomplishing something like this via a website. Say I just wanted a website form where the user would input their address. Then beneath the scenes it would ...
0
votes
0answers
38 views

Making QGIS custom form modal?

I have created a custom form for entering attribute values for newly added features / editing attribute values for existing features of a shape file. I chose the ui file as "Edit UI" and a python file ...
1
vote
0answers
25 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 ...
1
vote
1answer
46 views

How can I get features that satisfy a QgsExpression using PyQGIS?

I have two fields say "State" and "name" which would be get from the two comboboxes. After which, based on the current text in the combo box, I want to make QgsExpression and feature that satisfies ...
0
votes
1answer
43 views

How to access shapefile m-values with pyqgis?

Does anyone know how to access (read/write) m-values of a line-shapefile using pyqgis? I know how to do it with arcpy cursors ...
0
votes
0answers
30 views

How to raise exception from if statement in Python

This is a general python question, I would like to write a function that essentially states if data is available do this, if not raise an error, and a finally block which does something else. In ...
0
votes
0answers
27 views

Is PyQt4 'drag and drop' functionality available in Qgis Plugins?

In Qgis 2.8, is it possible to use the PyQt4 drag and drop classes (dragEnterEvent, dropEvent) to interact with items from a qtreeview, in a Python Plugin? Is it possible to hook into the ...
0
votes
0answers
11 views

How can I create text using Python in ArcMap 10.1

I am using data driven pages to create a map book and I want to create the neighboring labels. Is there a way to create the label with a background? And when there is a NULL value in the attribute ...
1
vote
1answer
61 views

QGIS custom Form - How to bind a value from a QComboBox?

I am trying to build a custom form for field data collection (bird species) with some python logic. The python code inserts values into a QComboBox: At the beginning of the list it adds the twenty ...
1
vote
0answers
21 views

Where does GEOS Library gets installed QGis

Working on OS X 10.10, QGis 2.8 I want to install basemap. I installed QGis 2.8 which includes the GEOS and the PROJ4 library. In order to install basemap properly, I need to pinpoint it to the ...
0
votes
2answers
61 views

How to change different projections of feature classes in geodatabase to one projection in new geodatabase?

I want to create a script that iterates through feature classes with different projections in a geodatabase and exports them into a new geodatabase, all with the same projections. What I want is to ...
1
vote
1answer
30 views

Using 3rd party libraries on QGIS (Windows)

How can I use 3rd party libraries on QGIS plugins on Windows? I've developed a plugin that uses rasterio and numpy for a customer, but he's having problems installing rasterio and numpy. Actually ...
4
votes
2answers
118 views

arcpy.da.SearchCursor ignores the where_clause parameter?

I'm trying to use arcpy.da.SearchCursor to go through records in a feature class stored in a SQL SDE database. I do so through a feature layer (created in arcpy) called "unit_lyr". When I run the ...
0
votes
0answers
31 views

Optimizing shapefile lookup time?

So, I have a ~1GB shapefile which is running circles around a ~5MB shapefile when it comes to feature look-up time (using python, with GDAL): def check(name, lat, lon, attributeFilter:'SQL ...
2
votes
1answer
87 views

Select by location in Python

I have a polygon layer and a point layer (with coordinates for each point). The polygon layer got created using the MMQGIS PlugIn (Hexagonal Polygons). I want to select all the points inside each ...
0
votes
0answers
24 views

Help how to return values from multiple columns to dictionary [migrated]

can anyone help with how to call additional columns to my dict below please? The example works fine for the return of one set of values (column) but I need to return values for 2 columns that are not ...
0
votes
0answers
64 views

Interpolation using GDAL

I am looking for some hints here. There is a shape file with point data of rainfall sampled at a regular grid, and there is a shape file with point data of soil attributes sampled at a regular grip ...
1
vote
4answers
72 views

How to remove period, comma, symbols using field calculator?

I want to delete . , # in attribute table using field calculator (VB Script or Python). How can I remove these using this example address: N. First St., Unit #1 (I don't need city or state name) I ...
0
votes
1answer
42 views

Iterate through all fields in attribute table and multiply by field

I have a table with a whole bunch of census variables (race, age, education, etc). I want to multiply all of these fields by a factor that I calculated. For example: Field1 has values of 10,20,30,40 ...
1
vote
0answers
44 views

QGIS 2.6 - 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 ...
1
vote
2answers
113 views

How to populate attribute table with sequential numbers?

Using Python, how can we populate a field in a feature class automatically in increasing order? The user must be able to provide the start number. For example, say he wants to populate values from 51 ...
3
votes
2answers
81 views

Using folder wildcards to copy files with Python

I would like to copy the data of one specific shapefile from a specific folder ("Grid") to a number of folders containing the name "Country". The country shapefiles would keep their original name. ...
1
vote
1answer
32 views

pyProj Coordinate Transformation Incorrect

I'm using pyProj to transform extents between two different geographical systems. In a case when both my systems are the same I expect to get back the same extents as inputted but this isn't happening ...
0
votes
1answer
75 views

Problem with addιtion abstraction in Field Calculator

I want a bit analytical respond for the mistakes I have done in my code cause I am new to programming. I am using ArcGis 10.2. and I must process a field with distances in an attribute table I have. ...
0
votes
2answers
36 views

How to use SQL within python in ArcGIS Labels

I'm trying to create labels across a one-to many relationship and have tried a simplified version of this method. My version looks like this: def FindLabel ( [NAME_V2] ): import arcpy ...
1
vote
1answer
29 views

Rename output shapefiles in PyQGIS

I have a shapefile which resides in a folder, gets processed and the output is saved in another folder. Before the output, I would like to rename the shapefile slightly differently from the original: ...
0
votes
1answer
53 views

Using pandas in Python window of ArcGIS for Desktop?

How can I import pandas module in ArcGIS at figure. I want to calculate poisson and negative binomial, so I think I need import pandas or other modules. import pandas as pd Runtime error ...
0
votes
0answers
30 views

How to skip non-empty fields in a model?

I have a model which iterates through a GDB, populating the same attribute field in every feature class with a parameter value. In this way I can mark all FC's in the geodatabase as to what project ...
2
votes
4answers
149 views

Using Loop function with arcpy.Exists()?

I have a code snippet using elif that checks if a file exists and continues to check through the letters of the alphabet (for example _A, _B, _C etc). All works fine but I think there must a better ...
4
votes
1answer
83 views

How to write to a single table via Python multiprocessing

A comment in the post Can multiprocessing with arcpy be run in a script tool? got me thinking, as I often need to do exactly this: Just beware of deadlocking situations (two Insert cursors in the ...
0
votes
1answer
40 views

Script not processing shapefiles from one folder to another

I am working on a script which takes shapefiles from one folder called "Original files", process them and then output the results into another folder named "Processed files. I asked a question on how ...
0
votes
0answers
35 views

How to import osm.pbf file into database with Python Imposm

I want to import a .osm.pbf file with the Python library Imposm. Currently my work flow is the following: import requests import os city_name = 'santiago_chile.osm.pbf' url = ...
2
votes
1answer
57 views

Python code for decreasing polygon size based on percentage?

I would like to decrease the size of polygons by percentage and not by distance in order to implement this into ModelBuilder to loop over a number of polygons. To my knowledge this tool is available ...
0
votes
0answers
48 views

Calculating distance from PointGeometry object to polyline in arcpy

I created a PointGeometry object on ARCPY and I'm trying to measure the distance from that point to the closest point on a polyline table.. The PointGeometry object has an easy function for that ...