Tagged Questions

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

learn more… | top users | synonyms

2
votes
1answer
217 views

OGR CreateLayer returns TypeError

I'm trying to create a shapefile layer based on the spatial projection of an already existing raster. (Ultimately, this will be used in gdal.Polygonize to get a shape from my raster data.) However, I ...
5
votes
1answer
147 views

Why are z-values replaced with zero after in_memory use in Python?

My script takes separate 3D feature classes, calculates a field, appends to a target feature class, and then deletes the originals. This is a huge data processing task of over 4700 mass point feature ...
1
vote
1answer
283 views

Rpy2 Unable to Load in Fresh QGIS Install

after installing qgis the a message given below is shown Unable to load the plugin: Unable to load required package rpy2. Please ensure that both R, and the corresponding version of Rpy2 are ...
3
votes
1answer
196 views

How to check if geometry is M aware?

I am trying to determine whether my shape file that I pass is in M-aware (has M value). I keep getting an error Attribute Error: 'Polyline' object has no attribute 'hasM' Not sure what I am doing ...
2
votes
2answers
176 views

Issue while running grass from subprocess

I have a map based web application using geodjango. I needed to display the crime hotspots within a selected polygon area. I found that v.kernel is very good for generating heatmaps/hotspots. So in my ...
1
vote
1answer
135 views

Can not import qgis.core in python

I installed OSGeo4W. I have no other Python version on my computer. I can import osgeo. But when I try to import qgis.core I am getting the error: >>> import qgis.core Traceback (most ...
26
votes
9answers
5k views

What are some resources for learning ArcPy?

I would like to learn ArcPy, but I do not know quite where to begin. Does anyone have any good advice on where I should start to learn ArcPy?
4
votes
2answers
1k views

ArcGIS script tool: Can you have an input parameter set to optional and have the tool work when an input is not provided?

I'm building a script tool that processes shapefiles ( GPS data collected on weekly basis). The tool is set up to take an input for each shapefile ( in this case Sewer, Storm, Sign). On some days, ...
2
votes
3answers
737 views

Python code : Help with using Search Cursor and Messaging the Total Count of Items from Field in Layer that was Searched

My program works but it is not displaying a message of the total sheet count found in attribute table that the search cursor searched through. For Example: It goes through the mxd chosen by user finds ...
2
votes
1answer
372 views

How to transform KML from lon-lat to UTM (E-N), using Python?

I have a lot of KML files set as lon-lat (geographic coordinates) and want to set them as UTM (E-N) and WGS84 with Python (using arcpy, ogr, or gdal) Does anyone knows how to do this?
1
vote
1answer
140 views

How to run “create mask” from the console?

There's a plugin called "create mask" for qGIS and trying out some simple scripting from the Python console. I would like to call it after I select the vector features I want, then do more related ...
1
vote
1answer
249 views

Change coordinate system in multiple MXDs ArcGIS 9.3 using Python

I have to loop through some folders which may contain *.mxd files and change their coordinate system. I already found this piece of Python which should do the trick for ArcGIS 10.x (from here): ...
0
votes
1answer
798 views

'Exceptions.NameError' > “Name 'sheet_count' is not defined” Error in Python Code

I know this is something simple but for some reason I am having trouble remembering. In my code I am getting a name is not define for sheet_count. This means I would have to define at top correct. For ...
2
votes
2answers
96 views

How do I create a network from connected links

I have a bundle of links in 'some' networks. I need to find out which ones are connected to each other i.e. I need to find out which links are not connected to the 'main' network. I have been working ...
3
votes
3answers
144 views

QGIS Python Intro Text

After reading replies regarding starting a mapping business, I think I'd better read a Python book. Any intro-level Python books to recommend? Mila
3
votes
1answer
318 views

Using field mappings to remove fields from a merged table

EDIT: Soreted, thanks :-) I'm trying to combine a (large) number of tables into a merged table, keeping only certain fields. I've tried the below, but it still gives all the fields. Any ideas? ...
0
votes
3answers
863 views

Summarize values per row using field calculator via Model Builder

