Tagged Questions

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

learn more… | top users | synonyms

0
votes
0answers
2 views

Multiple Subsetting

I have a XYZ .csv file for a large portion of an area. I have another txt file which contains Box numbers, Xmin, Ymin, Xmax, Ymax. I would like to export a CSV file for each boxes from subsetting a ...
0
votes
0answers
3 views

Trouble inserting name of feature in TOC into attribute table using arcpy.calculateField

I currently have about fifty rivers and creeks in a map, and none of the features contain the name of the waterbody. However, the features are named correctly in the table of contents Ideally, I ...
1
vote
3answers
14 views

Drawing some points in QGIS 2.4 using Python

I'm new to PyQGIS so here goes: Give a new QGIS project, how can we draw some Points on the map? I tried the following but nothing showed up. Should they be placed in a Vector layer before they can ...
0
votes
0answers
9 views

Convert DateTime field to Just Date in Label Expression

I have a DateTime field (ex: CreatedDate) and would like to only show the date with the label. How would I setup the label expression to do this using python? Thanks in advance!
2
votes
1answer
12 views

Troubles referencing fields in code block of Field Calculator

I'm trying to use values from a field to fill a new field with a truncated version. The 'str.rindex' function is working out well, but I can't seem to figure out how I'm supposed to reference the ...
0
votes
1answer
23 views

Programmatically Select a CRS in QGIS 2.4 using Python

When you run the following Python code in the Python Console of QGIS 2.4, uri = "file:///C:/data.csv?type=csv&xField=lng&yField=lat&spatialIndex=no&subsetIndex=no&watchFile=no" ...
2
votes
0answers
32 views

Bug in arcpy mapping?

Has anyone else had this problem? I have an mxd file with two layers in it, one of which is fairly 'heavy' (i.e. takes a minute or so to draw). All layers are visible by default. I have the ...
1
vote
0answers
27 views

Python script for dark object subtraction on Landsat 8 Imagery

Does anyone know of any python scripts that will allow me to conduct such a process? I am limited to open source software and have minor experience in Python.
1
vote
2answers
33 views

How to change field defined as REQUIRED to NON_REQUIRED in ArcGIS Geodatabase

I have created some feature classes in a geodatabase and also some fields using this sample code: arcpy.AddField_management("schools", "ref_ID", "LONG", 9, "", "", "refcode", "NULLABLE", "REQUIRED") ...
2
votes
3answers
31 views

Removing small polygons gaps in a Shapely polygon

I know this issue has been addressed before with different software, but I am looking for an approach with Shapely. I have a polygon with a very small gap on the interior of the shape: Here is a ...
0
votes
1answer
15 views

Running GRASS functions in QGIS 2.4 from python console

I am using qgis 2.4 and i am looking for the "easiest" way to execute e.g. the r.in.gdal function from the python console in qgis. Specifically for r.in.gdal, I could not found this function in ...
1
vote
1answer
21 views

How to take cosine squared of raster using python

I have an equation y = cos^2(x) where x is a raster. How can I write this equation in python?
2
votes
2answers
36 views

How can I select features based on another feature attributes?

Here is my case: I have a layer of features (buildings from a city) that is populated with polygons. This polygons have attributes : street name and postal code In the project I have another layer of ...
1
vote
0answers
16 views

QGIS Deployment in Citrix XenApp - How to Remove Pyramids from the image “properties”

I'm working on deploying QGIS 2.4 into a XenApp 6.5 desktop environment. We've tested QGIS to see if it will run in our environment on a test server and have found that building Pyramids with Ariel ...
1
vote
0answers
19 views

Use PyQGIS to import CSV and draw points using different color

A CSV file contains columns latitude, longitude and color. uri = "file:///C:/data/balls.csv?type=csv&xField=longitude&yField=latitude&spatialIndex=no&subsetIndex=no&watchFile=no" ...
2
votes
1answer
21 views

Add OpenLayers layer from QGIS's Python console?

On QGIS 2.4.0-Chugiak the Openlayers plugin is found under Web menu rather than the Plugins menu. How can you use the Python console to add a Openlayers Google Maps layer? The following code give us ...
3
votes
2answers
56 views

