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

learn more… | top users | synonyms

1
vote
2answers
116 views

How to get an indication of how points are spatially distributed?

Let's say I have a set of points and I want to get an indication of their spatial distribution. That is, if all points are at one location a possible return value would be 0, whereas if all points are ...
1
vote
1answer
132 views

ArcGIS arcpy reprojecting raster issue

I have a raster which I want to reproject from GCS_WGS_1984 to GCS_NorthAmerican_1983. I am using the following code: try: spatial_ref = ...
1
vote
2answers
386 views

Creating a new feature class with python and then adding attibutes

I am having trouble adding rows to a shapefile after it has been created. I'm not sure if I need to create the shapefile in memory and add the data or creating then re-open the file. While I've ...
1
vote
1answer
66 views

turn a Result object into a number

**import arcpy from arcpy import env from arcpy.sa import * import math # Check out any necessary licenses arcpy.CheckOutExtension("spatial") # OverwriteOutput arcpy.env.overwriteOutput = True ...
1
vote
2answers
320 views

How to remove z & m coordinates from shapes with QGIS? (Or arcgis, grass, gdal, Python…)

I've recently received some parcel data in shapefile format that has z & m coordinates (all = 0.0). The WKT for a typical parcel looks like this: "MULTIPOLYGON (((2672464.560700002 ...
1
vote
1answer
434 views

How to access row from dbf table?

I have got the following problem: I would like to access a row from a dbf table. I have tried to access it through SearchCursor, but I am not able to do it without knowing the field name. This is my ...
1
vote
2answers
750 views

Importing ArcPy taking many seconds and code is really slow for GeoProcessing Tools 64-bit (ArcGIS 10.1 SP1)

I've installed ArcGIS10.1 SP1 and whenever I import arcpy (on Pywin console or Eclipse PyDev) it takes aprox. 15-20seconds. Is this normal? I don't think so... I had Python 2.7.3 64-bit previously ...
1
vote
2answers
467 views

Python code does not work with RasterCalculator after exported from Model Builder

