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

learn more… | top users | synonyms

3
votes
1answer
37 views

How to refresh the view in QGIS Print Composer using Python?

I am trying to automate the printing of maps based on different attribute classifications using Python in QGIS. Everything is okay except for when I open the printed image, the labels are blurry. ...
1
vote
1answer
68 views

Importing file geodatabase (GDB) to table of contents (TOC) of ArcMap?

I have a geodatabase with several feature dataset and feature classes associated with it respectively. I would like to create a .mxd where the Table of contents consist of group layer and each group ...
2
votes
4answers
104 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
0answers
56 views

Identifying certain polygon from overlapping set

To clean up a large shapefile, I am looking for a way to do the following: I have the ID of many polygons which need getting rid of stored in a list. These polygons are villages and a second ...
0
votes
0answers
24 views

Export qgis vector layer to PostGIS table using python

I've created script, which does bunch of stuff, and in the end, I would like to export it to postGIS table. What is easiest way to do such export using qgis api or sth. I dont want to write SQL ...
1
vote
1answer
29 views

Raster created by python GDAL interpreted upside down

I am using CRS which has axis in left bottom corner. Code below produce Geotiff which is shown allright in QGIS but when I open it in other software it is upside down. Also gdal_calc takes it as ...
1
vote
1answer
46 views

how to convert kml to wkt using geodjango or python?

in geodjango i found that i can use WKT to insert geometry such as: pnt = GEOSGeometry('POINT(5 23)') but it doesn't show how to do it if the data is KML, as my data is in kml format, so my plan is ...
0
votes
0answers
31 views

How to get rid of suffixes from several shapefiles in a folder [duplicate]

I have several shapefiles in a folder and each one is suffixed by “ _LINES” or “_AREAS” I would like to get rid of these suffixes California_Aqueduct_LINES.shp --> California_Aqueduct.shp ...
2
votes
1answer
61 views

ListRasters based on filename using Arcpy

I am trying to create a python script for ArcMap which calculates the ndvi from two raster images for each RGB/NIR pair in a folder. However, I am unsure how to create two raster lists; one which ...
1
vote
1answer
42 views

How to ascertain if a cell/field contains a value in ArcGIS attribute table

I have done a bit of research on this but can't seem to find an answer. I am wondering if there is a way to identify whether a cell/field in the ArcGIS attribute table contains a value using the ...
3
votes
2answers
92 views

How to determine number of features in GeoJSON file using Python or JavaScript?

Is there a best way to determine the number of features in a GeoJSON file? Ideally using Python or JavaScript.
0
votes
0answers
65 views

Looping through each specified layer and exporting PDF map showing shapefile and information taken from each attribute table?

I have been working on an automation script for the purpose of mass pdf exportmaps. I am required to export many pdf maps showing individual boundary files and client information. I believe the ...
2
votes
1answer
53 views

How to check shape length before running code in Python/ArcPy?

I am using a code to convert a polygon into evenly spaced parallel lines for point in range(0,numPoints+1): shortPoint1 = currentLines[firstLong].positionAlongLine(lineSpaceNum*point) ...
2
votes
1answer
67 views

how to load the QGIS openlayers_plugin in standalone python script (not the QGIS embedded python console)

if I try to load the openlayers plugin in a standalone application it always fails with False, although paths are set, and plugin shows available. (tested on Ubuntu 14.04, QGIS 2.4, python-2.7) ...
1
vote
1answer
30 views

ArcGIS 10.2.1 working with time and reporting when feature geometry has changed

I'm working, with ArcGIS 10.2, ona whole lot of petroleum licencing data that chops and changes, in active areas, on a relatively frequent period. i collect the geometry data month by month (saving ...
0
votes
0answers
52 views

Exporting table of contents (TOC) with group layers to file geodatabase (GDB) with feature datasets?

I have created a python code for exporting shapefiles from TOC from different source folder to a output folder. However, in this case, I have some group layers in the Table of Contents (TOC). ...
1
vote
1answer
57 views

Listing all feature datasets and classes from multiple geodatabase into CSV file? [duplicate]

