Questions tagged [python]

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

Filter by
Sorted by
Tagged with
13
votes
1answer
484 views
+200

Open QGIS project files in exclusive mode / alert if project file already in use

I have QGIS-Project-Files saved to a network drive and was wondering if it is possible to warn users that a project file is already opened by an other user to prevent concurrent editing of the same ...
13
votes
1answer
1k views

Counting features into intersections of Shapely Polygons

I have a geopandas GeoDataFrame containing hundreds of shapely Polygon and MultiPolygon geometries. The polygons overlap in lots of places. I'd like to make a new geometry that contains a count of how ...
13
votes
1answer
2k views

How to access QGIS module from my virtualenv

I am running an Ubuntu 14.4 and I have installed a python virtual environment. Then I pip installed several python libraries (gdal, lxml, psycopg2 etc.) Also in my system I have the module for QGIS. ...
12
votes
5answers
6k views

how can i convert a shapefile to lat and lon boundaries?

i have a shapefile of country subdivisions and i would like to extract an array of bounding lat and lon for each division.. is it possible to do?
12
votes
2answers
12k views

Reading Excel sheet in ArcPy script?

I'm writing a python code to convert X,Y points in excel to shapefile. In this process i have toread xy points from shhet1. What is the step i have to include in my process to read data from sheet1 of ...
12
votes
3answers
9k views

Python equivalent of gdalbuildvrt

Is there a way to perform the same task as the gdalbuildvrt utility using GDAL Python bindings? So far I have not found any way to do this other than creating a vrt of a single dataset and manually ...
12
votes
3answers
14k views

Convert an ASCII grid file to GeoTIFF using Python?

I have a ASCII grid raster format file. For example: ncols 480 nrows 450 xllcorner 378923 yllcorner 4072345 cellsize 30 nodata_value -32768 43 2 45 7 3 56 2 5 23 65 34 6 32 54 57 34 2 2 54 6 35 45 ...
12
votes
5answers
31k views

GEOS and Shapely installation on Windows

