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

learn more… | top users | synonyms

4
votes
3answers
1k views

Python OGR: convert a point geometry into polygon

I'm writing a routine for creating the convex hull envelop around shapefiles of islands. I could read the data, extract polygons vertices into a geometry and then compute the convex hull. Now I need ...
1
vote
2answers
211 views

What is the best quick way to populate a field (in ArcGIS 10)? (for rare language/font e.g. Guzrati numerals)

I have polygons generated from shapefile (esri) format I have a tiff image of plot/parcel map(this tiff has plot id scribed in somewhat consecutive in manner) of that polygon feature. I would ...
4
votes
2answers
557 views

Randomly select a record to update using arcpy.da.UpdateCursor

This question is related to my question here. What I would like to do is use a cursor with a where clause to select a number of records. For each row, the values in two fields, TYPE_A and TYPE_B ...
2
votes
1answer
77 views

Python code for locking elements in Layout view

Is it possible to lock elements in layout view in Python? I know it is possible in the production cartography extension from ESRI but all I need is the funcionality to lock elements. I am wondering if ...
0
votes
1answer
77 views

How to use a property of a different interface for a created ArcObject

I have created an arc based three points (from point, through point, and to point). To create the arc I used this code: import arcpy, comtypes.client import comtypes.client.CreateObject as ...
10
votes
3answers
4k views

Get all vertices of a polygon using OGR and Python

I'm having a little trouble with the Python OGR API. What I am trying to do is get all the coordinates of each vertex of the outer ring of a polygon. This is what I have so far: import osgeo.ogr ...
0
votes
1answer
220 views

ArcGIS 10.0 Running Python function CADToGeodatabase() crashes ArcMap/ArcCatalog

My code: import arcpy, csv from arcpy import env dgnfile = str(arcpy.GetParameterAsText(0)) outFeatureClass = str(arcpy.GetParameterAsText(1)) #the fc in my fgdb template to be ...
0
votes
0answers
12 views

Arc 10.0 Running Python function CADToGeodatabase() crashes ArcMap/Catalog contd [duplicate]

Possible Duplicate: ArcGIS 10.0 Running Python function CADToGeodatabase() crashes ArcMap/ArcCatalog Sorry, no room to put all this in the coments window - tried putting this in Answer but ...
5
votes
2answers
628 views

Correct usage of a counter using arcpy.da.UpdateCursor

In the Python code inside a Calculate Value tool in my model, I have the following: getNum("%Selected Features%") def getNum(ftr): lst = [4, 11, 15] #values for SQL expression x = 20 fields ...
0
votes
0answers
676 views

Python package for Google Maps API v3?

I am looking for a Python package that can generate the JavaScript to display Google Maps API v3. I would like to integrate such package into a django website. I know pymaps exists but it's for ...
1
vote
1answer
866 views

How do I copy all feature attributes to a feature in a new layer?

I'm trying to create a new layer in QGIS based on an existing layer. The new features should have all the attributes of the corresponding features in the original layer. I've been trying to use ...
3
votes
2answers
695 views

Can python read the value of a cell in a spreadsheet? [closed]

Can python read the value of a cell in a spreadsheet? The simplest example would be a script that ran a buffer tool on a given shapefile. For the distance parameter, instead of just using a number ...
2
votes
1answer
475 views

Setting parameters in Arcmap for dynamic python script

I have a simple python script that works when run from PythonWin, but when I try to make it dynamic to run inside ArcMap I keep receiving: : ERROR 999999: Error executing function. Failed to execute ...
1
vote
1answer
163 views

cannot print listRasters

I'm trying to run this very simple script to check a problem in another more comlpex one. import arcpy arcpy.env.workspace= 'C:\\Users\\Umberto\\Desktop\\Prove_Script\\Karakoram\\temporary_01' rst= ...
2
votes
2answers
730 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 ...
4
votes
3answers
443 views

Is there anything faster than a cursor in ArcGIS to calculate records?

What is the most efficient (fastest) way to calculate records in a layer in ArcGIS? Is there anything faster than the Cursor in ArcGIS?
4
votes
1answer
910 views

How to import DGN geometry into a file geodatabase?

