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

learn more… | top users | synonyms

1
vote
0answers
57 views

How to wait for mapCanvas render before taking a screenshot?

i am trying to iterate over a large list of features and making a screenshot of the selected feature. My problem is that it seems to be a delay between the refreshing of the canvas and the taking of ...
0
votes
0answers
47 views

How can I upload CSV file in QGIS Desktop App?

Please see link : http://www.qgistutorials.com/en/docs/building_a_python_plugin.html I am using the same process for uploading a CSV file in a folder but it gives me an error. I am using this code: ...
1
vote
1answer
44 views

Calculating a z value in python

I have some contours where the z value is stored in the geometry and I want to display it as an attribute. I want to include this in a python script. I have an expression which does this in python ...
0
votes
0answers
27 views

Osgeo4w installation (qgis 2.8.2) error [closed]

I am installing QGIS 2.8.2 through OSGEO4W installer (32 bits) but in this moment, I get several errors of "Unable to get license....." in some librarie. What is happening? Also, there isn't ...
1
vote
0answers
23 views

How to react to network events

I am in the process of writing a Plugin which should react to some data (XML-Format) sent via a socket connection. Since I have never worked with IPC in terms of python before and my knowledge of IPC ...
1
vote
1answer
51 views

Calculate slope of line based off of point layer

I have a line feature class that needs to have its slope included as a field. I have a point layer that contains points and their elevations for the start and end of the line segments. How can I ...
2
votes
2answers
50 views

Critical facility pipe connections in python

I'm trying to find a way to determine pipeline connections located downstream a critical facility and score how far those connections are from the facility. Is there a way to accomplish the above ...
2
votes
1answer
96 views

Cutting polygon using line - cutter, cut() - using ArcPy?

What I'd like to do, using ArcPy: use a line to split a bunch of polygons into separate parts. Here is what the inputs could look like: In this case the line should split each polygon into two ...
0
votes
1answer
32 views

Using a list to access database from a layer

I am trying to access the database using a list in order to put it in a loop but I can't make it work. I want to replace the months with a list variable. This is the hard core example: ...
1
vote
0answers
11 views

Couldn't load plugin sextantelwgeomprovider, QGIS 2.0.1 on Ubuntu 14.04.2

I'm getting this error message when I start QGIS Couldn't load plugin sextantelwgeomprovider due an error when calling its classFactory() method Traceback (most recent call last): File ...
2
votes
1answer
32 views

How can I create a polygon from points and assign it a color in QGIS using python?

I want to create a new vector layer, containing a polygon from a set of given points, and giving it a color.
0
votes
1answer
24 views

different data types in ArcMap field calculator?