I think my problem is easy to solve, but so far I couldn't find a solution. I have a Feature Dataset created with the Union tool in Model Builder and now try to sum up all values of one specific field ...
2
votes
0answers
89 views

Custom python datasource to QGIS

I'm working on a homebrew spatial feature data format, and using Python to write it's API. It occoured to me that use some tool like QGIS to display my data would be very nice to have, for debug/test ...
2
votes
2answers
1k views

Extract coordinates from vector layer in PyQgis

In Qgis, I have made a polygon, and from that polygon I have made a vector grid via research tools-> vector grid. The grid covers the entire polygon. Now I want to extract these grid points in the ...
4
votes
1answer
499 views

Programmically Populate Value List in ArcGIS Tool Interface

I'm just trying to set up the parameters in a tool I've built in ArcGIS. What I want to do is read in a feature class or table and get the values in a specific field called "SITE". The field contains ...
2
votes
2answers
475 views

Using select by location to update a field in a feature class

I am using Arc 10.1 and I am working on a script that takes a value from a field within one shape file and updates a field in another shape file based on its location. Basically I have smaller parcels ...
1
vote
0answers
60 views

Python Program for “QC of PDFs Created from Data Driven Pages”

I need some help. I am fairly new to Python. I found a sample code and I need to change a couple things in it for it to work. I need it to make sure that all PDFs were created from the Data Driven ...
10
votes
1answer
2k views

How to find differences between shapefiles?

Every month I have to QA/QC some streets data for an entire county (over 47,000 records). The first step is to compare the two files. Currently, I'm using a tool that was created in house via VBA ...
0
votes
1answer
101 views

How Could I Calculate Shortest Path ?

I am working on QGIS - 1.8 Version and frequently getting an error while using Road Graph and Shortest Path Opetions. Kindly Suggest or provide solution.. With Regards Prashant Persai
1
vote
1answer
470 views

How to refresh a Combobox Add-in in ArcGIS 10.1

I need to refresh the value in the combobox after an event from other tool in the same add-in (ARCGIS 10.1. Python). I've changed the value of the combobox with the code: combobox.value = val and I ...
4
votes
1answer
240 views

How do I write XML metadata with Python?

Some Python software I have written generates raster files via GDAL. I would like the software to create an XML metadata file for each raster so that I can include details about how the raster was ...
4
votes
1answer
169 views

Programmatic raster-vector calculation

I currently use GRASS' r.mapcalc to find the difference between vector and raster data using a loop and temporary files and layers. Is it possible to do the core calculation between raster with a ...
2
votes
2answers
443 views

Calculate Percent coverage using another raster, with dif resolution and orientation

I have a 0.5 meter raster that defines presence or absence (cells are either 1 or 0). I have another 5 meter raster, which I created. I would like to calculate a percent coverage of the underlying 0.5 ...
3
votes
1answer
666 views

Arcpy does not execute “CopyFeatures_Management” to write a featureclass to an ArcSDE database

I have some problems with my Python script. The script gets an JSON with different information about images. The information includes general information about images and also the gps position of ...
2
votes
1answer
169 views

Select and zoom python script

I am attempting to make a simple select and zoom python script for my address points. Currently the script will complete successfully but will not select or zoom to the entered point. I am using two ...
3
votes
1answer
66 views

Python program for “Comparing total number of pages of an mxd to total number of PDFs created from that mxd”!

I need some help on my program. I have the parameters set to ask user to pick an mxd and the folder where those data driven PDFs are located. I started with Search Cursor to create a list from the ...
1
vote
2answers
863 views

Select Layer by Location - Arcpy - Why are my inputs being interpreted as invalid?

I am working on a tool in a python toolbox and am totally confused about what is going on and causing my select by location operation to fail (Error 000368). I am trying to select the features in one ...
2
votes
1answer
614 views

how to add a query layer to a mxd in a python script

I want to add a query layer to an arcmap document so that whenever i have a db data update, it is reflected in my ma and I can update my service through python script. This is my script so far... ...
4
votes
1answer
320 views

Arcgis Stop Working with my Loop Scrip (Could Be Memory)