I have a folder having multiple geodatabase and I am calling that folder “Multiplegdb” There are 3 geodatabase in a folder which are as follows: ABC.gdb UVW.gdb XYZ.gdb Each geodatabase have ...
0
votes
1answer
43 views

QGIS Python - Convert the CRS of an in memory vector layer

In a python script of qgis I load layers from different datasources using the QgsVectorLayer() and the QgsRasterLayer() commands. The coordinate reference systems of the data sources differs. Since I ...
1
vote
1answer
38 views

Creating multiple Feature Datasets from table/list using ArcPy?

How to Create multiple Feature Datasets from a table/list. I can create a single feature dataset in a geodatabase with this python code. import arcpy from arcpy import env env.workspace = ...
1
vote
2answers
54 views

Creating a plugin tutorial

I am looking for a tutorial of how to create a plugin for QGIS. I want a tutorial that: Explains about the latest version of QGIS Working in windows environment. adequate for absolute beginners and ...
1
vote
1answer
114 views

Simple field calculator equation in ArcGIS 10.2.1 not working with python parser

I am trying to calculate a percentage in a field in a table. customers and total_customers are short integer fields. arcpy.AddField_management(tableSepSel2, "percent", "DOUBLE") ...
0
votes
0answers
61 views

Why will my field calculator python function always return Null if any inputs are Null?

I've written a simple python function that outputs a list based on yes/no fields. It appends a word to a list if it has a "yes" in another column then writes the list, formatted according to the ...
1
vote
0answers
76 views

Cumulative field calculation using Python in ArcGIS for Desktop?

I am using the following Python code to sum cumulatively but I need the summation to take place while the other field is equal to 1 and then again start the summation when it's equal to 2. I need the ...
3
votes
1answer
145 views

Extracting centerline of a Complex-Polygon in PostGIS/Python

Any idea how to extract the centerline of the following polygon (Fig1) using PostGIS functions or Python modules? I was trying Voronoi Function but thats not helpful for this kind of shape. I want ...
2
votes
0answers
69 views

N Nearest Neighbours efficiently PostGIS/Python

The data is worldwide about a million points, lat/lons, with an id and an importance value (0.0 to 1.0), and it's limited to being on land. Ideally I need to cluster all 1 million points into 100,000 ...
2
votes
1answer
51 views

Loading features attributes into numpy array

I am currently working on an add-on that relies on the user choosing fields of tables (that can be from shapefiles, csv or dbf) that are open in QGIS and then making computations with such data. ...
3
votes
1answer
87 views

Using if/elif for passing null values to Python of label expression in ArcGIS for Desktop?

I am trying to pass the Null values in label expression in advance python section. I have this code and it's not working. Note that all my values in [TX_SECT] and [ABSTRACT] are numbers. def ...
1
vote
0answers
30 views

Finding areas with high POINT density from PostGIS table using Python

I have a PostGIS table with thousands of POINT objects and I want to find areas that have a high density of points. I have the DBSCAN clustering algorithm implemented in Python which does exactly ...
0
votes
2answers
47 views

Parse PHP/HTML to shapefile or similar

I've been experimenting with scraping spatial data from a web page (www.majidata.co.ke). I've managed to find the source of the vector data from within a webpage though and have saved a chunk as HTML ...
1
vote
1answer
47 views

select random rows with python in arcgis

I am new to using Python in ArcGIS, and I wonder: how do I select random lines (or every two lines) of an attribute table? I must select these lines and calculate them, so they are different from ...
3
votes
2answers
124 views

Python code to compare two fields in different feature layers?

I have two shapefiles which encompass 3897 features each. Corresponding shapefiles (village and watershed that flows into it) have the same ID (ws_id in one, OBJECTID in the other). Many watersheds ...
0
votes
1answer
44 views

Cause of ExecuteError: ERROR 000539: Invalid field County Insets.OBJECTID Failed to execute (CalculateField)?

The following script joins two layers on a common id and attempts to use the OBJECTID in the joined table to update records for a field in the input table. In running it in "current" mode, it moves ...
0
votes
0answers
41 views

How to manage two map items in a QGIS composition with python?

I need to manage two different map items in the same map composition, with a stand alone python script. Each composer map has been referenced like this: composerMap1 = ...
2
votes
1answer
49 views

