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

learn more… | top users | synonyms

5
votes
2answers
211 views

Using newly created features in the next part of a python script

Good Afternoon I am trying to write a python script which buffers a large number of features from a geodatabase (but not all) and then dissolves the newly created buffer shapefiles together. ...
1
vote
1answer
800 views

how to get the projection from a vectorlayer in qgis?

Hi I am trying to set the projection on a raster to match that of a vector point layer. Thus I need to findout what is the projection of a give layer, to use it in the GDAL.Dataset.SetProjection() so ...
3
votes
0answers
940 views

How to create mask bands in GDAL and Python?

I have small program in Python that uses gdal and numpy to perform a logarithmic scale of some data into the RGB 0-255 range. Now this input data has a nodata value set to mask the valid values, and ...
2
votes
1answer
293 views

Python script for Data Driven Pages to run a series of DDP at once?

I have a several different polygon shapefiles that I am using to create individual maps for each polygon within the shapefile. The layout is the same for each map, the only thing that changes is the ...
0
votes
0answers
104 views

How to create a pop up attribute table for each crash located on a roadway segment in arcmap

I am trying to create a simple user interface that displays information for each crash located on the routes. I also need to display a graph along with that. I am a beginner in Python with no prior ...
0
votes
1answer
557 views

Error : keyword can't be an expression

I am getting "keyword can't be an expression" error while running the following code: >>> import arcpy >>> arcpy.MakeFeatureLayer_management("Point","P1","Layer" = 'WM-VALVE-ID') ...
1
vote
1answer
438 views

ogr: how to use epsg database for RD New projection?

I'm trying to assign this EPSG projection to my newly created shapefiles using ogr. The OGR Projections Tutorial says: ...any geographic coordinate system in the EPSG database can be set by it's ...
4
votes
1answer
602 views

How to Create a raster layer from a numpy array using pyqgis?

I am working on a plugin for Qgis to calculate spatial Kernel density maps. I have all the calculations working, all I am missing is a way to turn a Numpy Array, with density values into a multiband ...
0
votes
1answer
106 views

Creation point layer from linear layer with only ends of lines

I have ArcGIS 10 with ArcView licence and I need to make point layer from a linear layer, with only start and end points for each line. In ArcInfo I could use Feature Vertices To Points with ...
10
votes
2answers
268 views

Count raster value in a bounding box (spatial extent)

I have simple question: given a bounding box, how can I count the number of specific values (say, I am interested in the number of value == 1 ) in a raster in 1) arcpy, or 2) raster package in R?
4
votes
1answer
777 views

Retrieve path and file name of current qgis project in python

Is there a way to get the path and the file name of the current project from a python script? I'm currently trying to develop a python plugin for qgis and I need to create a file with a similar name ...
1
vote
2answers
219 views

What is the difference between Geoprocessing Map object vs. MapDocument object in Python

I have the following code: mxd["C1"] = arcpy.mapping.MapDocument(os.path.join(fRoot, filename)) mxd["C2"] = [arcpy.mapping.MapDocument(os.path.join(fRoot, filename))] C1 creates a geoprocessing Map ...
2
votes
0answers
5k views

Create a stacked bar chart with matplotlib [closed]

I'm trying to create a stacked bar chart in python with matplotlib and I can draw my bar one up the other # -*- coding: utf-8 -*- import psycopg2 import matplotlib.pyplot as plt import numpy as np # ...
1
vote
2answers
2k views

GetParameterAsText() error in python script

i have a huge problem with an error . when i use getparameterastext and use it for searchcursor , i encounter to an error .for example the below code import arcpy featureClass = ...
4
votes
1answer
423 views

ogr2ogr when importing from fgdb and use in python

I want import data from my GDB to PostGIS. It works fine on some datasets (all records -data- is imported or nothing is imported) from a gdb but just doesn't import others. I can't find any ...
2
votes
1answer
2k views

Mapping x, y pixel coordinates to latitude and longitudes on the WGS84 datum

Apologies in advance for the long question, I am fairly confused at this point and I figure if I show my thought process any flaws early on in the piece can be more easily pointed out. I have a grid ...
1
vote
2answers
543 views

Script to extract UTM Zone using Range and Meridian information

