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

learn more… | top users | synonyms

2
votes
1answer
351 views

Updating and inserting a field within the same loop

I am working with an empty feature class where I am writing a script to create polylines within the featureclass and attach an associated text value with the polyline. I am using a for loop as noted ...
2
votes
1answer
1k views

how to install networkx python in QGIS

How to install and how to compile networkx python on QGIS? I always get an error that no module named networkx in the console of QGIS I copied the file networkx in C:\Program Files\Quantum GIS Lisboa\...
2
votes
2answers
311 views

How to automate performing analysis (intersection) between objects within different feature classes, for large number of objects?

I have two tables of roads - the same roads, from different sources, and am trying to compare how similar their positions are. I'm wanting to buffer each road in one of the feature classes and ...
2
votes
3answers
1k views

Couldn't load plugin fTools due an error when calling its classFactory() method

When I start qgis I get a python exception: Couldn't load plugin fTools due an error when calling its classFactory() method ... 309, in _import mod = _builtin_import(name, globals, locals, ...
2
votes
1answer
674 views

Convert a List to a file list to use in an arcpy tool

I just can't figure out how to feed a list of files into an arcpy tool... I have List_tif.append(os.getcwd()+"\\Stage1\\"+name+"\\GeoTif\\"+name+"_"+str(ddp.pageRow.PageName) + ".tif;") That ...
2
votes
1answer
533 views

Can you script publishing a GP service?

I have a geoprocessing service in ArcGIS for Server 10.1. I would like to share this service with a number of external organisations that also have ArcGIS Server 10.1. i.e I dont want them hitting ...
2
votes
3answers
2k views

An error has occured while executing Python code while doing home range analysis (Qgis 1.8.0)

