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

learn more… | top users | synonyms

2
votes
1answer
691 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
541 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
328 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
845 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
1answer
569 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
1answer
52 views

Python if, and, or to compare field values and assign new value

I have 3 fields in a table that i need to evaluate and return a new value based on the results using the field calculator (PYTHON) They are: SETSPAID (long) This field must = 0 TYPEOFSERVICE (string)...
2
votes
2answers
63 views

Save line geometry as points geometry in QGIS (pyqgis)

I have line and polygon layers. I want to make a list of points' coordinates (ends or begginings of lines), which are touching the polygons. The coordinates which I need are selected as yellow. ...
2
votes
1answer
56 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
78 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
48 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
106 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
69 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
63 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
101 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
59 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
103 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
114 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
56 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
284 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
393 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
46 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
309 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
82 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
4answers
510 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
1k 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
181 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
1answer
270 views

Plugins crashing with “No module named qgsprojectionselectionwidget” in Windows?

My Python QGIS plugin works on Ubuntu (at least for me, and all fatal bugs reported so far are solved), but when I run it on QGIS installed from the official 2.10.1 64-bit installer for Windows (on ...
2
votes
3answers
381 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
235 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
164 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
87 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
183 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
78 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
118 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
155 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
202 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
126 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
81 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
243 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] ...
2
votes
1answer
77 views

How to add a message bar to custom canvas?

There is a simple code to add message bar to main window in QGIS: iface.messageBar().pushMessage("Hello","World") My question is how to add bar to my custom canvas canvas = QgsMapCanvas() in ...
2
votes
2answers
286 views

QGIS/Python script to generate random points many times

Good day. Can anybody provide a simple code to be run in the Python Console of QGIS (I am using 1.8 Lisboa) to generate X number of random points (say e.g. 5000) over a certain global shape of ...
2
votes
1answer
89 views

Replace Expression in Field Calculator to include a Numeric Range

There has to be an easier way to clean up address data, I hope? GeoCoding, I need to remove APT# and any number or letter that follows.
2
votes
1answer
199 views

problems overwriting files in ArcSDE with python script

I'm having a great deal of difficulty overwriting files when using ArcSDE. The usual 'arcpy.env.overwriteOutput' method doesn't seem to work. When I run this script: import arcpy from arcpy import ...