I have a model authored in Model Builder that uses "RasterCalculator" to process input raster datasets. arcpy.gp.RasterCalculator_sa("OutRas = Con(\"%STATIC_forestland%\" == 0, -255, ...
1
vote
3answers
168 views

Center of a bounding box

I have bounding box coordinates of my shapefile (fetched from layer.GetExtent() Python with GDAL/OGR): (-38.6102467739459, -38.017601026186576, 33.01563382506067, 33.624945228091406) So I assume ...
1
vote
2answers
512 views

Can anyone recommend an Arcpy GUI? [duplicate]

Can anyone recommend a GUI for arcpy? So if I want to run my script as an exe with some blank text boxes(or text boxes with default entries), radio buttons, check boxes etc.
1
vote
1answer
2k views

Find and replace unicode character in a shapefile

I've found several example of script and blog posts on working with unicode characters, but I haven't been able to make anything works so far... It's a little frustrating I have a shapefile encoded ...
1
vote
2answers
139 views

How to interact layers with a nested loop?

I've dealing with the code below with such a long time. I have to show in a raster image the result of calculating the cost of the electricity for a solar plant. The thing is that I have to interact a ...
1
vote
2answers
763 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 ...
1
vote
2answers
513 views

Can you use arcpy.Copy_management() with in_memory tables?

I have a table in an ArcSDE GDB I'd like to step through using Python. For performance reasons I wanted to load it into memory like so: arcpy.Copy_management('C:/GDB.sde/MyTable', ...
1
vote
2answers
525 views

Python scripting for ArcPad Checkin

I can use ArcGIS Desktop model builder to leverage the ArcPad Check In Tool. When I run the model it executes successfully. When I export the model as python I get this code: import arcpy # Local ...
1
vote
3answers
235 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 ...
1
vote
2answers
1k views

Problem loading vector layer (pyQGIS)

I've installed the qgis on ubuntu 12.04 following the instructions on http://hub.qgis.org/projects/quantum-gis/wiki/Download. I am trying to test the Python API and try to do the follwoing from ...
1
vote
2answers
2k views

How can I save raster dataset using arcpy

I'm trying to save filled raster object to geo database by my specified filename. import arcpy from arcpy import env from arcpy.sa import * env.workspace = r"C:\GIS ...
1
vote
1answer
551 views

How to translate ESRI cursor example to pyQgis?

For example, how to translate this code into pyqgis? rows = gp.UpdateCursor("D:/St_Johns/data.mdb/roads") row = rows.Next() while row: row.buffer_distance = row.road_type * 100 ...
1
vote
2answers
299 views

GetCount_management From ArcGIS ToolValidator

We want to check if features are empty in the ToolValidator. When you call GetCount_managment() and background processing is on, there is a popup from our validation step. Is there a different ...
1
vote
4answers
1k views

Install other python distributions on top of ARCGIS installation ? - esp. Python(x,y)

I'm using ArcGIS 10 and would like to use various additional libraries that are not included in the delivered version of ArcGIS (esp. numpy and matplotlib). First I tried to install them manually as ...
1
vote
3answers
493 views

python: Replace Variable in VB-Expression-File (.cal) [ArcGis 9.3]

I'm trying to modify a VB-Expression saved in a cal-file: dim out if [D19830701]=-9999 then out= [D19830501] else out= [D19830701] end if __esri_field_calculator_splitter__ out with this ...
1
vote
1answer
75 views

Why is feature.geometry() None in my user-defined expression function?

I'm trying the user-defined expression functions for QGIS, as listed on Nathans blog: http://nathanw.net/2012/11/10/user-defined-expression-functions-for-qgis/ I always get the feature.geometry() as ...
1
vote
2answers
47 views

Creating shapefile from selection - remove from map

I am iterating over a shapefile and creating a new shape from each row. I will be creating several thousand individual shapes and do not want to inundate my TOC with that many layers (I bet ArcMap ...
1
vote
1answer
39 views

User defined parameter within code block of field calculator - Modelbuilder - ArcGIS - Python

I am using Reclass within a Code Block in Field Calculator in a Model to calculate field values for a variable based on several other fields. Using reclass is much quicker than select and then using ...
1
vote
2answers
60 views

Raster' object is not iterable

I'm trying to calculate the percentage of cell counts in new raster and the new raster is created from an old raster based on the Value > 14. In my code, 1st for loop is for original raster and ...
1
vote
1answer
39 views

sum of raster counts

I'm trying to get the sum of "counts" in a raster. I have the code below which can successfully read the counts of each row in raster attribute and stores the counts in a list provided below. ...
1
vote
5answers
112 views

Calculations in if statement

I want to perform a simple calculation with the Field Calculator using this piece of script (note that all the elif statements are attempts for another syntax and non of the worked): def ...
1
vote
2answers
51 views

If-Then-Else statement in ModelBuilder has improper syntax

I have a model that converts a road network into a different schema for a different program. In one step of the model I am converting values for a field "Class". I wrote an If-Then-Else statement in ...
1
vote
2answers
51 views

Problems searching for attributes

I've come across this problem a few times and have not been able to find a satisfactory answer. I am new to python though so perhaps I have not been looking in the right places! Anyway, In ArcGIS I ...
1
vote
1answer
66 views

Script to “extract by mask” a list of raster files

I'm trying to mask a group of raster files and save the new rasters in a different folder using the same name of the original files. It doesn't sound as a difficult task, but I'm having trouble ...
1
vote
2answers
151 views

How can I group Points to make polygon via Python

I have an array of coordinates Point= [lat,long] ListPoint= [[38.203655,-76.113281],[38.10,-76.12],..] I wanna make a polygon that contains all these points ? There is a project developed by ...
1
vote
1answer
73 views

Arcpy Script tool

I'm creating a script tool and using the SelectLayerBy Attribute function (below), arcpy.SelectLayerByAttribute_management("cities_lyr", "NEW_SELECTION", '"CRIME_INDX" <= 0.02') However, I keep ...
1
vote
1answer
92 views

Equivalent function to shapely's envelope in ogr?

I wrote a very simple python function that gives me the envelope/bounding box/...based on two coordinate pairs (ower left and upper right corner): # ... def get_bounding_box(self, ll_corner, ...
1
vote
3answers
276 views

Problem with python script to control GRASS GIS from outside - How to import grass.script under Win 8.1?

I am working with GRASS 6.4.3 and python 2.7.6 under WIN 8.1. I am a novice with computer science and coding, and I have seen many posts including those:Is it possible to use GRASS GIS in Python ...
1
vote
1answer
77 views

Is it a good idea to use GRASS Algorithms for Geoprocessing in a Server Environment?

I´m designing a web-service to run in a server environment that will do some geoprocessing actions to datasets uploaded by users and send the results back. I´m programming in Python, and so far I´ve ...
1
vote
2answers
51 views

Fill Sinks of multiple rasters in a Python expression

I have 31 rasters that represent different watersheds and I would like to use the Fill (Spatial Analysis) tool to fill the sinks of all rasters at once in Python. All the rasters have the same name ...
1
vote
1answer
111 views

ListRasters not recognizing raster files in python

I have 2 rasters in my workspace, one in TIFF Format and the other in GRID format: "C:\ExampleFolder" When I use the python script: import arcpy >>> ...
1
vote
2answers
195 views

Efficient way to store multiple values of an x,y location in Python?

I am trying to read values from a stack of images and store them in a structure that will allow for easy readability. My current idea is to create a loop for x in width: for y in length: ...
1
vote
1answer
105 views

How to remove all selection from all registered layers using QGIS plugin?

I want to remove all selection from registered layer in QGIS using Python. I tried to clear the map canvas using: self.iface.mapCanvas().clear() self.iface.mapCanvas().refresh() but the ...
1
vote
2answers
587 views

How to terminate Python scripts in Processing framework properly?

I'm writing a Python script to use it in Processing framework. I need to cancel script execution if certain conditions are met (to save user's time). I tried to use sys.exit(arguments) command. The ...
1
vote
1answer
293 views

Insert Cursor fails to write results to table

Insert Cursor fails to write results to table. The Search Cursor is returning the results, but errors when trying to insert into field. # Insert Cursor for GDB table to GDB table # Import modules, ...
1
vote
1answer
39 views

Trigger a custom ArcToolbox tool outside Model Builder

I have created a model in a custom Arc Toolbox with Model Builder in ArcMap 10.1. Is it possible to trigger the model outside Model Builder and ArcMap? For example, use a Python script to trigger the ...
1
vote
2answers
85 views

What is the most efficient method to delete points?

I have a script that takes a point featureclass (FC) through the following workflow: Select points that lie within individual polygons From the selected points within each polygon, randomly subset ...
1
vote
1answer
123 views

selection by attributes with python

I have a problem concerning the selection by attribute with python on arcmap. I use this code: import arcpy from arcpy import env arcpy.env.workspace= "E:\cities" Mi=(r"E:\cities\rivers.shp") rows = ...
1
vote
3answers
233 views

How to access user credentials in database connection?

I am trying to automate a couple of things when a QGIS plugin is activated: If Layer A is not in the TOC, add it. This requests username and password to access a PostGIS table using the inbuilt ...
1
vote
1answer
185 views

How to automate creation of PNG maps using Python?

I have a project with 50 vector layers and I have done custom styling for them. Now I want to make around 30 png files with different xmin, ymin, xmax, ymax. The output size (png) should be width ...
1
vote
2answers
173 views

Hyperlink broken path - python check

I've recently come across an issue where some of our hyperlinks aren't working. I'm familiar with python and have made similar scripts before, but I would first like to ask for your assistance to ...
1
vote
2answers
198 views

Reducing number of decimal places after X/Y coordinates in a FC

I'm using arcpy.AddXY_management to add coordinates, and I want to reduce each X/Y field by x number. I've tried to reduce it by string slicing and that obviously didn't work. I also tried setting the ...
1
vote
1answer
352 views

special python library needed for spatialite?

It appears that pyspatialite is very outdated. Do I need a special library like pyspatialite in order to use the spatial functions of spatialite? Or can I just connect to the database via the normal ...