Hi Everyone, I am looking for a phython or php script that will accept the Range and Meridian values of a location and use it to identify the UTM zone. I have a table that comprises of Easting, ...
7
votes
1answer
457 views

Reduce extent of raster processing

I need to reduce the processing extent of my raster by some sort of automatic procedure in python. Currently the borders of the dataset I've been using has anomalies (due to the classification of the ...
2
votes
1answer
350 views

How can I use Python to save several MXDs within the same script?

I have a program (720 lines of code) that runs multiple tasks on Arcmap .mxd files. Such as update layers, update text, add layers, etc. Within my program I have multiple "mxd.save()" instances. All ...
2
votes
1answer
425 views

Script for Editing TIN in Arcgis: modelbuilder works, when exported as script gives an error

Arcgis can give such a headache! I want to automate loads of small tasks, and so I need to edit empty TIN with python in order to create a full TIN. My srcript is giving errors, so I tried by hand to ...
7
votes
6answers
16k views

How to get X Y coordinates and cell value of each pixel in a raster using Python?

I’m really new to Python and I would like to know whether there is a quick method to get cell values of a raster pixel by pixel and the coordinates (map X Y coordinate of centre of each pixel) using ...
2
votes
0answers
374 views

How to access mysql data from python built-in console?

I'm writing a QGIS Plugin, and somewhere I want to present data from a MySQL database. It's simple data(strings,etc), not Geospatial, or vector data. I'm familiar with querying databases from python ...
4
votes
2answers
1k views

Trouble finding YMin and YMax of a shapefile in ArcMap 10 and Arcpy

I want a python script that tells me the Xmin, Xmax, Ymin, and Ymax of a polygon. (I guess this is finding the extent of a polygon?) My current script gives me the correct the Xmin and Xmax, but it ...
4
votes
2answers
2k views

FWTools ogr2ogr in Python

I am trying to convert MapINFO tabs to ESRI Shapefiles using FW Tools. I downloaded the tools and can run the FW Tools Shell and convert no problem: ogr2ogr -f "ESRI Shapefile" ...
4
votes
1answer
672 views

python crashes creating many Feature Classes in multiple Feature Datasets

I'm trying to populate a Geodatabase with roundabout 60 Datasets with a new Featureclass for each Dataset. To do this, i wrote a python-standalone-script that loops through these datasets and creates ...
2
votes
1answer
859 views

Convert MapInfo - MapBasic Script into Python

I have a mapbasic script that divides an irregular polygon into smaller polygons of 1 hectare each. Would anyone help me to convert the following into an arcpy python script. ' This program ...
5
votes
2answers
484 views

Using rpy2 in ArcGIS

I have a 3rd party python geoprocessing script that requires rpy2, and thus also r. What is the best way to get these working together? Using R with ArcGIS Desktop says the most useful option for ...
0
votes
1answer
498 views

zonal histogram fails to create output table when looping

Using python I'm having problems when trying to attempt a FOR LOOP with the ZonalHistogram function of ArcGIS 10.1. It works fine if I use it only for one image but it gives me this error while for ...
9
votes
2answers
983 views

How to bypass errors in arcpy for/while loop?

I have a handy script tool that loops through a workspace and renames and copies shapefiles to a feature dataset. However, if there is a corrupted shapefile somewhere in the workspace the script ...
2
votes
1answer
761 views

How to split geometry collection into its items using Python and QGIS API?

I'm getting some geometries via intersecting lines by polygons (somewhat blindly - I don't really know if intersection exists and actually I don't need to know) using python and QGIS API: ...
6
votes
1answer
313 views

Python/GDAL get unique values in discrete-valued raster

I would like to get some advice on the most efficient way to return a list of unique values of a discrete-valued raster using Python and GDAL. I had thought that the most obvious way would be to ...
0
votes
1answer
180 views

How to populate Unique ID field after sorting?

I am trying to create an new unique id field in a feature class. I already have one field called "SITE_ID_FD", but it is historical. The format of the unique value in that field isn't what our current ...
6
votes
3answers
1k views

How do I extract a raster's extent in python?

I am looking for an easy way to extract a raster's extent in python. Currently, I am using gdalinfo and then parsing out the corner coordinates. The problem with this approach is that gdalinfo is ...
4
votes
1answer
194 views