It keeps appearing: Traceback (most recent call last): File "C:/Users/Worten/.qgis//python/plugins\HomeRange_plugin\HRplugin_dialog.py", line 80, in QObject.connect(self.buttonBox, SIGNAL("...
2
votes
1answer
1k views

Batch intersect from a text file using Python (ArcGIS)

I am attempting to modify my code below which reads from a text file of shapefiles and executes an intersect and outputs them to a user specified location: import arcpy, sys, os from arcpy import env ...
2
votes
2answers
1k views

GDAL Clipping (hack)

I am trying to use the python script from http://www.sparkgeo.com/labs/2010/07/07/gdal-clipping-hack/ to clip a raster based on many shapefiles. The script is using a mysql database an i would like to ...
2
votes
2answers
1k views

With Python and ArcGIS, how do I add features to a featureclass?

In ArcGIS Python code: CopyFeatures_management copies features to the same featureclass - that means overwrite to the feature class. How can I add new features to one featureclass or namely different ...
2
votes
2answers
327 views

Is code completion available in QGIS Python Console?

I wanted to know if the autofill functionality is available in the python console for QGIS as the one available in ArcGIS Desktop's Python Console or am I supposed to hardcode it.
2
votes
1answer
836 views

ArcPy - Dataframe rotation - Getting a polyline length wise in the dataframe in layout view in ArcMap

EDITED: I'd like to rotate my dataframe until a polyline fits dataframe-width wise in the layout view of a .mxd. If the lines runs north/south I would like the dataframe rotated until the line is ...
2
votes
2answers
3k views

Help with ArcGIS10 Python and SearchCursor reading Null values in field

I'm using a Python script to count the number of unique string values in a feature class. My script works if there are values in the field but if there are any NUll values in the field it crashes. Any ...
2
votes
1answer
566 views

How can I, in a general way, rescale a raster in ArcGIS Model Builder

What I want to do is rescale a few rasters from whatever they are now (i.e., values between -99 and +1000 OR -256 - +256 OR 0 - 3.23) to a normalised value (i.e. values between 0 and 1). I would ...
2
votes
2answers
3k views

How to automate point-in-polygon queries in ArcView?

Layer1 = point shapefile (multiple points, geocoded) Layer2 = polygon (1 attribute; (1,2,3...)) I want a non-gis person to be able input a single address and be told the attribute of the polygon ...
2
votes
2answers
300 views

How to use any ArcMap tool from a python script?

I'm trying to develop a tool that uses some of arcmap default tools like the Sketch Tool or Trace Tool. Is it possible? Let me explain a little more, I need to draw a feature, ask for user input, and ...
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. ...
2
votes
1answer
41 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 (...
2
votes
1answer
75 views

PyQgis: During editing, add new feature attributes

Workflow: Start edit mode -> New feature is created -> On the console (pyqgis), new attributes are set -> Exit edit mode. Problem: The attributes are not saved. Only after completion of the editing, ...
2
votes
1answer
43 views

Using zonal_stats with python in QGIS to calculate statistics for each image

I work with Python in QGIS, I want to calculate statistics for each image that I have with a specify shapefile and save result after, I tried to do like this: from rasterstats import zonal_stats ...
2
votes
1answer
85 views

Creating custom forms in Arcmap 10.3

I am hoping to make a custom form within ArcMap 10.3 where the end user can select a recently digitized shape file (or feature), and enter values of specific attributes through a custom form. This ...
2
votes
1answer
47 views

Why is the first element of my WFS layer None instead of a feature?

I have made a WFS connection and got a layer from it. I want to use the first feature from that layer. driver = ogr.GetDriverByName("WFS") wfs_url = "WFS:http://example.com/wfs" wfs = driver.Open(...
2
votes
1answer
62 views

Suppressing rasterio verbosity

I have the following script using rasterio: if not os.path.isfile(out_dir + os.sep + name_adm1 + '.tif'): with rasterio.drivers(): with rasterio.open(constants.ras_cmask) as src: ...
2
votes
1answer
85 views

QGIS corrupted processing tool

I've been dealing with various problems after re-installing QGIS and other GIS-related software (see QGIS corrupted plugins upon reinstallation). The solution worked for a bout a day and now I lost ...
2
votes
1answer
56 views

How to multiply a user-defined input parameter with a field value within the graphical modeler?

I have the same Question as asked in this post (How to connect input parameter to the field calculator algorithm within the graphical modeler?) and the answer from Joseph already helped a lot: ##...
2
votes
2answers
102 views

PackageLayer_management failing within script, needs to run outside of an ArcMap session

I'm automating a workflow that requires outputting a layer package, it throws the general ERROR 999999 when executing and breaks. It does, however, generate a folder in the correct directory, with ...
2
votes
1answer
94 views

Getting script file name as object in Python? [closed]

I'm quite new to Python and programming in general. I have created a few scripts using Python and as part of my framework/best practices for my scripts, I'd like to display when a script begins and ...
2
votes
1answer
53 views

Fastest way to process OSM

I've been working with imposm and Python, it's fairly easy to parallelise. I've hit a performance problem when trying to associate the coordinates to the ways. Creating a dictionary from ...
2
votes
3answers
222 views

ASCII file with latitude, longitude and data to GeoTiff using Python

I have a .asc file with three columns of data: longitude, latitude and a data value. Each latitude and longitude point represents the location of a centriod of a 1/8 degree unprojected grid. I want ...
2
votes
1answer
323 views

geopandas spatial join extremely slow

I am using the code below to find a country (and sometimes state) for millions of GPS points. The code currently takes about one second per point, which is incredibly slow. The shapefile is 6 MB. I ...
2
votes
2answers
44 views

How to select form the attribute table in with ogr

i want to select the (Sumava) from the attribute table and then make a shape file, my problem is i don't know which function should i use to select this area.if any one can help me? import ogr import ...
2
votes
2answers
249 views

Generate TIN from elevation data in Python (no Arc)

I would like to generate a 3d terrain model of an area, and I am stuck on creating the TIN (which I will convert to an STL). I know there are plenty of ways to use ArcGIS, QGIS, 3DEM, and various ...
2
votes
1answer
79 views

Create new shapefile based on values ranges in existing shapefile using gdal/ogr/python

I have a shapefile containing many thousands of polygons with values stored in an attribute field and ranging 0-105. I would like to create a much simplified file that contains classes for value ...
2
votes
2answers
239 views

Find country from GPS coordinates, offline using python

I'm aware that there are several similar questions already but I have been searching for days and not been able to solve my problem: All solutions I've found require GDAL, which I have not been able ...
2
votes
4answers
422 views

Python Library for converting GeoJSON Multi-polygon to polygon

I would like to know if there is a Python library that can be used to convert GeoJSON Multi-polygon to a Polygon. Note: i want to convert .geojson file Multi-Polygon feature type to Polygon feature ...
2
votes
2answers
970 views

How to calculate the bounding box of a geojson object using python or javascript?

I have django app with leaflet on the frontend and I need to calculate the bbox of my geojson so that I can pass the coordinates to map.fitBounds() I have tried some libs as well as trying the ...
2
votes
3answers
170 views

Search and concatenate Landsat bands with Python

I have a number of Landsat geotiff (*.TIF) file in a folder. The problem is simple, I need to search certain Landsat bands from that list and make a composite tif image. I am using Orfeo Toolbox's CLI ...
2
votes
3answers
326 views

How to create a Projection from a CRS string using pyproj?

I'm trying to convert between two coordinate systems using pyproj: import pyproj p1 = pyproj.Proj("+init=EPSG:4326") p2 = pyproj.Proj("""PROJCS["NAD27 / California zone II",GEOGCS["...
2
votes
2answers
206 views

Merging features (lines) in shapefile with same name using Python and QGIS?

I am working with the NHD flowline dataset (USGS) and some of the line features have the same name. I want to merge the line features that have the same name. For example: There are three features ...
2
votes
1answer
149 views

HDF5 and georeferencing?

I'm doing quite heavy processing of Earth Observation data, and it appears that a lot of my workflow can be speeded up by using HDF5 for local storage. I mostly work with large stacks of raster files, ...
2
votes
2answers
79 views

How to load stored composer from project file in standalone QGIS application?

I would like to load a .qgs file and get a composer from it, but I can't figure out how. Is there a way, or do I have to read the xml myself and individually set the appropriate values for the ...
2
votes
2answers
165 views

Store in a python list the attribute table of a vector in QGIS

I'm stuck with a very simple issue.. I've loaded in QGIS (through the py console) a csv layer (no geometry) made of 4 fields and 3 rows: #load the csv layer = QgsVectorLayer("path/to/the/csv", "...
2
votes
1answer
74 views

Dissolving a TIN using python/ogr binding

I have a TIN model where I remove some of the triangles (see fig. 1). Most of the triangles touch on one edge, some on one vertice. I would now like to generate a polygon shapefile containing the ...
2
votes
2answers
71 views

How to successfully do “nested” looping over a Fiona collection

I wrote some code that basically loops over all features in a shapefile with Fiona in Python, doing some things, calculating some things, etc. I found that it would exit the for loop prematurely, ...
2
votes
1answer
106 views

python crashes with returned gdal band object from a function

I wrote these two functions in a module when I want to read the band in NetCDF or HDF files and return the band outside the function. Each HDF and NetCDF has many subdatasets. Each subdataset in a ...
2
votes
1answer
149 views

How to launch Processing tool User Interface using PyQGIS?

I am trying to launch the UI of a processing algorithm using Python script but I cannot find a simple way for it (aside double clicking on it in the process toolbox of course). The plugin is a water ...
2
votes
1answer
192 views

How to find if map layer registry is empty?

In my script I want to open layer named my_layer if it is in the map layer registry. I use following code for it: inputLayer = QgsMapLayerRegistry.instance().mapLayersByName("my_layer")[0] If not ...
2
votes
1answer
117 views

How to create a new empty memory layer with fields scheme from other layer in QGIS?

Being a complete noob with python so far, I got inspired by this answer: http://gis.stackexchange.com/a/155988/8202 to dive into it a bit. When creating features in a new target layer from an ...
2
votes
1answer
77 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 ...
2
votes
2answers
221 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] ...