Specifically, I have an empty File GeoDatabase template consisting of several Group Layers, each containing several Feature Classes. In fact each FC has several subtypes exposed by including a .lyr ...
2
votes
2answers
582 views

The name contains invalid characters

I'm having a problem with the following script. When listing parameters that are optional I've used the "" before, so I can't figure out why this isn't working. import arcpy import os ...
1
vote
1answer
303 views

How to add multiple rasters to a layer file?

I'm trying to make a .lyr file to bring into ArcMap with arcpy.mapping. I can bring a single raster into a .lyr with the script below. I'm unsure how to proceed to get multiple rasters from the same ...
2
votes
2answers
345 views

arcpy.mapping.AddLayer invisible layer

I'm having a bit of a problem with a script on a particular machine. ========================================================== import arcpy,sys class AddLayer(object): ''' classdocs ...
2
votes
2answers
180 views

How to sort a field according to value range?

I have to check an attribute table field (MY ID NO) of polygon feature against a tiff image of parcel map where fields are written as 12-58,65,87,2565-89999,58648. Example: Parcel map tiff(image) ...
4
votes
1answer
859 views

Python console vs Toolbox script in ArcGIS

My question is similar to this post: Adding Layer in current session using ARCPY . My script works in ArcMap python console but not as a script in toolbox.I am running ArcGIS 10.0 SP4. The script is ...
2
votes
4answers
605 views

Error When Trying to Run Slope Analysis Script

I have written a script which is supposed to loop through all the rasters in a folder and perform a slope analysis on each raster and save the results in another folder. I keep getting the following ...
3
votes
1answer
202 views

How to use the QgsDiagramRendererV2?

I'm writing a plugin for QGIS in python in the QGIS API doc, I can see the QgsDiagramRendererV2 class, under the qgs.core section http://www.qgis.org/api/classQgsDiagramRendererV2.html What I'm ...
1
vote
0answers
183 views

Table record counts change when using python tool

I have a python tool which investigates mxd files and clips/projects and exports all visible datasets. Recently I've found that the record counts (even on non-clipped data) is different. It's ok if I ...
6
votes
1answer
832 views

How to call GRASS modules in pyQGIS?

I wish to use a Grass module (v.to.db) in QGis, without the grass toolbox. I tried with the Python console, but to no avail : Using Sextante plugin but obviously it didn't know all the grass ...
2
votes
1answer
512 views

Python: Run script when opening an MXD in ArcGIS 10

This post is related to Run a Python Script when opening an MXD? I would like a python script to run every time a .mxd is opened. However, the link above uses VBA to do it, which ESRI suggests ...
-3
votes
1answer
289 views

How to calculate altitude with given lat,long position?

I'm new to GIS. I want to calculate the elevation of any point on earth giving lat, Long (for example like google elevation Api, or the earth tools: http://www.earthtools.org/webservices.htm # ...
4
votes
3answers
3k views

Why does arcpy.ImportToolbox() not work in ArcGIS 10 (SP5) when calling custom model for topology?

I have an arcpy/python script using ArcGIS10 and using a custom toolbox and model. The toolbox has an alias of defaultTopo and my model within the toolbox is called AddRuleToTopologyModel. This model ...
6
votes
1answer
603 views

pyproj, proj4 doesn't return same coordinates after inverse conversion

I'm trying to interpolate between coordinates, as a step in that process I convert latlong to UTM so I can work in metric. I don't get the expected latlong when converting back, reproduced below: ...
6
votes
2answers
277 views

Python scripting- compute statistics

I'm new to Python but I've heard is a good way to automate tasks. I have thousands of point shapefiles and need to extract the maximum value of each one and put them in a new table. I'll appreciate ...
4
votes
1answer
62 views

How to deliver an additional Python Library with own Plugin?

For my own plugin I need a special library (pyexiv2) to write a comment into a jpg file (PIL does not do that). When I want to share my plugin in one of the repositories in the future, what would be a ...
11
votes
1answer
1k views

Is it possible to take automatically a “screenshot” of my selected feature in QGIS using Python?