When trying to install Shapely on my Windows 64bit computer, I cannot get the GEOS library to work. So far, I have run the OSGeo4W installer from which I installed GDAL (I believe the geos library ...
12
votes
2answers
12k 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 ...
12
votes
3answers
16k views

'NoneType' object has no attribute

I am new to python geospatial programming. i ran the following script and got the corresponding error message >>> import osgeo >>> import osgeo.ogr >>> shapefile = osgeo....
12
votes
5answers
7k views

Compiling Python scripts (to .exe) that use ArcGIS Geoprocessing Tools?

I've been coding with Python for several months now and have developed some reasonably complex scripts for primarily geoprocessing tasks. That being said, I'm still learning a lot as I'm coming from a ...
12
votes
2answers
4k views

QGIS fails to load

I installed some python libraries using pip (pandas, scipy, simplekml) and ever since every time I try to load QGIS I get this error: Warning: loading of qgis translation failed [/usr/share/qgis/...
12
votes
2answers
4k views

Methods for optimizing multcore processing in ArcGIS

I am interested in learning methods to utilize the full extent of multicore processing power available on a desktop computer. Arc states that background geoprocessing allows the user to utilize ...
12
votes
5answers
4k views

Determining min and max values in an ASCII raster dataset using Python?

I have a raster dataset in ASCII format. Using Python, I need to determine the min and max values inside the dataset. I've been told that the header information is key, which contains things like ...
12
votes
2answers
17k views

Creating Shapely MultiPolygons from shapefile MultiPolygons

I'm reading a shapefile using Fiona: with fiona.open('data/boroughs/boroughs_n.shp') as source: mpolys = [p for p in source] candidate = polys[0]['geometry'] this gives me a dict containing a ...
12
votes
5answers
630 views

Smallest GIS library for embedded devices?

I need to use very simple geometry operations (read SHP or other standard format and simple searches) within an embedded device running a simple linux based os. What is the smallest and simplest API ...
12
votes
4answers
2k views

How to use PostGIS to handle complex geoprocessing workflows?

Our organization is considering moving our geoprocessing workflow to PostGIS. We are currently using ArcGIS, with a plethora of custom Python tools used in ModelBuilder. We're moving most of our data ...
12
votes
4answers
656 views

Mirror of Michigan State University's Python geoprocessing course materials

Been learning geoprocessing with Python using MSU's GEOG 825 ( python geoprocessing ) course. Unfortunately the link is dead now. I know this is a long shot but does anybody have a copy of the ...
12
votes
4answers
16k views

using shapely: translating between Polygons and MultiPolygons

[EDIT: the solution to this was simply to use OGR to read shapefiles. See geographika's example.] In an ESRI shapefile, there is no distinction between Polygons and MultiPolygons. Furthermore, there ...
12
votes
1answer
39k views

Reading, modifying and writing a geotiff with GDAL in python

I'm trying the learn the ropes of Remote Sensing image processing using Python GDAL bindings and numpy. As a first attempt, I'm reading a Landsat8 geotiff file, do a simple manipulation and write the ...
12
votes
1answer
1k views

How to address the new “Task-Completed” QgsMessageBar in Python?

I am really amazed what huge steps the QGIS development has taken in the last months. The new iconset, the improved Print composer and many more changes to be seen in QGIS 2.0 are really awesome! ...
12
votes
5answers
2k views

How to convert line simple features to topological network?

using Gdal/ OGR is there a way to convert a shp, kml, or PostGIS line layer into a network of nodes and segments so it can be used in packages such as networkx?
12
votes
3answers
13k views

Getting intersection of multiple polygons efficiently in Python

I would like to get the intersection of multiple polygons. Using Python's shapely package, I can find the intersection of two polygons using the intersection function. Is there a similar efficient ...
12
votes
3answers
4k views

Image processing using Python, GDAL and Scikit-Image

I am struggling with a processing and hopefully I will be able to solve here. I work with Remote Sensing applied to Forestry, especially working with LiDAR data. The idea is to use Scikit-image for ...
12
votes
3answers
15k views

How to create polygon shapefile from a list of coordinates using python gdal/ogr?

I am trying to create a polygon shapefile from a list of coordinates using open source python tools. The following is what I have so far which was hacked together from the Python GDAL/OGR Cookbook and ...
12
votes
2answers
735 views

Measuring Script Writing Competency?

I've been asked by my manager to come up with some sort of competency measure for an employees understanding of scripting/programming. Because I am a self taught programmer, I really don't have a ...
12
votes
4answers
16k views

How to import qgis.core to Python app?

I'm new to Python. I want to create GIS app with Python using QGIS library on Window 7 64 bit. The way I do: install QGIS 1.7.0 I set PYTHONPATH=D:\Program Files (x86)\Quantum GIS Wroclaw\apps\qgis\...
12
votes
2answers
4k views

How to toggle layer visibility in QGIS using Python?

How can I toggle layer visibility in QGIS via Python API?
12
votes
1answer
12k views

GDAL RasterizeLayer does not Burn All Polygons to Raster?

I am trying to burn a shapefile to a raster using GDAL's RasterizeLayer. I pre-create an area of interest raster from a different shapefile, given a specific pixel size. This AOI then serves as a base ...
12
votes
1answer
9k views

Geopandas Line Polygon Intersection

I'm trying to find where multiple lines intersect a polygon for two different geodataframes: from shapely.geometry import Polygon, LineString import geopandas as gpd polygon = Polygon([(0, 0), (1, 0)...
12
votes
2answers
5k views

How to compute Straight Skeletons using Python?

Is there a Python package which provides an implementation of a Straight Skeleton algorithm? I'm aware that the open source (C++) project CGALcontains an implementation but it seems like cgal-...
12
votes
3answers
5k views

Split a feature when intersecting with a feature of another layer using PyQGIS/Python?

I have a buffer layer (green polygon) which I want to split to two polygons whenever it crosses a barrier (blue line). I have been trying to use "splitGeometry" method, but I just can't get it to work....
12
votes
2answers
2k views

Accessing file geodatabase (.gdb) rasters with GDAL?

I'm working on a tool that converts raster layers to arrays for processing with NumPy, and ideally I would like to be able to work with rasters that come packaged in a .gdb without exporting them all (...
12
votes
1answer
22k views

How do I maintain a resposive GUI using QThread with PyQGIS

I have been developing some batch processing tools as python plugins for QGIS 1.8. I have found that while my tools are running the GUI becomes non-responsive. The general wisdom is that the work ...
12
votes
1answer
2k views

Automating roof orientation detection from satellite imagery?

A while ago I did a neighbourhood roof orientation survey for solar panel deployment, by visually checking each roof and marking individually whether they were south or almost south-facing. As this ...
12
votes
3answers
8k views

Extract data from NetCDF using a shapefile polygon in Python [duplicate]

I need to subset data from a NetCDF using a specific shapefile. The data are sea surface temperature and ocean color at 1/4 degree resolution. I have 4 polygons describing the US. Northeast ...
12
votes
1answer
874 views

Alter Minimum Bounding Box Algorithm

I'm trying to create an algorithm similar to minimum bounding box (though it may end up looking nothing like it). In this case the angle will be passed as a parameter and given the angle I need the ...
11
votes
4answers
2k views

How to reproject 500 CSV files efficiently and easily using QGIS?

I know, my question is similar to some old ones on this site. I've a lot of CSV files (geo coordinates) to import to qgis (and then to convert them), and the usual way is not the best way to do it (...
11
votes
5answers
11k views

How to workaround large mosaic process which is failing?

I need to mosaic about 550Gb of tif imagery together and the software I have tried keeps failing. The area has been split into zones so that the smallest has approx 200 tiles. I have used the latest ...
11
votes
3answers
4k views

What are pros and cons of Python add-ins vs .NET add-ins to ArcGIS for Desktop?

I found in ESRI .NET help: Python All ArcGIS Desktop applications include an embedded scripting language called Python. Many areas of ArcGIS—particularly geoprocessing—are accessible through ...
11
votes
3answers
15k views

Obtaining the data of one selected feature in QGIS using Python?

I have a problem/question regarding python and QGIS. Is it possible to get the data of one selected feature in QGIS using python, and if so how? In my example I have a layer which shows some parcels ...
11
votes
2answers
29k views

Obtain coordinates and corresponding pixel values from GeoTiff using python gdal and save them as numpy array

How can I obtain projected coordinates as well as the actual pixel values at those coordinates from a GeoTiff file and then save them into a numpy array? I have arsenci020l.tif file, and its ...
11
votes
1answer
6k views

Intersecting lines to get crossings using Python with QGIS?

I have a set of lines representing bus lines. Some of the lines are overlapping and take the same roads. I am able to extract the nodes. However I am interested in extracting only crossings like ...
11
votes
3answers
5k views

How do I prevent Qgis from being detected as “not responding” when running a heavy plugin?

I use the folowing line to inform the user about the status: iface.mainWindow().statusBar().showMessage("Status:" + str(i)) The plugin takes about 2 min to run on my data set but windows detects it ...
11
votes
2answers
6k views

Programmatically load composer from template and generate atlas using PyQGIS

I am trying to build a plugin to load a print composer from file, generate an atlas and export to image. So far I have been successful in loading the template and exporting it to image. I have been ...
11
votes
1answer
13k views

PyQgis question: How to change or set active layer?

Developing a QGIS plugin, I found that if no layer is selected in the Layers panel I can iterate over all layers and do anything to them, but "activate" them. Could someone give me a hint please?
11
votes
3answers
2k views

Downloading and processing raster files in Python? [closed]

I am fairly new to python and seek guidance for a question which might sound trivial to many. Is there a way to use 'wget' in a python script to download raster files from a server and process them ...
11
votes
2answers
2k views

How to add different sized rasters in GDAL so the result is only in the intersected region

I'm writing a Python method that adds two rasters and generates a single raster output. For reasons beyond my control, the extents of the input rasters are different, but they do overlap. Is it ...
11
votes
1answer
15k views

Georeferencing raster using GDAL and Python?

I want to georeference a raster using python and GDAL. My current approach is to call gdal_translate and gdalwarp using os.system and an ugly list of ground control points. I'd really like a way to do ...
11
votes
2answers
5k views

Measuring distance in spherical Mercator vs zoned UTM

I've got points in WGS84 lat/long and I'd like to measure "small" (less than say 5km) distances between them. I can use the haversine formula from http://www.movable-type.co.uk/scripts/latlong.html ...