What is the best way to get from wkt to shapefile in Python?

I am querying tables from a SQL-Server database and would like to convert the table into a shapefile. It has wkt geometries and wkb as columns in the table, along with other attributes that need to ...
1
vote
0answers
20 views

py2exe ImportError: No module named _err

The .exe file generated with py2exe returns the following error: c:\Users\...\dist>ShapeFileConverter.exe Traceback (most recent call last): File "ShapeFileConverter.py", line 4, in ...
1
vote
2answers
31 views

Automating procedure to add shapefile to multiple map templates using ArcPy?

I have a project that has me create a package of about a dozen maps for a client and I do this multiple times per week. I am trying to figure out if there is a way to automate this with python. I am ...
1
vote
1answer
32 views

slow Python script pulling from an iSeries database

I've converted and updated some python scripts that exported data from an iSeries database (HTE) to Access to export the same data to a fgdb. My biggest issue is the time it's taking to export the ...
3
votes
1answer
48 views

Fast raster combine using rasterio

I'm trying to duplicate the functionality of ArcGIS's Combine function within rasterio. Given a list of (presumably categorical) rasters read with rasterio, I want to output a combined raster and a ...
1
vote
1answer
37 views

ExecuteError: Failed to execute. Parameters are not valid. ERROR 000732: Layer Name or Table View: Dataset L does not exist