Dropdown menu to select vector layer from current displayed layers in qgis

I'm trying to write a python plugin to create an input file for an urban climate model out of three shape files. One of the shape files contains the buildings (polygon), one the trees (point), and the ...
2
votes
0answers
66 views

How to call a method when self.iface.actionSelectRectangle().trigger() is released?

In my QGIS python plugin I use "self.iface.actionSelectRectangle().trigger()" to select features. I also have a button which changes the attributes of the selected features. Is there a way instead ...
2
votes
0answers
179 views

qgis and embedded ajax (bing map)

I need to load in a docked QWebView this html: < html > < body > < iframe width="100%" height="499" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" ...
2
votes
1answer
272 views

Is it possible to set a layer style (e.g. set the color ramp) before loading the layer using pyQGIS?

I am implementing a tool which allows an user to calculate some statistics with some data from the registration office. My question is, can I set some layer styles using pyQGIS? The analysis part is ...
6
votes
3answers
277 views

Do OSGeo4W and ArcGIS 10.0 use the same Python installation?

This question was asked several years ago at: Can ArcGIS and OSGeo4W share the same python install?, but it seems that versions have changed since then. I currently have ArcGIS 10.0 installed (not ...
1
vote
3answers
326 views

Why do I get a no module error when I try to batch process in Arc10?

I was trying to batch reproject a set of shapefiles and I kept getting the error No OS Module As the set was relatively small I just did it individually, however I want to be able to batch process in ...
0
votes
1answer
472 views

Looping Dataframe in Python doesn't Return Expected Results

I'm creating a python addin script to be used on some mxd's I have created as templates. Each map contains 2 dataframes. I need to loop through each dataframe and do some processing on each. I set my ...
1
vote
1answer
620 views

Python script for GRASS - executing from PHP

I wrote the following python script: #!/usr/bin/env python import os import sys gisbase = os.environ['GISBASE'] = "/usr/lib/grass64" gisdbase=os.path.join("PATH") location=LOCATION NAME ...
1
vote
1answer
186 views

Qgis mapserver - Can it use plugins you use in qgis desktop?

Im thinking about developing a small python plugin for qgis which would access postgis raster database and return data via ST_AsPNG() for example. But since i need this in my wms, would it be possible ...
1
vote
1answer
256 views

Arcobjects in Python, inherit from Abstract Class

As for question, I am trying to adjust Grid Map labels via Arcobjects with Python. For now I do have: from comtypes.client import CreateObject, GetModule import arcpy def CType(obj, interface): ...
1
vote
1answer
537 views

How do I find out if a given lat lon is in a KML Linear ring using shapely?

I'm a GIS n00b. I have some LinearRings in a KML file that give the areas for a bunch of different regions. And then I (will) have some lat lons that I want to test to see if they're in any of the ...
3
votes
2answers
2k views

How to perform volume calculation in QGIS

EDIT 07/12/12 Ok, meanwhile I came to another problem I want to discuss. I just tried around with the volume calculation with some layers and came to a point where I receive the following error. ...
5
votes
2answers
754 views

Importing attributes from Excel file into new Polygons

I have a constantly updated Excel file containing address information which I am currently copying into the attributes of new polygons which I am creating on a daily basis. I am currently doing this ...
2
votes
1answer
545 views

Are features of new labelling tool available to control via Python API?

I am writing a plugin using Python and currently using methods that set the label similar to those seen under Layer Properties. Some of the features under the new labelling engine available on the ...
8
votes
4answers
1k views

How to split points by polygon?

I am looking for a way to split points by a county polygon feature class. The attached image shows two feature classes: one composed of points and the other a county polygon feature class. The split ...
1
vote
0answers
216 views

Hack to change data source of a layer file in ArcGIS 9.3.1 with python?

I'm looking for a way to change the source of my layer file using python. Actually I want to do this because I need to re-use a XSL template which is defined under the tap HTML popup of the layer ...
7
votes
2answers
539 views

How to catch PostgreSQL/PostGIS errors in GDAL/OGR Python bindings?

Is it possible to catch PostgreSQL output error messages in OGR after a query has failed? For example conn.ExecuteSQL('SELECT * FROM non_existing_table;') In Postgres this returns an error ...