I am having issues with my scrip, because it makes my computer very slow after 15 loops arcgis 10.1 and explorer.exe crashes. But instead of this, i can see my 15 pdf files saved correctly and i need ...
4
votes
1answer
275 views

Slow performance on splitting a shapefile by attributes

I've tried to develop some workflows with the ArcPy module for splitting a shapefile based on the unique values in a specified field. The code works as expected except one thing I am not able to ...
4
votes
1answer
270 views

How change border line to no pen with python console?

From Python console I load a shapefile with qgis.utils.iface.addVectorLayer. How I can remove border lines (change to no pen) in the active layer?
3
votes
2answers
623 views

Majority filter (minimum mapping unit) in ArcGIS with larger window size

I want to run the majority filter in ArcGIS with a window size of 4 or 5 i.e. greater than the default 3. Is it possible? Or some other command (or tool) which might help me achieve that? thanks!
1
vote
1answer
345 views

Data Driven Pages, Graphs, and selections in ArcMap 10.1

Is it possible in python to create a selection set based on the extent from a Data Driven Page (DDP)? I have a layout view with a map and a graph. The graph is set to only plot the selected set of ...
1
vote
0answers
63 views

Script Tool Problems ArcMap 10.0

I Have a scipt tool that runs when input shape files are added from the table of contents (added from drop down menu.) However this tool will not run when they shape files are added using the add file ...
5
votes
2answers
276 views

Exit Python script in ArcGIS 10.0

I have a script with an bail-out function like so: def die(): from sys import exit exit() Occasionally in the script I check a condition and exit if necessary. This works great in 10.1, ...
2
votes
1answer
166 views

Updating and inserting a field within the same loop

I am working with an empty feature class where I am writing a script to create polylines within the featureclass and attach an associated text value with the polyline. I am using a for loop as noted ...
1
vote
1answer
555 views

Using Python if/then/else to return value from either of two fields based on value of third using ArcGIS Field Calculator?

I'm trying to avoid manually inputting Begin and End engineering station values already inputted into a seperate field. I'm dealing with(4) fields: Begin_Sta End_Sta Beg_End and Station. The ...
5
votes
1answer
131 views

Cursor only completes one loop

I am at the end of my rope here. This cursor runs fine for one iteration and then stops. It doesn't throw an error, it just completes. There are 3,000 rows in my table, so I don't know why it would do ...
2
votes
1answer
512 views

Need help in Python script : Getting an unicode encode error

When I`m running a script (it checks to which database a mxd is connected) I get the following error: return codecs.charmap_encode(input,errors,encoding_table) UnicodeEncodeError: 'charmap' codec ...
3
votes
1answer
145 views

How to add Oracle database connection to AnalyzeforMSD script?

I use this script right now: import os, arcpy directory = r"C:\Project" for root, dirs, files in os.walk(directory): for myFile in files: fileExt = os.path.splitext(myFile)[1] if (fileExt ...
2
votes
1answer
543 views

How to access all mxd files in a folder?

I'm a beginner to Python and am trying to figure out how I can access several mxds in a folder. For example, when I want to use the AnalyzeforMSD function in ArcGIS: import arcpy mxd = ...
0
votes
1answer
327 views

How to update element text in arcpy.mapping? [closed]

I have a problem updating a map element text (named element1) in a map document using the following code: a1 = '"' + ("element" + str(1)) + '"' for elm in arcpy.mapping.ListLayoutElements(mxd, ...
7
votes
2answers
1k views

Converting KML files for use with Python library Shapely

I am trying to get a KML-file (wijken.kml) into Shapely. The KML-file is validated against the proper XML schema, so I guess the input is correct. Routes I have tried: 1) Converting to WKT or WKB ...
2
votes
1answer
328 views

Intersection of convex polygons on a spherical surface

There are a number of algorithms available for the intersection of two convex polygons, but I am interested in an algorithm to find the intersection of two convex polygons on the surface of a sphere, ...
1
vote
1answer
588 views

how to install networkx python in QGIS

How to install and how to compile networkx python on QGIS? I always get an error that no module named networkx in the console of QGIS I copied the file networkx in C:\Program Files\Quantum GIS ...