Hi I am trying to create a loop so that each layer is produced in its own map. This is my code: import arcpy path = "C:\Users\Et\Documents\ArcGIS\Default.gdb" mxd=arcpy.mapping.MapDocument(path ...
1
vote
1answer
37 views

QGIS select reversed geometries

I have a road network and a geometry for each road direction. One Geometry from A->B and another Geometry from B->A. This geometries are covering each other. Is there a tool available in QGIS to ...
3
votes
0answers
34 views

Select and copy attributes features in ArcMap using Python add-in tool?

I'm trying to add a tool to an add-in toolbar to select features from an existing feature class and copy attributes to another feature class,from point to point. TopoHeight_Field_Name='Comment' def ...
0
votes
0answers
7 views

Pixel Value Recording Script Efficiency

I have been working on a script to read pixel values and print the values out to a text file. This is currently working but takes around two hours with a 6.6gb file. This is to replace an older script ...
2
votes
1answer
22 views

Shapely's simplify won't simplify any more

I have a multipolygon in shapely, and I want to simplify it until it has less than a certain number of points. When I use the preseve_topology=False argument to geom.simplify, I can get the number of ...
4
votes
1answer
43 views

SQL-query in arcpy - SELECT WHERE feature between two values

I need to select features between two values in python with arcpy. However, whenever I try to run the code below, it returns with error message "An invalid SQL statement was used". whereclause = ...
0
votes
0answers
34 views

Free ebooks of QGIS [duplicate]

I am new to QGIS and python. Can any one tell me, where I can find QGIS and Pyqgis ebooks for free.
1
vote
1answer
50 views

Could not open/read USGS raster file

I could not open/read the following .img file. The document below says it is a raster file. http://edc2.usgs.gov/1KM/land_sea_mask.php I tried to open it using many ways such as Q-Gis software, and ...
9
votes
2answers
136 views

How can I parallelise embarrassingly parallel GIS operations in QGIS python?

A common requirement in GIS is to apply a processing tool to a number of files or apply a process for a number of features in one file to another file. Much of these operations are embarrassingly ...
2
votes
0answers
27 views

What is the issue with geopdf format?

I'd like to add the geopdf format as output of a library that I am working on. After have looking around, I have not been able to find a (c, c++, python) library that meet my license requirements ...
2
votes
0answers
53 views

Error with da.UpdateCursor and SDE feature classes

I am making my first attempt at editing an ArcSDE feature class with python through a da.UpdateCursor. I'm essentially taking code I've written for a file geodatabase feature class and applying it to ...
2
votes
1answer
34 views

Arcpy PointGeometry does not carry forward the ID

I used this as starting point I have the following code: Test data data = numpy.array([(0, 51.1047664, -114.3722785, 1205, ...
-1
votes
1answer
40 views

Geocode as soon as PostGIS table is updated

I am trying to create a map such that as soon as I enter an address into PostGIS table, it'll automatically be geocoded (and published in geoserver). The only way I could think of doing this was using ...
1
vote
1answer
34 views

Calculating distance between latitude and longitude by using python

I have a database of 2000 points, which is in csv format of latitude and longitude. I want to find distance between these points all at once. And also showing these points in Map by using only pyQGIS. ...
0
votes
2answers
21 views

QGIS 2.4 crashes when symbolizing QgsComposerShape in Python with ScriptRunner

I'm attempting to use ScriptRunner to output a jpeg of a red rectangle using QGIS Composer to understand the QgsComposerShape. Everything works except QGIS crashes when the symbol is applied. The ...
0
votes
1answer
52 views

Needed either python or VB Script to write right indent

Question : I have a field column that is has numbers with percent. The field properties are string and 50 in length. I ran it in an expression using round([T_Acres]/207 * 100,0) + "%" in VB script . ...
1
vote
0answers
51 views

How to convert length in Decimal degrees to meters programmatically?

I'm new to qgis and I want to find the length of some roads in a map. So I used the following code, from shapely.wkb import loads def getLength(): layer = ...
2
votes
1answer
52 views

Reading postgis geometry with shapely

I am doing a small-scale workflow in ipython notebook with geopandas and shapely, pulling a bunch of geospatial data, sometimes from shapefiles, sometimes from postgis (where more expensive processing ...
1
vote
2answers
33 views

Specify a GDB feature class using Python Tkinter dialogue box

I tried to specify a feature class from a GDB dataset through Python Tkinter tkFileDialog.askopenfilename. Below is the script. It worked for me in the past when I was dealing with .txt or .las files. ...
1
vote
0answers
21 views

Asset point IDs, pipeline and flow direction

I have a data set of a sewage pipe network and point data (assets). I would like to: first calculate the flow direction of pipes (polyline feature) assign IDs to the pipelines using asset IDs ...
0
votes
0answers
24 views

Writing shapefile with projection defined crashes Fiona part two

I have the same problem as this post. Writing shapefile with projection defined crashes fiona It says that was an issue with GDAL. I cleaned my site-packages of anything GDAL, fiona, six related. ...
1
vote
1answer
36 views

Iterating an ArcGIS tool over multiple Fields with selection boxes

I have one shapefile that contains many fields and I'd like to write a simple script tool that allows me to run IDW for the fields I select. Is this possible? For example..... Input: 1 shapefile ...
1
vote
2answers
103 views

Field Calcuator to add percent using Python

What might I go wrong here is that I am trying to add percent. I use the Field Calcualtor and it keeps getting an error. I am opening the Table to add a field named Percent and then type this: ...
1
vote
3answers
43 views

Export selected fields in ArcGIS to Excel using Python

I'm am creating a script that will allow a user to add XY coordinates to a point layer, then export (along with any addition user selected fields) to Excel. I am getting stuck on the iteration of the ...
1
vote
0answers
43 views

Iterating between two layers using QGIS python

I will try and explain my situation as clearly as possible. I just created my first plugin that is being used to analyze between various layers and give back quantities to the user. Most of it is ...
3
votes
2answers
38 views

How to get arcpy to work with Anaconda?

I am trying to follow the step-by-step directions in the answer to "how to separate Python installation with ArcGIS" but cannot find the path file, DTBGGP64.pth, in ...
2
votes
1answer
38 views

How to find length of a discontinued line feature

I wanted to find the length of features in a road layer. So I go through each feature in the layer and used, line = feature.geometry().asPolyline() to find the points which particular feature is ...
1
vote
0answers
24 views

Error Loading Layer/Shapefile in a Standalone Python QGis Application

I tried loading a shapefile on Python using PyQgis API but to no avail. I double-checked the path to shapefile and found it to be correct. QGIS module also seems to be imported just fine. When I ...
1
vote
1answer
25 views

Use subprocess module to run GDAL processes

I am attempting to write a python script that will reproject & merge a series of .tif files then clip them to the boundaries of a .shp file. I have successfully used the subprocess module to do ...