Version 2.7 of the Python programming language

learn more… | top users | synonyms (1)

2
votes
1answer
31 views

Is it possible to find the feature class name from a python label expression in ArcGIS?

Does anyone know how to find the path to a feature class within a label expression using ArcGIS? I don’t need to simply display the path. My overall goal is to create a python function to display ...
0
votes
0answers
31 views

Errors using arcpy.CalculateField_management

I am trying to use the arcpy.CalculateField_management function and running into some trouble. I have a shape file called district_plans, and to this shape file I have joined a table of data (the ...
1
vote
1answer
31 views

Automation of changing symbology for a given layer

I have a shape file that is a 10-by-10 grid of squares. The shape file has 50 attribute columns (named p_1 through p_50) where each column has 100 entries (corresponding to the 100 grid squares) and ...
0
votes
0answers
15 views

Creating Convex hull and finding buffer in QGIS

I have a layer and features are selected using Select Features by freehand tool and for that selected features, convex hull was done and for that convex hull i am trying to find buffer and write it in ...
0
votes
1answer
18 views

Shapely (geos) crashes during unary_union

When attempting to union multiple polygons with Shapely 1.5.6 in Python 2.7.9, using GEOS 3.4.2, I get the following error in the underlying C++ code: Assertion failed: (!"should never be reached"), ...
2
votes
2answers
69 views

Using lists in Python functions [closed]

I have some code in a function that uses a list, which works, but is there a way to write a list outside of the function and use it within the function code? For example in my code below I have a ...
1
vote
0answers
25 views

What is the correct way to write the code for getting layers from the server?

I'm writing a script to call raster from the server to load them to my MXD file. It is just like when you add the data in Arcmap. Problem is that the raster I have is on the server. Is this correct ...
1
vote
1answer
22 views

if condition is false but output is true . what is the exact expression of greater than to bands value ('mjune@1'> 99.6:)

from qgis.core import * from qgis.gui import * from qgis.analysis import QgsRasterCalculator, QgsRasterCalculatorEntry from math import * from PyQt4.QtCore import QFileInfo import os from osgeo ...
0
votes
1answer
23 views

How to join two plugins in QGIS?

I have created two different plugins in QGIS using python. I would like to combine both in one plugin. How can I do that?
1
vote
1answer
45 views

How to sum 10 raster bands instead of 9 from code?

I want to sum 10 raster bands but the problem is that the following code will only work for summing 9 bands, which means the output image consists of 9 bands. from qgis.core import * from qgis.gui ...
0
votes
1answer
34 views

How to delete a shapefile from a directory using QGIS?

I am using the following code to clip a shape file using processing tools via Python and would like to delete the clipped file from the directory. Here is my code. from PyQt4.QtCore import * from ...
1
vote
0answers
44 views

How to auto-increment attribute fields using cursors and conditional statements?

I am trying to create unique IDs for an attribute named "FACILITYID" (str) and have got a ton of help from related posts and online python tutorials. I selected the rows I wished to create unique ID's ...
2
votes
1answer
77 views

Converting values in datetime field to strings in text field using Python parser of ArcGIS for Desktop?

In the attribute table of my file geodatabase feature class I have a populated field called DateField of type date, and a text field called TextField. I have not yet hit on a way to convert the ...
2
votes
1answer
44 views

Error message trying to merge Shapefiles in Python

I try to merge all Shapefiles from one folder together into one, using this: shapeList = arcpy.ListFeatureClasses() print shapeList for fc in shapeList: if fc == "*domain*": ...
0
votes
0answers
28 views

True Altitude of GPS cooridnates

Given two points a=(lat1, long1) , b=(lat2, long2). I want to divide the line between a and b into points with equidistant length. (for example 100 Points) For each of these points i need to ...
2
votes
2answers
178 views

How to count point shp inside polygon shp using Python?

This is my first time here, so I'll try to be as specific as I can. What I'm trying to do is found out which polygon contains the most points and write the result in a text file. Here is my script : ...
2
votes
0answers
64 views

How to load GeoJSON into PostgreSQL database using Python?

What I have tried to do is (In Python IDLE): import psycopg2 import json try: conn = psycopg2.connect("dbname='carto' user='postgres' host= localhost password='password'") except: print "I am ...
1
vote
3answers
86 views

Programmatically adding .shp file to .mxd file

I have spent hours attempting to find the solution to the following problem online, but all answers I have found are quite old, and none work. Here is the situation: I have a variety of .shp files. I ...
1
vote
0answers
24 views

“addItem” in Portal for ArcGIS

I'm trying to upload a .pdf file in the content of my Portal for ArcGIS with a python script. I'm trying with the "additem" REST operation. My code is as follows: import urllib import urllib2 import ...
-1
votes
1answer
35 views

Writing code to create MapDocument object gives ValueError: MapDocObject: Unexpected error? [closed]

I am trying to write the code but it gave me the error within the Python window: >>> mxd = arcpy.mapping.MapDocument("CURRENT") path = "C:\Student\MapScripting10_0" ...
1
vote
0answers
29 views

Difficulty with python package mgrs by Howard Butler

I am developing an app in python and I am trying to import Howard Butler's mgrs package. I am using setuptools to install the package. It does not find the setuptools library module. I have tried ...
2
votes
0answers
28 views

Error ET Geowizard Clean Polygon() takes no arguments (3 given)

I want to clean polygon feature classes with ET Geowizards (clean polygon) because I cannot find any tool within ArcMap (ArcInfo) that does the same. I have really small gaps within the polygons (but ...
1
vote
2answers
78 views

Permanently add a python toolbox to ArcToolbox

I've written a python toolbox for my company containing several scripts to speed up various repetitive tasks. Each time we want to use it we have to open ArcToolbox, right click and select "Add ...
0
votes
0answers
23 views

How to use random number generator to select by attributes in ArcMap? [duplicate]

I am not familiar in using Python and random number generator. I was wondering how to select 250 rows/values from a column named "JUROL". Every value in that column is different and the column ...
0
votes
2answers
56 views

Select layer by attribute for entries in a dictionary (python)

I'm kinda new to python (and programming) and having trouble figuring out how to properly specify what I want to do. Basically, my code compares names of well owners and orps owners and saves all ...
1
vote
0answers
33 views

Why when I use the ReadAsArray() Shell restart in this code?

I want to read the .pix file in the 3 different Array in python and I use this program but when I run that nothing do And shell be restart and program closed . from scipy import ndimage import ...
0
votes
1answer
55 views

Distance with Bearing Calculation not working

I have this function in Python that calculate distance from a point with bearing. Problem is the latitude part is generating the wrong answer and i cannot figure out where i went wrong: def ...
1
vote
2answers
72 views

Issue in the popdown box (QComboBox) in QGIS 2.6 Python plugin

I had developed a plugin that counts the number of features for a layer in Qgis2.6. When i load a layer say 'Airport' for first time and click the pop-down box in the plugin,it lists the airport ...
0
votes
1answer
66 views

QGIS 2.6 Crashed for my own plugin

I had developed a plugin that counts the number of features for a layer in QGIS 2.6. I am using Windows 7 os. It works fine when i loaded a layer. But when I remove that added layer and then if I ...
1
vote
1answer
75 views

Attribute Error:'NoneType' object has no attribute 'name'

I am developing a plugin that counts the number of features for a layer in qgis2.6.The plugin works fine when there is a layer but when there is no layer,it throws an error.For reference,a part of the ...
1
vote
1answer
48 views

Multi-part Geometrical Intersection error

I am working with intersection of polygon and line segments (continued from a previous question). When a Line intersects with a Polygon, the result is a LineString; When a LineRing intersects with ...
1
vote
1answer
58 views

Loading Vector Layer using python console in qgis

I am using qgis2.6 version and new to pyQGIS. I tried to load a vector file using python console in qgis. I don't know where I am wrong. The layer was not loaded and does not show any error too. Help ...
0
votes
1answer
56 views

Understanding desc.fields

First time poster so I hope I did this right. I'm relatively new to Python scripting and am trying to understand the error I'm getting. I have the following simple code and what I don't understand is ...
2
votes
1answer
35 views

Object Inspector Button not enabled in python console of qgis

I am using QGIS2.6 version. I loaded an existing py file in a editor. Though I added a codes in the editor, the object inspector button was not enabled. Please help me in figuring out what would be ...
1
vote
1answer
95 views

Python Basemap fails

I am using Anaconda 2.1.0 and Basemap installation is successful conda install basemap However, I keep getting the following error when I try to project lat,lon to a planar: Assertion failed: (0), ...
2
votes
3answers
144 views

How to change properties of an item in a legend in ArcMap 10.2 using python

For many of my projects I use a single mxd to create multiple maps using a python script to switch on/off various raster layers before exporting to pdf. Before beginning the exporting process I ...
2
votes
1answer
53 views

How do I import an ASCII grid using arcpy?

I'm trying to automate the setup of some flood depth/hazard maps. The user specifies a folder containing depth grids generated by a hydraulic model (.asc format) and some background mapping (geotiff ...
1
vote
1answer
67 views

Cannot find pythonwin on my ArcGIS 10.1?

What is the version for the Python in ArcGIS 10.1 and what is the build ? My laptop does not show having pythonwin in the folder under C:\Python27\ArcGIS10.1\Lib\site-packages\pythonwin. Is there ...
2
votes
2answers
58 views

How to find number of synchronized records in ArcGIS10.2.2 (Data Management)

I want to find number of records synchronized while using arcpy.SynchronizeChanges_management tool. Right now, I'm getting only messages like process is Executing, Synchronize successfully ...
2
votes
0answers
45 views

how to extend polyline to the intersection point?

I have a polyline shape file, would like to extend the polyline to the intersection point of the nearby polyline and snap using python in Qgis. Thanks
1
vote
1answer
124 views

Python IDEs (PyScripter,PythonWin) crashing when installed with ArcGIS for Desktop?

I am learning Python, so here is a real newbie question! Everything writen in ArcGis Python's windows is working fine. The same lines, correctly writen in an IDE, when run, are crashing it. Working ...
2
votes
1answer
57 views

How to calculate area using QgsDistanceArea?

I am trying the following code as given in the QGIS documentation: d = QgsDistanceArea() d.setProjectionsEnabled(True) print "distance in meters: ", d.measureLine(QgsPoint(10,10),QgsPoint(11,11)) ...
3
votes
1answer
112 views

How to use QGIS field calculator in python?

I would like to use QGIS Field Calculator in Python to update the existing column based on certain conditions? How can I do this?
1
vote
1answer
37 views

Which parameter and Data Type to set for spatial reference in ArcGIS Python script tool?

I developed a python script for user defined grid and I want to make a tool from this script. The problem I am facing is to set up parameter for spatial reference. I used GetParameterAsText ...
1
vote
1answer
42 views

Slanted raster along the line? Wind erosion model and windbreak effectivity

I'm working on wind erosion modelling and windbreak potential. Imagine windbreak, which has some values of optical porosity (in %) and this values determinates the effectivity of windbreak in specific ...
1
vote
1answer
21 views

Using ModelBuilder to replicate series of tasks without deleting output features first?

I am calling a number of files that I want to clip etc in ModelBuilder which clips data and sends it to a specific feature class. I want to re-run that same process for which I have converted the ...
3
votes
0answers
46 views

How do you find out where there are missing tiles on a basemap on ArcGIS Server?

I have a basemap service on ArcGIS Server 10.1 where after doing a cache update (exploded cache), some of the tiles are missing. I have added a "missing tiles.png" so that it shows where the missing ...
2
votes
1answer
121 views

How to add vertex to an existing polyline programatically?

I have a Polyline and would like to add new vertex to before start point or end point or at any part of the polyline using python in qgis. How can i do that?
0
votes
1answer
41 views

How to set attribute to selected field?

I am trying to create a temporary point layer in memory using the following python code. # create layer vl = QgsVectorLayer("Point", "temporary_points", "memory") pr = vl.dataProvider() # add fields ...
2
votes
0answers
131 views

Calculate area in square meters from degrees?

I have a polygon shape file in geographic coordinate system, i would like to calculate area in square meters in QGIS using python. Is there any formula or equation to do this? Thanks