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

learn more… | top users | synonyms

0
votes
2answers
773 views

Find longitude for point between two coordinates with pyproj?

I've written a function to get the longitude of a point of known latitude between two known points (might not be working correctly yet), but I feel like there must be a better way of using pyproj to ...
2
votes
3answers
3k views

Is it possible to open rasters as array in NumPy without using another library?

I know that it is possible to open a raster as an array in NumPy using GDAL, but I want to skip GDAL and use NumPy only, as it is cooler handling rasters with NumPy as matrices. There is a similar ...
0
votes
0answers
36 views

qgis build under ubuntu 12.04, but all the python plugins are not there

All the .so plugin show correctly, only the python plugin do not. I am confused and do not know how to fix this. I think there must be some python problem . The build process is successful.
2
votes
1answer
334 views

How to smoothly join two rectangles

I am looking for the Math and steps involved not using a tool. We have PostGIS but its an old version so we are working with the data in Python. Given three coordinates: -107.37, 52.46 -103.24, ...
3
votes
1answer
1k views

layer.visible command not working in arcpy.mapping module

I am using the arcpy.mapping module for the first time, and the lyr.visible command is not working as it should (or I am not using it as I should). I have a list that contains the the layer names of ...
2
votes
2answers
871 views

Find index location of a lat/lon point on a raster grid in ArcPy