I would like to run the following pre logic code in the Arcmap field calculator: def calc(f, fn, f1, f1n) f= str(f) f1 = str(f1) f = f.replace(" ", "") fn = fn.replace(" ", "") f1 = f1.replace(" ...
0
votes
0answers
36 views

simple if statement in ArcMap field calculator

I have two fields containing string variables. The first one is f and the second one is f1. I would like to create a new field and populate it with the following: if f1 is equal to f, return f1 if ...
4
votes
3answers
76 views

How to use Python for online GIS? [closed]

I consider myself a GIS expert, and I have successfully completed many GIS projects for clients. I am proficient in spatial analysis, ArcGIS, QGIS, and quite good in Python as well. However, I am only ...
3
votes
2answers
38 views

Joining polygons to polylines based off specific point in polyline being within polygon

I am trying to join a polyline feature class and a polygon feature class. The polylines will always have at least their first point in a polygon, and each polyline consists of exactly three points. ...
0
votes
2answers
48 views

qgis2web python error message

Some times qgis2web pluggin does not work. I have this python error message: Ha ocurrido un error mientras se ejecutaba el código de Python: Traceback (most recent call last): File ...
0
votes
0answers
12 views

How to set extent of spatial SQL query in python (geoalchemy)

since days i've been hustling around trying to figure out, how to properly query data from a PostGIS database using geoalchemy2, an extension to python's sqlalchemy supporting spatial database ...
1
vote
0answers
27 views

Generating shapefile of polylines using pyshp from a csv file and opening file in qgis

I tried the solution posted in: Creating Polyline from GML using PyShp?, Using PyShp to convert polygons in *.csv to *.shp files? and Using PyShp to create polygon shapefiles? to generate ...
1
vote
2answers
45 views

Editing .tiff rasters in Python

I am triying to edit .tif rasters in python, but I have some issues regarding the tiff to array converstion. I read there are multiple options for opening rasters (gdal, PIL, matplotlib), but which ...
1
vote
1answer
43 views

How to search for a specific field and then use it in Field Calculator

I have a piece of code where the goal is to search through the field names within a feature, select any field based on a specific character (in this case "z") and then use that selected field within a ...
1
vote
0answers
14 views

How can i add sub menu under custom top menu in QGIS using python

I have added "My Tools" Menu on top. Now i am clicking on "Plugin" then selecting QGIS Plugin bulider. Here in the menu field a drop down list is coming. How can i add "My tools" in this drop down ...
2
votes
0answers
30 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 ...
2
votes
1answer
53 views

Processing algorithm fails from Python script

I'm trying to write a Python script performing a geoalgorithm. What is surprising me is the following: I first test the algorithm by QGIS (2.8) interface. In my case, the GRASS interpolator ...
1
vote
0answers
47 views

How can i add custom menu in QGIS Using python

I am tried to add a custom main menu in QGIS Desktop Application. Here I am already added custom sub menu in QGIS but I want to add a custom main menu in QGIS using Python. See the blow image.
5
votes
3answers
152 views

How to find and replace attribute values based on a list

I have a Shapefile and a list in .csv which contains two columns with names: "Old_name" which contains the old names that already exist in the attribute table of the previously mentioned Shapefile; ...
0
votes
1answer
42 views

Custom Script Tool Error - 000732

I am having a problem when impoting a script into a custom script tool. I am not the strogest person with python, but I have an existing scipt tool which was created by someone who does not work here ...
3
votes
2answers
69 views

Which python function should I use to populate a string field based on a numeric value from a numeric field in ArcGIS Field Calculator

I am new to Python and I'm trying to write a simple if then statement in Field Calculator in ArcGIS 10.2.2 that will take the values from a numeric field and add them to a string field. I can't ...
2
votes
1answer
44 views

QGIS re-write loop efficiently, assign number to every row of a column,

I have a column titled CompanyNam and I need to extract the ownership information. For example, if CEZ is the first company then, I assign to it number 1, then Sokolovska is the next number, etc. If ...
1
vote
0answers
20 views

surface area in a basin with reference to incremental height of DAM

I want to calculate "surface area in a basin with reference to incremental height of DAM" i tried this: step_size = 10 # metres; reduce this if you want finer resolution num_steps = 20 # increase ...
2
votes
1answer
39 views

QGIS set all layers with custom transparency with python?

I'm exploring QGIS python functions to set all raster layers with a custom transparency, i.e 0,0,0,100 . Looking at some previous questions. There is a way to loop all the layers, but the aspect to ...
4
votes
1answer
88 views

Replacing multiples words using field calculator in attribute table python

I need to replace multiple words with one word in a field at one time in one script. Example in my LettersField I need to replace all the "Aa" and all the "Bb" and all the "Cc" with "Rr". I am ...
2
votes
1answer
36 views

QGIS crashing/failing when dissolving multiple shapefiles in a Python loop

I am using QGIS 2.10 (but I've also tried 2.8) to loop through all the shapefiles in a folder (those ending in .shp) and perform a dissolve function on each of them. However, when I run the following ...
1
vote
2answers
28 views

Trouble inputting interger values into an SQL statement within ArcGIS

So I am defining a function for use in a ArcGIS tool that will verify attributes, catch errors, and obtain user input to rectify those error. I want the tool to select and zoom to the segment that is ...
1
vote
0answers
40 views

How to define a custom function that returns value of a field in an unsaved form

Filter expression builder in QGIS 2.8 allows us to define custom functions using python. I'm intrested would it be possible to define a function which returns a value of a field in an unsaved form ...
0
votes
0answers
14 views

Attribute Table Column to Python List (QGIS 2.0)

I have a column of strings in my attribute table and I want to create a list out of this column. How can I do this? my attribute column of interest (CompanyNam) looks like this: Eva Ela REW Scot ...
0
votes
1answer
46 views

How to quantify the coverage area?

I have a task where I shall quantify AIS coverage in a predefined geographical area. The AIS is a system where automated positional data is sent from ships to base stations. I have AIS data with ...
1
vote
1answer
26 views

Python ogr filter attribute SQL

I have a shapefile with 4 attribute fields (MC_ID, MC_info, C_ID, C_info). I want to change some MC_ID values selecting the features by C_info. For example: I want to set MC_ID = 2 for C_info = g19, ...
0
votes
0answers
28 views

unable to use matplotlib in qgis using python

I have tried to draw graph using matplotlib i used this library in my qgis application but i got the error ImportError: No module named backend_qt4agg i used following code in my qgis python ...
0
votes
2answers
44 views

Using python string wild cards within the field calculator ArcGIS 10.3.1

I have two fields. One field has an ID. The other field has a list of ID's. Using the Field Calculator I with to calculate 1 or 0 if either field contain the same ID number. I was successful at ...
0
votes
0answers
23 views

Determining Centroidal Longest Flow Path using Python (and not HEC-GeoHMS)?

I've been using the Centroidal Longest Flowpath from the HEC-GeoHMS Basin Characteristics Toolbox. The explanation from the HEC-GeoHMS manual is that the centroidal longest flowpath is computed by ...
3
votes
1answer
52 views

Reading Synthetic Aperture Radar raster images using python

Is it possible to read and modify Synthetic Aperture Radar raster images using python? gdal is not able to understand their Type which is Binary (application/octet-stream). One can find sample radar ...
0
votes
2answers
54 views

Capitalizing 5th word in Python string? [closed]

I understand how to capitalize first word using !CITY_NAME!.capitalize(). However, if I have a string in a record and I want to capitalize the fifth word, what is the code for that? Ex: 3 Boundary ...
2
votes
2answers
47 views

Reserved Ampersand Character in Label Expression of ArcGIS for Desktop?

I have this code which works... def FindLabel ([NUMBERNAME], [NUMBER], [BLOCK], [SURNUM]): lineone = "A:"+ [NUMBER] absName = "<CLR red='255'><FNT size = '14'>" + [NUMBERNAME] ...
1
vote
3answers
78 views

Autopopulating text field with string and number combination

I have an attribute table with a text field which indicates a unique identifier for each row. The identifier includes a combination of text and numbers, sequentially increasing, as follows: ...
3
votes
2answers
93 views

SyntaxError from Python Label Expression in ArcMap?

I am trying to use a find label expression that changes the font of one field, [NUMBERNAME]. I am using the Python parser of ArcGIS 10.3.1 for Desktop. All fields have a data type of text. This is ...
1
vote
1answer
56 views

Efficiently Calculating Farthest Point from Origin

I'm trying to find a clever/efficient way to calculate the the farthest point from an origin, given a list of lat,lng points. For example, if trying to find the closest point from an origin I could ...
2
votes
1answer
52 views

Execute ogr2ogr from python

I tried to execute ogr2ogr from python with this shell command: ogr2ogr.exe --config PG_LIST_ALL_TABLES YES -f "PostgreSQL" -append PG:"host=hostnamet user=username password=password dbname=dbname" ...
2
votes
0answers
46 views

Gdal Python Problem : Black strips in geotiff

I am trying to use GDAL (2.0.0) Python API in Blender, but I am having some difficulties. I am trying to save geotiffs for : - a 2D numpy array storing 32bits floats - a 3 channels rgb numpy array ...
1
vote
1answer
28 views

XML Document points to the wrong location after using arcpy.BatchProject()

I'm trying to reproject a number of shapefiles representing contours from NAD_83_Albers to NAD_83_UTM_Zone_9N using arcpy.BatchProject(), but I have to use python/regex to preserve a particular file ...
1
vote
1answer
29 views

Using label expression to label highway with last group of numbers in field

I'm using Tiger road files and I want to label the highways with their shield number. Tiger has an inconsistent naming convention for road features; I am specifically concerned with the highways. I ...