GDAL Python Not Working Correctly - Raster Calculations

I am sure this question has been asked and answered before. I am working with a x64 bit installation of OSGeo4W. I am trying to perform raster calculations using the gdal through the OSGeo4W shell, ...
2
votes
1answer
60 views

How to get into the Python API of QGIS?

After a few hours I am about to give up on finding a kind of documentation for the QGIS Python API that actually works/gives the correct information. It is obvious that there is no actual code ...
1
vote
1answer
33 views

QGIS raster calculator using abs() function

Is it possible to use the Abs() function in the raster calculator in QGIS? I've tried it, but it didn't work.
1
vote
0answers
33 views

QGIS processing framework SAGA NaturalNeighbor in external Python Script - No Output

I want to build a little script, which generates a NaturalNeighbor grid based on a point Shapefile. The script runs within my PyDev environment without any error messages, but no outputfile is ...
2
votes
1answer
50 views

arcpy with multiprocessing throws “UnpickleableError: Cannot pickle <type 'geoprocessing Layer object'> objects”

I'm attempting to speed up a process which is currently running synchronously, by using the python multiprocessing module. I'm having trouble sending a feature layer to a function which is called by ...
3
votes
1answer
51 views

Generate end points from a layer that contains multiple lines

I generate a layer file that has multiple parallel lines, that I want is to sequentially (from OBJECTID(1) to OBJECTID(Max)) create a point at each end point of the line segments and number these ...
1
vote
0answers
24 views

Setting up ArcPad applet (Python) that calls arcgisscripting?

I've been asked to support a legacy script that was "made" (read: found) by a former coworker. My python skills are pretty basic, so I went right to installing the applet like I would for a VBS ...
3
votes
2answers
109 views

How I can reverse numbers in a string without reversing any text? [closed]

I have a string, I need to reverse just the numbers in the string without the text: String: [321 test] The result will be: [123 test]
7
votes
1answer
119 views

Meaning of exclamation mark in Python parser of ArcGIS Field Calculator?

In the following line, I don't understand what those exclamation marks mean? And why put everything in quotation? I don't understand the purpose of the variable expression, please explain to me as I'm ...
1
vote
1answer
45 views

Populating Access (*.mdb) table with text from Text Elements to inventory MXDs using ArcPy/Python?

I am trying to write a piece of code to populate an Access mdb table with information from text elements in an mxd (text elements all have "names"). The purpose of this is to create a catalog of my ...
1
vote
2answers
109 views

Split a string column into 2 columns in python [closed]

I have a csv file and this is the structure of that file. It has only one column with number of strings. I want to split this one column into 2 columns at the character \. Can anyone please tell me ...
0
votes
1answer
41 views

Explicitly close a OGR result object from a call to ExecuteSQL

How can I explicitly close/release the result of an ExecuteSQL statement when querying a Spatialite database with OGR via Python? I have a simple query to return the SRID of a dataset. This works as ...
1
vote
1answer
77 views

List all Feature datasets & feature classes from a single geodatabase into CSV

I have prepared a python code and I got the following errors: "Parsing error IndentationError: expected an indented block (line 11)" and "Runtime error Traceback (most recent call last): ...
0
votes
1answer
27 views

Handling KML/CSV with geopandas - DriverError: unsupported driver: u'CSV'

I'm trying to import a dataset of UK postcode districts UK postcode districts from Google Fusion tables into geopandas with the aim of splicing it to a dataset of house prices. The problem is that ...
2
votes
1answer
47 views

Python to change file names in a directory

I am converting a directory of kml files to 1 single fGDB, but they all have the date as the file name. This creates a problem when using the original name because of the number at the beginning of ...
-1
votes
2answers
82 views

arcpy.Delete_management(“”) not working

I've written a script in a python toolbox. That script creates a folder in the user defined workspace for all the output files that are created during the script process. When the script is done, I ...
0
votes
1answer
43 views

Label related records in ArcMap from enterprise geodatabase

Two questions related to labeling 1:M related records in ArcGIS 10.2. I have successfully built an Advanced Label expression in Python to label records from a related table. I am currently working ...