This question has been confusing me for a while, and I'd love y'all's help. I'm trying to find the index location on a raster (in terms of column and row#) of a specified lat/lon point. My first ...
2
votes
2answers
512 views

Python-OGR: nested loop only loops once

I have a polygon file buffer_stands.shp with 20 features and I have a line file OSMroads.geojson with 9 features. I expected the script to loop through the buffers and print out for each buffer loop ...
0
votes
0answers
58 views

Combining two separate shapefiles with undefined projections out of Leica

So this is a mess. When the software outputs I have two shapefiles. The projections aren't defined, but I know one is WGS84 and the other is NAD 83. The NAD 83 includes northing easting and ...
3
votes
2answers
201 views

How to define workspace as input for GP tool in order to select from list CAD layers as the second input?

How to define workspace (folder) as input for gp tool in order to select CAD layers as the second input that will be obtained from the first input?
0
votes
2answers
99 views

Error point sampling tool

I'm usig QGIS 1.8.0 and I did some interpolations. Now I want to do some sampling with the point sampling tool but I keep getting this error (I attach a picture of the error message). Does anybody ...
3
votes
0answers
686 views

Is there a way to execute FME transformers from a PythonCaller script in an FME workspace?

I have a very large and complex Python/arcpy script that does lots of custom calculations, and I am trying to port it to an FME environemnt. The script runs beautifully under ArcGIS. The problem in ...
5
votes
1answer
4k views

Python If else statements

I'm trying to populate a field from another. The catch is that it isn't 1 or 2 values. If my field A = 4 then I want it to return field B to 0. But if Field A is 1, 2 or 3 then I want the user to be ...
1
vote
1answer
257 views

how activate qgis features selection toolbar in the main window

How can i activate and desactivate qgis features selection toolbar in the main window using a signal in a python plugin?
2
votes
1answer
85 views

How to run shapefile.py

I'm script challenged and trying to repair a shapefile with a missing .shx. This tool sounds ideal: https://code.google.com/p/pyshp/, but the four step instructions are not enough. Can someone give me ...
1
vote
0answers
80 views

Russian in fieldname changing with Python in ArcGIS

Is there any way to rename fieldname in the attribute table of a layer/shapefile in ArcGIS 10.2 containing russian letters? If yes, is it possible to do it in a script?
3
votes
2answers
3k views

OSM - Extract Streets from OSM Data (With/Without Python)

I'm currently in the works of creating a pythonic way of extracting street names from an OSM dump for the Province of Quebec. Originally, I wanted to do this in Python to make it easier to integrate ...
11
votes
3answers
1k views

How to convert LAS file to numpy array?

I have begun learning how to manipulate LAS data in python and wanted to see how others handle LAS files. I would like to read the points (I am using a numpy array), and filter out classes 1 and 2 ...
7
votes
3answers
2k views

How to Receive an Email after a script has run?

I'm working my way through my first attempt at scheduled tasks with modelbuilder and python. So far I have: Created a model that reconciles our SDE versions and then compresses the database. ...
0
votes
0answers
593 views

Change field attribute in one column based on Domain value from another field using Field Calculator

When I am editing a feature class, I want to automatically populate another field base on one column in the table. Here are the fields and data I am working with. Proj_Code, Proj_Name DA, Dawn Lake ...
5
votes
2answers
2k views

Stereographic projection of WGS84 ellipsoid on a plane[python]

I would like to ask you for help in following task. What I need to do is to derive local x,y coordinates from latitude, longitude, applying stereographic projection of WGS84 ellipsoid on a plane, ...
6
votes
2answers
3k views

How to get field names in pyqgis 2.0

I am trying to change an plugin from QGIS 1.8 to 2.0. In the 1.8 version I create a table of the field names like this: layer = vlayer provider = layer.dataProvider() feat = QGSFeatrue() allAttrs = ...
1
vote
1answer
229 views

Different output from running algorithm in toolbox and from script

I am unable to get the same results when running the qgis:reproject tool from QGIS processing toolbox (QGIS version 2.0.1) as when running it from a Python script (console). In this example I am ...
1
vote
1answer
201 views

QGIS Python Composer Attribute Table has no content

I post 2 Month ago the same question. So I try it a second time with more code. My Problem still is that I add at the composer a attribute table and in this table there is no content. My Code: ...
5
votes
2answers
4k views

Loading PostGIS raster layer into QGIS

I am unable to load a PostGIS raster layer into QGIS. I have looked through previous posts Loading raster from PostGIS DB into QGIS and Cannot add the PostGIS raster layer with QGIS but was not able ...
-1
votes
1answer
251 views

Python - indentation error [closed]

I've started learning python for future use in QGIS and using Ubuntu, installed with Python 3. I'm doing the tutorials from the great book for newbies "A byte of python". I'm having troubles running ...
2
votes
2answers
1k views

Calling variables within ArcPy functions

I have a defined function (ex. def my_function(x,y)). def my_function(x,y): """algorithm""" my_variable = my_function(filex, filey) How can I call this variable within the code block section of ...
1
vote
2answers
161 views

how to identify qgsvectorlayer area?

I need to identify the area from Qgis qgsvectorlayer anyone have an idea how to do that in python ?
1
vote
2answers
363 views

No prj file output from qgis:reproject

I'm trying to reproject a vector layer using the 'qgis:reproject' algorithm in the processing/sextante module of QGIS, from Python. This kind of works, but the .prj and .qpj files created after ...
1
vote
1answer
62 views

How can I avoid creating a new cursor object repeatedly while counting features in a large SDE Database?

I would like to get a script running much faster than it is now. The script completes on my machine in about 33 minutes. It generates a report that counts features with specific attributes in one ...
0
votes
2answers
61 views

Migrating several shapefiles from one server to another?

my organization is a large ESRI user and we are under going some hardware changes. My question is: Is there a way to move several shapefiles scattered across many folders (in one server) to another, ...
1
vote
1answer
615 views

Select by SQL in QGIS Python

In the GUI there is the Query Builder, but that does not seem to be easily available in Python. The processing (SEXTANTE) module has the qgis:selectbyattribute algorithm, but that only supports ...
1
vote
1answer
418 views

Split table column and use to update another table

I have a table (T1) which I need to populate (using python for ArcGIS) the fields Val1, Val2 and Val3 ID Val1 Val2 Val3 0 1 2 with data from another table (T2): ID Data 0 V1 1 V1 2 V1 0 V2 ...
2
votes
1answer
560 views

How to extract vegetation polygons from Imagery using Python?

I have been trying to roughly polygonize vegetation areas from Imagery (RGB). I tried using Iso Cluster Unsupervised Classification (Spatial Analyst) but it is still too detailed for my purpose. I ...
1
vote
2answers
684 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 ...
0
votes
2answers
717 views

GDAL and Python: how to create new files for (e.g.) clipping with gdalwarp

I'd like to learn using GDAL, and I want to use it in Python. Following the tutorial (http://www.gdal.org/gdal_tutorial.html), I succeded in opening vector and raster files using ogr.Open and ...
4
votes
0answers
73 views

Using QGIS plugins from Python [duplicate]

Is there a simple way to automate calls to QGIS plugins from a QGIS Python script? Either from console or a plugin? I am ideally looking for a way to specify input/output parameters and bypass GUI. ...
2
votes
1answer
423 views

Embedded python script module import issue

I have two ArcGIS python scripts. One is a primary python script that calls a number of functions from a second python script. Everything works well, i.e. primary tool calls and uses functions from a ...
1
vote
2answers
1k views

How to remove z & m coordinates from kml files

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 ...
4
votes
1answer
1k 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 ...
3
votes
2answers
1k views

Get coordinate of second to last vertex for python ArcGIS

I need to obtain the x and y attributes of the second to last vertex for each segment and add to the attribute table using Arcpy (or some other python module). To get the Y co-orodinate of the first ...
6
votes
2answers
2k views

In Python, reading a GDAL raster from memory instead of a file

I'd like to analyze some raster data in Python using NumPy. This data doesn't necessarily exist as a file on the filesystem, it could be the result of a query against PostGIS, or something ...
1
vote
1answer
572 views

How identify Layer name when removing it from legendInterface qgis?

I am trying to connect the removing layer action with a slot for doing some processing after that. I already try this: QObject.connect(self.iface.legendInterface(), ...
3
votes
0answers
65 views

How to automate creation of Network Turn Features from line segments? [closed]

I have a road network which I will add Turn features in. From the road network, I have created a model that cuts out the line segments where the turn features will be located. My problem is how to ...
2
votes
1answer
2k views

How to call processing toolbox in Qgis' python console

I have been trying to use processing toolbox via python console in Qgis 2.0.1. I am able to write the following comamnds: I am particularly interested to run 'r.statistics' from GRASS module. ...
0
votes
1answer
86 views

Inverse Distance Weighted Python error in QGIS 2.0

When I wanto to use the command Inverse Distance Weighted in QGIS 2.0, I want to execute as batch process but when I open file it appears a window that say Error de Python This is what it says: ...
2
votes
0answers
286 views

How can I create random concave polygons for test purposes?

In the context of generating random test data using QGIS (in a shapefile): I can generate random, continuous (adjacent) polygons by first creating n random points using ftools and then generating a ...
4
votes
1answer
1k views

How to apply “Band” settings using gdal Python bindings?

I am trying to replicate the gdal_translate command, but using pure Python: gdal_translate infile.tif outfile.tif -co COMPRESS=JPEG -co PHOTOMETRIC=YCBCR -co TFW=YES -b 1 -b 2 -b 3 I have ...
7
votes
1answer
1k views

Is there a python option to “join attributes by location”?

I am trying to perform the function join attributes by location as found on the QGIS menu Vector>Data Management Tools. I am seeking an open source python option for this. I know arcpy has a spatial ...
1
vote
0answers
82 views

How to create a startup prompt that populates definition queries on multiple feature classes

I would like to create an ArcGIS start up prompt or custom button that asks for a user's initials and then populates multiple feature class & layer definition queries. More specifically, I would ...
0
votes
1answer
120 views

Pyshp Editor error

Following my predecessors (here and here) I am trying to append new data to shapefile using Pyshp. The specifics of my problem is the need to save the file with the same name (without creating a new ...