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

learn more… | top users | synonyms

2
votes
0answers
404 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 ...
3
votes
1answer
156 views

Show feature classes as a checklist in a workspace in ModelBuilder

In my model, I would like to show all the feature classes inside a file gdb as a "checklist", similar to how the tool dialog window for Make Query Table looks: So instead of the input being a ...
5
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" ...
2
votes
2answers
746 views

Updating polygon geometry: deleting inner rings with python

I've searched, but can't find clear explanations how can I simply delete inner rings from existing polygons with python or extract outter rings and overwrite the geometry. Seems GDAL/OGR should be the ...
0
votes
1answer
576 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 ...
1
vote
1answer
931 views

How to drop ArcSDE connection using Python scripting?

I want to be able to control connections to ArcSDE via python. Here is my script so far using ESRI's example. import arcpy from arcpy import env env.workspace = r"SDEConnection" fcList = ...
6
votes
1answer
355 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 ...
2
votes
1answer
961 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 ...
9
votes
2answers
1k 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 ...
4
votes
2answers
2k views

Is there a way to get at C's OGRLayer.Intersection() or OGRLayer.Clip() in Python?

I am working with OGR in Python and noticed that the C libraries have useful Intersection() and Clip() functions as part of the Layer class. Is there any way to get at these functions in Python? I ...
0
votes
1answer
205 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 ...
4
votes
1answer
215 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 ...
6
votes
3answers
2k 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
741 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 ...
1
vote
1answer
1k views

Why can't I install python-qgis on Ubuntu 12?

I am with ubuntu 12 and Qgis 1.8. I have installed QGIS and grass plugin but I can't install python plugin. How to install python plugin with dependeny in Ubuntu? ~$ sudo apt-get install python-qgis ...
2
votes
0answers
83 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
197 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
298 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 ...
0
votes
1answer
563 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
3answers
409 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 ...
2
votes
1answer
881 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
3answers
295 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 ...
10
votes
3answers
6k views

How to fully load a raster into a numpy array?

I have been trying to check my filters on DEM raster for pattern recognition and it is always resulting in missing last rows and columns(like..20). I have tried with PIL library, image load. Then with ...
3
votes
2answers
4k views

How do I use python to batch process the reprojection of a group of shapefiles?

My client would like his shapefiles reprojected and I would like to get a script that can batch process all the files located in the same folder. I am new to Python and ArcPy but am very interested. ...
1
vote
1answer
638 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
1answer
257 views

How to clip a Oracle query layer directly in a Python script?

I have a query layer directly running from ORACLE database in a MXD. I want to clip this layer with a layer being created in another MXD in a Python based tool. My question is to do this clip ...
1
vote
1answer
193 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 ...
2
votes
1answer
621 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 ...
1
vote
0answers
228 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 ...
2
votes
0answers
162 views

How can I draw an ellipse filling the dataframe with ArcPy?

I need to modify one of my template scripts to draw a circle from the centre of the (inset) data frame to the edge of the data frame. This will then be used to clip the data frame to shape. I'm using ...
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 ...
0
votes
1answer
540 views

Parse attribute table value to export filename using data driven pages and arcpy.mapping

I'm trying to customize a data driven page looping statement workflow and want to set a better filename to the final export. Currently the file name uses the page index (pgIndex), but I would like it ...
11
votes
1answer
2k views

How to access feature classes in file geodatabases with Python and GDAL?

I am trying to access a vector dataset in a ESRI File Geodatabase using Python + GDAL. I have successfully compiled GDAL with the file geodatabase API. The FileGDB driver is working correctly since ...
5
votes
2answers
869 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 ...
4
votes
2answers
3k views

Create temporary files as intermediate output to be used as input in concatenation

Q_PART_I I need to merge many (MANY) tables in one unique output table by means of the arcpy.Merge_management. Anyway, I'd like to avoid the creation of tons of intermediate files as my script ...
1
vote
1answer
679 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
0answers
385 views

Cannot merge dbf tables (problem with lock files???) [closed]

I am new to Python and to this community as well, hope someone could help me. I am running script to extract and merge toghether the tables of some Raster. Each Attribute Table presents only one row ...
1
vote
2answers
483 views

Cannot get arcpy.MosiacToNewRaster to work with list

Below I have a snippet of a much larger code that I cannot get to work and I am not sure why. It seems that I always have trouble using arcpy functions with rasters. Can anyone help me get this code ...
3
votes
1answer
90 views

> - operator and “Shape_Area” field in a geodatabase

this might be a pure python problem or a problem with arcpy. please help me out: min_area = float(GKPROZ_functions.min_of_field(out_name,"Shape_Area")) print area_max if min_area > ...
1
vote
1answer
296 views

Setting Script Tool Parameters Using Python and ArcGIS 9.3.1

Can't quite figure this out and i'm sure it's a simple fix. I have a script that utilizes the AGSSOM tool. It first stops all published services, allows for databases to be tidied up by ...
12
votes
3answers
4k views

Is there a way to use “Select by Attribute” in QGIS using a python command?

is there a way to use the function "Select by Attribute" in QGIS using a python command? In my plugin the user should enter a value via a GUI and this value should be used in a function which selects ...
3
votes
2answers
1k views

Using ListFields and CalculateField to find max value in variable number of fields to populate another field?

I need some assistance with the syntax for a CalculateField_management calculation as I have still yet to master all the python syntax rules. What I am trying to do is find the max value in a ...
1
vote
1answer
272 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): ...
6
votes
1answer
1k views

Python script to convert Lat Long to ITM (Irish Transverse Mercator)

I am currently working on a python script that converts Lat Long (WGS84) to ITM. The formulas used are based on a paper published by OSGB (Appendix B): ...
7
votes
2answers
242 views

How to use Python modules as data providers in QGIS?

I don't know if it has been discussed in the past. Qgis data providers can only load native compiled libraries (.so, .dll, etc) that offer the required interface. Is there anything blocking to the ...
1
vote
1answer
403 views

Dealing with overlapping grid (and graticule) labels using ArcGIS Desktop?

I do have 3 grids made by Grids menu in data frame properties. I do need them to display in certain layout and also to behave accordingly to couple of rules (overlapping issues), so I can automate my ...
3
votes
2answers
2k views

Is there a way to automatically populate attribute values in Qgis?

We are using a Qgis/PostGis combo, where Qgis is used for adding features with attributes into a PostGis database. Is there a way to automatically fill the attribute data values with some ...
1
vote
0answers
602 views

Looping multiple feature classes in python for ArcGIS 10

I currently have a large list of feature datasets and dbf tables in a geodatabase. I would like to join each shapefile with its matching DBF file using the "Make Query Table" tool and then "Copy ...
7
votes
3answers
3k views

Calculating Field based on name of shapefile

I have multiple shapefiles to which I have added a field called "gname1". For each shapefile, I want "gname1" to be set to the name of that particular shapefile, for every feature within the ...