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

learn more… | top users | synonyms

0
votes
2answers
110 views

gdal_grid performance issue — alternatives?

I use gdal_grid within a Python script, but for my large files the calculation time is enormous. Apparently this is a gdal_grid issue http://trac.osgeo.org/gdal/ticket/2411 Does anyone have an advice ...
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
1answer
97 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
694 views

ArcPy SelectLayerByAttribute Error and how to control GP output layer name

I have a rather long script that first references an SDE feature class (non-versioned) to perform an attribute selection based on a SQL selection. I've been unable to figure out why the script will ...
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 ...
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: ...
0
votes
1answer
308 views

Error in Select Numeric type column in pyodbc with ArcCatalog

I created a python script that uses "pyodbc" plugin to connect a SQL Server database and write out data. It was imported in an ArcGIS 10.1 tool and run from there. try: arcpy.AddMessage('FLAG 0') ...
3
votes
2answers
41 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
50 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 ...
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(" ...
2
votes
1answer
146 views

PostgreSQL PL/Python Function for “IF” condition

I am using OSM data to run pgr_dijkstra() for weighted-path calculation. But after importing OSM data using osm2pgsql I populated some additional columns into my ways table. So now it has gid serial, ...
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 ...
3
votes
2answers
589 views

How to find unique values of an attribute with python in qgis?

i look for solution to get the unique values of an attribute of a vector layer. what is the best way in python qgis to get the unique values of one distinct attribute? I work with qgis 1.8.0.
3
votes
2answers
2k views

Python script to export .csv tables from GDB

I am very new to Python programming and have been tasked with writing a program to export a csv file from a file geodatabase feature class. The csv should contain only certain fields and the records ...
3
votes
1answer
215 views

Is it possible to run a search cursor on a multipart feature class?

I have a multipart feature class of cities. I want to run a search cursor on a cities feature class where: one city is selected and a select layer by location is run to select all parcels that are ...
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
246 views

Is there a function to select a region of a map for further processing with Python?

I would like to select a map's region in QGIS for further processing with python console. Ideally I would like to select the region with a mouse drag (like Gimp crop function) and then e.g. analyze ...
5
votes
3answers
155 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
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
1answer
76 views

Python/GDAL hyperspectral Image wavelengths

I can open and read a hyperspectral image using GDAL according to the instructions brought by Max König here: So after reading the data like this : data = gdal.Open( filename ) then I can see ...
1
vote
0answers
28 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 ...
4
votes
3answers
4k views

Using PyShp to convert polygons in *.csv to *.shp files?

I'm converting csv data to shapefiles using the pyshp python library. What I want to do is very similar to Using the python shape library: pyshp - how to convert .csv file to .shp, except that I ...
1
vote
1answer
226 views

Creating Polyline from GML using PyShp?

I have a problem in creating some polylines in one Shapefile with PyShp 1.2. The plan is to read a GML file containing LineStrings and create a shapefile. The theory is clear, but the realworld is ...
0
votes
2answers
110 views

cadtool and spline plugins not working

Am trying to edit a line shapefile using a spline tool in QGIS 2.4.0 .Its drawing but the ok button is inactive. what could be the problem? Generally am trying to create a curved line.
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
2answers
46 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 ...
3
votes
0answers
351 views

QGIS API - Print Composer Template produces empty map?

I have a print composer template which I'm trying to populate with different subset queries from a CSV-derived vector layer using the Python API. However, all the output PDFs contain everything except ...
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 ...
1
vote
1answer
152 views

How to enable the snapping options for vector layer using the python programming?

I want to enable the snapping options for the the existing layers using python programming. How can I do this?
2
votes
0answers
32 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 ...
0
votes
1answer
345 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 ...
2
votes
2answers
1k views

OSR Python testSR.ImportFromEPSG(4326) returns empty spatial reference

This is empty using Python .ImportFromEPSG(4326): import osr #this fails: testSR = osr.SpatialReference() testSR.ImportFromEPSG(4326) print testSR.ExportToPrettyWkt() #why did the import from EPSG ...
4
votes
1answer
89 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
171 views

Extract data from netcdf using a shapefile polygon in python

I need to subset data from a NetCDF using a specific shapefile. The data are sea surface temperature and ocean color at 1/4 degree resolution. I have 4 polygons describing the US. Northeast ...
1
vote
0answers
48 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.
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 ...
3
votes
2answers
70 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 ...
81
votes
5answers
13k views

How do I access ArcObjects from Python?

I would like to be able to script some things that are not exposed via arcgisscripting or ArcPy. How do I access ArcObjects from Python?
6
votes
2answers
2k views

ArcObjects + comtypes at 10.1 and newer

Has anyone played around with using ArcObjects in Python at version 10.1? I am having all sorts of problems, such as TypeErrors when wrapping the ESRI OLB modules and AttributeErrors when attempting ...
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 ...
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
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 ...
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 ...
4
votes
1answer
2k views

gdal ImportError in python on Windows

Trying to import gdal for Python 2.7.3 on Windows XP: >>> import gdal Traceback (most recent call last): File "<stdin>", line 1, in <module> File ...
2
votes
4answers
244 views

Field Calculator Python Expression Issues

I'm pretty new to Python and this is my first post on this forum so I could use some help. I am currently attempting to run some code in the Field Calculator in a model in order to replace string ...
2
votes
3answers
2k views

ExportToJPEG() arcpy script failure

I'm attempting to writing a python script that will automate exporting a set of stock maps to JPEG from their mxd files, and I'm having some strange issues getting there. I've alternatively been ...
1
vote
2answers
29 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 ...