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

learn more… | top users | synonyms

16
votes
1answer
5k views

How to divide a polygon into specific sizes using ArcGIS?

I have several thousand irregularly shaped polygons in a shapefile. I want to be able to split each polygon into three areas, and to specify what the size of those areas (they sum to the previous ...
9
votes
2answers
685 views

Scriptable alternative to ArcScan (particularly vectorising lines within tolerances)

Sadly the answer to this question suggests that it is not possible to script ArcScan from within a python script. Therefore, does anyone know of any alternatives to ArcScan (either within ArcGIS, or ...
2
votes
1answer
343 views

ArcObjects ITextSymbol.GetTextSize in Python revisited: usage with StartDrawing and FinishDrawing methods

I am using ArcGIS 10.0/ArcObjects and Python 2.6. I am trying to get the usage of the ITextSymbol.GetTextSize method correct. The syntax, as established in an earlier question, is: dblx, dbly = ...
4
votes
3answers
2k views

Why would “import arcpy” hang Python script run from DOS/cmd prompt?

I have a very small test script (test.py) that I use to see if Python is installed and ready to use ArcPy. All it contains is: print "Starting" import os print "OS imported" import arcpy print "ArcPy ...
1
vote
1answer
313 views

Can you access ArcScan from a python script?

I'm using a python script with ArcPy in ArcGIS 10, and want to access some ArcScan functions. Is this possible? I can't see anything in the documentation about it, but I can't really find any very ...
4
votes
2answers
2k views

Programmatically alter AliasName for fields defined in layer file (not underlying source)

Is there a way to alter the AliasName on a layer file only, and not the underlying shapefile or feature class? I have a few hundred layers that define joins between hundreds of tables with census data ...
6
votes
2answers
4k views

How should I use GDAL to perform a transformation?

Greetings, I am a student who wishes to use GDAL to transform a series of images from Lambert Conformal Conic (EPSG: 9802) to Google Earth's WGS 84 (EPSG: 4326) for a web mapping project. I know ...
5
votes
3answers
2k views

ArcMap/ArcObjects - Drawing graphics onscreen: Explanation or tutorial for Draw/Refresh/PartialRefresh methods?

I find myself woefully lacking in understanding of when, why, and how (which type) to do screen draw/refresh/partial refresh. For instance, in a standalone Python script outside the application ...
5
votes
3answers
2k views

Python, comtypes and ArcObjects: Error creating AppROT object

I am experimenting with comtypes and ArcObjects under Python 2.6.5 and ArcGIS 10 SP1. I'm using the pure Python method to wrap the ArcObjects OLBs described in this answer, but getting an error in the ...
4
votes
1answer
210 views

ArcObjects ITextSymbol.GetTextSize in Python: Why are the out params equal to 0?

This is related to the question I asked earlier about the syntax for this method under Python and comtypes. Now that I know the syntax and am trying to use it, the returned out params are equal to 0. ...
6
votes
3answers
4k views

Using model builder, how can I extract certain fields for 1 selected feature from a point shapefile file with multiple features?

I have a point shapefile that is filled with many features. If I have 1 feature selected I need to be able to export certain fields of that selected feature (ID, lat, long) into a dbf file. What ...
3
votes
1answer
761 views

ArcObjects: How to get from IFeatureClass on annotation feature class to IAnnoClass?

I am working in Python 2.6 and ArcGIS 10.0 through comtypes, so I have full ArcObjects access. (See the answer I tacked onto the related question "How do I access arcobjects from python?") That ...
3
votes
1answer
252 views

ArcObjects ITextSymbol.GetTextSize in Python: How do I define two input variables that get populated by the method?

I am using Python 2.6 and ArcObjects in ArcGIS 10.0 to build and draw, among other things, graphic text on the current display. At one point I need to use the ITextSymbol.GetTextSize method. In a ...
20
votes
6answers
14k views

Defining projections for multiple shapefiles in ArcMap?

I have over 100 shape files that don't have .prj file and thus when I bring them into ArcMap 10 they show the coordinate system as unknown. I know all of the shape files coordinate system is GCS WGS ...
11
votes
1answer
1k views

How can I display raised error messages to the user in the ArcGIS geoprocessing results window?

Question: Can print statemnts raised from a custom exception be displayed in the gp results window? Background: I modified a script that I found that takes two inputs from a user, finds the ...
3
votes
1answer
1k views

calculate value using maximum value from different feature class

I'm trying to get the maximum numeric value from one feature class and use that value in an expression to calculate values of a different feature class. fc2.bldg_id = max(fc1.bldg_id)+1 Can this ...
0
votes
4answers
7k views

Python Question - how do I extract a part of a string

I'm building a tool in python and for that I have a question: I have a string such as "Denver.dwg Group Layer\Denver.dwg Annotation". How do I assign to a variable (for later print) only the first ...
5
votes
1answer
1k views

Updating a point's geometry based on geometry of another feature class

I'm looking to update the point geometry of lets say "oldFC" by obtaining the shape geometry of "newFC" and applying that to the "oldFC". I also want it to grab the value in the ID field in ...
8
votes
4answers
2k views

Best way to find the polygons crossed by a line

I'm trying to find all the polygons crossed by a single line (a GPS track). I'm using the OGR library (from python) for computing this, but it's currently a bit 'brute-force' (and slow). For every ...
8
votes
5answers
5k views

update one shapefile attribute table with values from another dbf table

I try to explain here what I am trying to do: I have one shapefile and one independent dbf table with the same fields. In the dbf table all the fields are populated but in the shapefile attribute ...
7
votes
1answer
1k views

automated georeferencing

I am attempting to fully automate the process of georeferencing a load of .png files - i have xml file containing the co-ordinates - but how can i use them? Does anyone have any advice?
7
votes
2answers
1k views

selecting by attribute and specific value replace

I want to select all of the features by attribute where the attribue in myattrib is like... Selection "criteria H". That is not a problem. However then I need to replace (myattrib," H", "") except ...
6
votes
4answers
1k views

Raster to Polygon Scripting Problems

I am trying to make a script which selects every .png file in a folder beginning with the letters "LG". I then want the scipt create a shapefile, replacing the "LG" with "SH", and then i want the ...
8
votes
1answer
3k views

Problem with setValue() function in ArcGIS 10

I'm trying to add data to an attribute table in ArcGIS 10 using the following code: def make_floor_no( shapefile ): "Makes header for number of Floors (FLO) and calculates value" fieldName = ...
6
votes
1answer
262 views

Does Arcpy work for Engine or Server the same as Desktop?

I am contemplating a project where there is not going to be access to ArcGIS Desktop and wondering if Engine and/or Server install ArcPy and Python? Is this possible? Does anyone have an example?
4
votes
2answers
319 views

Unique Character Generator Help

I am working on a script that will populate 3 letters into a field. I have to use letters due to field limitations and to make sure that I have enough combinations. I'm not really sure where I am ...
2
votes
1answer
1k views

How to change the datasource with python?

How do I change the datasource of all layers in a map document using arcpy and python
11
votes
4answers
2k views

Looking for a pythonic way to calculate the length of a WKT linestring

I was quite unsatisfied with Calculating Length of Linestrings in WGS84 in Miles. It kept me wondering if there is a more convenient, Pythonic way to calculate the length of a WKT linestring according ...
9
votes
1answer
6k views

How to create a script tool that will create a copy of a feature class and offset it by a given distance? (arcpy)

I want to duplicate a polygon feature class and offset all of the polygons by about 10 feet in both the x and y directions. I asked if there was any way to do this last week, and I was informed that I ...
8
votes
4answers
2k views

how can i convert a shapefile to lat and lon boundaries?

i have a shapefile of country subdivisions and i would like to extract an array of bounding lat and lon for each division.. is it possible to do?
19
votes
6answers
552 views

Python for GIS on a thumb-drive

I'm looking at putting together a light Python install on a thumb drive that I can take to client offices and do some basic GIS processing. I'm thinking of installing the following: PyScripter ...
3
votes
2answers
265 views

Segmentation Fault (segfault) when using OGR CreateField() in Python

Receiving a segfault when running this very short script in Ubuntu. from osgeo import ogr, osr shpfile = 'Census_County_TIGER00_IN.shp' def cust_field(field): '''cust_field(shpfile, field) ...
7
votes
6answers
4k views

How can I calculate the orientation of each side of a polygon in ArcGIS 10?

I want to examine the orientation of each line in a polygon so that I can calculate their solar exposure. Each polygon represents a building, and has an associated height. For the moment, I just want ...
9
votes
3answers
1k views

How to populate an undirected graph from PostGIS?

This question is more related to resources that I might not have identified yet, although I've been searching the web for a while. In the project I'm working at the moment I need to run a ...
6
votes
1answer
1k views

Setting units in python using ArcGIS 10

I want to calculate the area of each polygon in a shapefile. How do I control what the units of measurement are? def getArea(shapefile): """Print area of polygons""" Rows = ...
7
votes
3answers
3k views

Problems setting up eclipse (with PyDev) for ArcGIS 10

I'm trying to use eclipse with PyDev to program in python. In Windows 7 x64, I've added a PATH environmental variable (PATH C:\Python26\ArcGIS10.0\python.exe;) and what I thought were the relevant ...
2
votes
3answers
1k views

Adding shapefile as layer in ArcMap via Python scripting?

I am trying to automate various tasks in ArcGIS Desktop (using ArcMap generally) with Python, and I keep needing a way to add a shapefile to the current map. (And then do stuff to it, but that's ...
45
votes
13answers
11k views

Resources for learning Python programming with generic GIS goals in mind?

In your opinion, what is the best book/site to learn Python with GIS goals in mind? By "best", I mean: not very long (book) easy to understand (book/site) good practical examples (book/site) For ...
4
votes
1answer
543 views

GDAL Pixel Functions question

I am writing a program in python that converts raster files using gdal, and using VRT as an intermediate format. One of the things that i need to do is convert bands between different formats. I am ...
11
votes
6answers
1k views

How to implement value-by-alpha map in GIS?

I've been doing some background reading about cartograms recently and stumbled upon interesting alternative - value-by-alpha maps. Concept is described in more details here and full paper is ...
4
votes
2answers
709 views

Maturity of Mapserver mapscript C# bindings?

I've been thinking about possibly porting an internal custom GIS application built on top of Python / PyQt / Mapscript / GDAL-OGR / PostGis to C#. I was wondering about the maturity of the C# ...
3
votes
1answer
471 views

With CTM how can I get the latitude and longitude bounding box of a geoPDF?

Embedded in a geoPDF is info on the CTM - Coordinate Transformation Matrix. I am unfamiliar with this CTM. I know how to use python-numpy. How (or is it even possible) for me to use the CTM ...
5
votes
1answer
721 views

Altering composer label items in QGIS with Python

I'm only new to QGIS and Python so this may exists already, and hopefully be easy to do. What I'm hoping to do sometime in the future is build a map book generator using QGIS as the base. In order ...
1
vote
1answer
621 views

Run a python script every time the page is changed in Data Driven Pages? (ArcGIS 10)

I'm setting up a Data Driven Pages mapbook mxd for a series of parking locations. I have dynamic text that updates according to the current map sheet, but I also have text that needs to update using a ...
2
votes
2answers
755 views

Any python script to convert a geoPDF to a KML embedded with a jpg link?

I have many geoPDFs. I want to turn them into KMZ or KML+JPEG using a python script. Any suggestions? SEE CODE BELOW
5
votes
5answers
4k views

How do I build a form within ArcMap?

I am building a file geodatabase using ArcGIS. The gdb is going to be distributed to dozens of 'stand alone' machines. End users are expected to populate the gdb with data. End users do have ArcGIS ...
1
vote
2answers
915 views

Running ArcGIS 10 Python script on a unix server - is it possible?

I've written some python scrips that use the ArcPy module to do some pretty intensive processing. I'd like to be able to run these on the fast unix server we have in our department so that I don't ...
5
votes
2answers
8k views

'Select by attribute' using python in ArcMap 10

I need to select a feature using SQL before zooming to it in python. What I'm looking for are replacements for the commented lines in this code: import arcpy parcel_num = "123456" mxd = ...
37
votes
10answers
25k views

How to install GDAL with Python on windows?

Can anyone please explain to me in step by step instructions how to install GDAL/OGR with Python on Windows. I have Windows Vista and I have tried following the information on the website and it does ...
6
votes
3answers
3k views

Convert .mxd with embedded VBA command button to ArcMap 10

I'm trying to convert an .mxd file from an older version to ArcMap 10. The old version had two simple VBA scripts attached to toolbar buttons. I am trying to convert this .mxd to ArcMap 10. For ...