I am implementing a tool which allows the user to create a profile of a feature (in my case urban parcels). Is it possible to automatically take a screenshot of this feature (displayed in a QGIS ...
0
votes
2answers
746 views

Python module “shapely.wkb” missing

I am trying to follow a tutorial from here http://qgistips.spatialthoughts.com/2012/12/find-neighbor-polygons-in-layer-in-qgis.html#more I have downloaded the relevant python script and edited it as ...
0
votes
0answers
156 views

How to access the rules of QgsRuleBasedRendererV2 using python?

I can't get access to the rules of rule-based renderer, python says there's no attribute "rootRule", though documentation says it should be (http://www.qgis.org/api/classQgsRuleBasedRendererV2.html) ...
0
votes
1answer
451 views

Parsing list object file paths for file name

I am trying to automate a naming process that takes the file name from a list of file paths to name other folders, geodatabases, zipfiles, etc. The problem I'm running into is that, I assume, I am ...
3
votes
0answers
65 views

Programatically reorder layers in qgis? [duplicate]

Possible Duplicate: Sort layers in QGIS table of contents? I write a qgis python plugin ,and i try to connect keybord keys to reoder layers in qgis . Are there a method in qgis allows me to ...
4
votes
1answer
184 views

How to select points within polygon constrained by field?

I've created a polygon from a raster dataset: arcpy.RasterToPolygon_conversion(RasterInt, "C:/arc/poly_int.shp", "NO_SIMPLIFY", "Value") The 'value' field has numbers 1-37, which map to the ID ...
2
votes
1answer
1k views

How to make a 'Make Table Query' script in ArcGIS?

I am trying to get the make table query running in a script. IF I simply export the script from a model, it works without a problem. However, I do have to change the variable names, as this will be ...
1
vote
1answer
70 views

Styling map elements based on their properties

I am currently generating tiles based on OSM data using Mapnik and Python and am quite happy using the XML styling but I am at a loss as to how to vary the styling on an element by element basis. I ...
3
votes
1answer
281 views

Join GPS points obtained from .GPX file in Python Console

Having loaded the .gpx file into a new layer from python console, I'm unable to access the gps points in the attributes table. Essentially, i'm unable to join these points to form a polygon ...
10
votes
2answers
2k views

How do you delete an in-memory Table View?

In a Python script, I'm cycling through thousands of Excel files and using arcpy.MakeTableView to create in memory table views from the first spreadhseet in each file. How do you delete the reference ...
1
vote
1answer
206 views

Why won't QGIS let me write to a file?

I am writing a QGIS Python Plugin. I am trying to write data to a file using with open("filename.txt", "w") as f: f.write("file text.") QMessageBox.information(None, "Test", "Written to file.") ...
10
votes
1answer
412 views

Is there a way to use ArcPy and PyGRASS tools in the same Python script?

I´m trying to write a Python script, that includes different ArcPy / ArcGIS commands and want to combine it with GRASS geoprocessing tools. Unfortunately importing the GRASS libraries doesn´t work. ...
3
votes
2answers
299 views

Create Table (Data Management), Unable to Save to Feature Dataset

I'm trying to create a table in a feature dataset and get the error: Parameters are not valid. The code works when I write only to the gdb. Am I not allowed to write to a feature dataset or am I doing ...
2
votes
0answers
72 views

Arcpy: Counting number of segments where altitude rises or decreases based on DEM?

I have a DEM of Sudety mountains and linear .shp with several hiking paths. I'm trying solve one problem: How to make a script based on input DEM and input line shapes that would count number of ...
2
votes
0answers
281 views

problem in read_shp() to generate a networkx.DiGraph from point and line shapefiles

I tried to use the Python module networkx and specifically the read-shp () to ensure the transformation of a graph to a file sharpe but I always find this error noting that this is the first time I ...
3
votes
2answers
1k views

Can't Select and Export from Python Script

I am a novice in python programming but I am trying to learn by doing. I got stuck with this function a while back and can't seem to find a solution or a workaround. I am writing a script that is ...
2
votes
1answer
336 views

Saving rasters in a Python for loop fails only on last iteration

I'm a newcomer to Python scripting and I'm having what's seemingly a very simple problem but one that's stumped me enough to send me posting to these forums for the first time. I'm using a for loop ...
3
votes
2answers
785 views

Checking if a point is in a circle

I'm using shapely to check if a point is in a polygon, but I also need to check if a point is in a circle. Checking the docs, I don't see how do that... Maybe I could create a circle? circle = ...