3
votes
1answer
40 views

Are the functions in OGRPolygon accessible through the python bindings?

I'm currently trying to use the OGR python bindings to process some shapefiles. I want to obtain the number of interior rings in a polygon feature. Unfortunately I'm unable to use the documented ...
0
votes
2answers
55 views

using Python to calculate NDVI, output as a Geotiff

I need a script that can calculate NDVI from two separate input Geotiff files, then output the results as a Geotiff. I wrote following script, most of which is borrowed from various on-line sources ...
3
votes
3answers
351 views

Python - Find the largest extent in a list of extents (tuple format)

I am trying to find a way (simplest is the best) to retrieve the largest extent in a list of tuple extents in python. The list is looking like that: extents = [(-180.0, -90.0, 180.0, 83.624), ...
2
votes
1answer
26 views

How can I extract only band 4 from a geotiff multi bands to create geotiff or AAIgrid with this band using Python?

I have a geotiff file with many bands... I will like to create a .asc file or tiff file by converting only one band from the geotiff file. I don't find the solution by using python... With ...
0
votes
2answers
28 views

Get srid from a shapefile using ogr

I'm writing a script to import shp to postgis, using python, osgeo and psycopg2 ( see my previous question: Import shp to Postgis using Python and ogr ) I'd know if there is a way to get by osgeo ...
1
vote
1answer
38 views

How to call ogr2ogr from command line with Python 2.7 from ArcGIS 10.2 for Desktop?

I am trying to access ogr2ogr in the command line, and this is the message I receive: 'ogr2ogr' is not recognized as an internal or external command, operable program or batch file. This is ...
1
vote
0answers
32 views

Decompress a LZW-compressed GeoTIFF

I have a LZW-compressed GeoTIFF file and would like to split it into several smaller regional files and change the format to png. I tried to do the spliting with gdal_translate -srcwin. I only get a ...
2
votes
2answers
51 views

Memory and Processing Efficient Approach to Read a Timeseries in Python

I am trying to store a timeseries of high resolution raster images containing NDVI values into a dictionary for calculations. I am curious as to which approach may the most efficient when loading ...
1
vote
1answer
34 views

Split Large GeoTIFF to smaller regions with python and gdal

I have quite a large GeoTIFF-file (compressed 50MB but unpacked 6GB) and want to split it into several smaller regional files. Therefor I am using python. As I am a new gdal user I do not really have ...
0
votes
1answer
30 views

gdal polygonize in python error, blank polygon created

I am having trouble using the Polygonize function in python. The cookbook example for this can be found here. The relevant portion of my code is: sourceRaster = gdal.Open('myraster.tif') band = ...
0
votes
1answer
44 views

Gdal creating raster rotated wrong way

I have been trying to read in a stack of images for a timeseries and created an output raster that contains the max pixel values of the timeseries. The arrays were created using numpy img_stack = ...
0
votes
1answer
25 views

How do I use ogr2ogr with python GDAL? [duplicate]

I've just installed GDAL, but I don't know how to import/use ogr2ogr. I've tried: from osgeo import gdal from osgeo import ogr and searched both for ogr2ogr, but it wasn't there.
0
votes
0answers
23 views

No data appears when using gdal_calc.py but source had data values

I'm in the process of calculating topographic exposure using a mix of GDAL, grass, R and python in Windows. I need to process a very large tiff file using the following calculation: ...
1
vote
0answers
35 views

How to use GDAL on Heroku?

I have a geospatial python app that I want to use on Heroku. This is my requirements.txt file: Flask==0.10.1 Jinja2==2.7.2 MarkupSafe==0.19 Werkzeug==0.9.4 gunicorn==18.0 itsdangerous==0.23 ...
1
vote
2answers
51 views

Mask image based on no-data pixels in another image with different projection - GDAL or Python

I've got a land cover image which covers the whole globe, and a satellite image which covers a very small part of the globe. These two images have different projections, co-ordinate systems and pixel ...
0
votes
1answer
67 views

Import shp to Postgis using Python and ogr

I just export a Postgis Table to shp using this tips but I'm not able to import a shp to Postgis using the same library(ogr). Any idea? Thanks a lot f.
1
vote
0answers
43 views

How can I draw features on GeoTIFF in Python?

I have a set of data (coords + value) and want to turn it into a heatmap in GeoTIFF. Should I calculate pixels and set them as array, or there are shortcuts? This is what I do now: driver = ...
0
votes
1answer
54 views

How to get the pixels from a geotiff file in gdal python for a given bbox?

I have a GeoTIFF file in WSG 84 Projection reference (it's a GeoTIFF of SRTM). I can use python & gdal to read the whole lot of data into an array (with ReadAsArray()), but I want to only have a ...
0
votes
0answers
70 views

GEOS assertion failed

The following script fails, if I import the 'rasterstats' library. import rasterstats import ogr geom1 = ogr.CreateGeometryFromWkt('POLYGON ((415924.806155724043492 ...
1
vote
2answers
107 views

os.system /subprocess.call error handling when error in command line function?

In my Python script I call a GDAL utility using: subprocess.call('gdal_rasterize -a ICE_TYPE -where \"ICE_TYPE=\'Open Water\'\" -b 1 -burn 5 -l ' + shapefileshortname +' ' + shapefile + ' ' + ...
3
votes
2answers
136 views

how would one get the end points of a polyline?

I am attempting to write a script to get the end points of a series polylines, and then use those end points to create a polygon. I'm not sure which tools to begin to use on this project. I would ...
3
votes
2answers
83 views

Python, GDAL, VRT: help wth code efficiency and processing time

I'm going to attempt to make this question as succinct as possible while still including relevant information, as I have trouble with being concise and am trying to avoid writing unnecessary stuff. ...
1
vote
1answer
119 views

Why does OGR driver.Open() for File Geodatabase give AttributeError: NoneType object has no attribute Open?

There are a number of existing Questions that hint at a possible Answer to this Question, but none seem to be providing me with the solution to my problem: How to access feature classes in file ...
2
votes
1answer
122 views

“ImportError: No module named gdalsrsinfo” What's the issue?

in the python console I can call import gdal, and gdal is recognized as a module; however, most gdal programs, such as gdalinfo and gdalsrsinfo are not recognized. I checked the GDAL source files to ...
2
votes
0answers
56 views

Zonal Statistics using Gdal and Python

I recently came across a loop_zonal_stats function by @ustroetz found here: Issue Trying to create Zonal Statistics using Gdal and Python.. I am using a (single) polygon shapefile and a raster file to ...
1
vote
0answers
47 views

Write raster with its attribute table and symbology

I am classifying lots of rasters and I'd like to automate the legend creation and symbology displaying for easy manipulation. Here is the kind of raster I'm dealing with: library(raster) r <- ...
0
votes
0answers
21 views

Is there a way of converting polygon vertices to points using GDAL python? [duplicate]

I have an ArcGIS standard license and I want to convert polygon vertexes to points in a script. Since I don't have a good enough ArcGIS license I've been using ET Geowizards to get the points. The ...
0
votes
2answers
62 views

Is it possible to alter raster values without Arcpy? [closed]

I'd like to be able to alter raster values, through fairly simple equations, without using the module Arcpy. Is that possible? It seems like gdal, numpy, and rasterlang might make this possible but ...
3
votes
0answers
168 views

Reprojecting WGS 1984 Web Mercator (EPSG:3857) in Python with GDAL

I am reprojecting rasters in python using GDAL. I need to project several tiffs from geographic WGS 84 coordinates to WGS 1984 Web Mercator (Auxiliary Sphere), in order to use them later in Openlayers ...
1
vote
1answer
145 views

Convert polygons in shape file to a numpy array?

I have a shape file containing a number of polygons and all attributes being text. I'm trying to import the polygons into numpy as an array where each polygon is represented as unique values. I ...
0
votes
1answer
91 views

Cannot import gdal_array

I attempted to use GDAL without installing due to not having rights to install on this computer. I managed to get several gdal modules working, but when I attempted to use ReadAsArray() I received the ...
0
votes
3answers
136 views

Is it possible to use GDAL without admin rights?

I am trying to do some image analysis in Python but am unable to install GDAL due to limited rights. I have attempted copying some of the files and folders into my python folder but am constantly ...
2
votes
1answer
96 views

How to use Python console under QGIS 2 with gdal module?

I am trying to move my plugin from QGIS 1.8 to QGIS2.0. However, the gdal module cannot use under QGIS2.0. I try to use Python console, typing: import gdal #it's OK gdal.GetDriverByName( ...
0
votes
1answer
68 views

How do I use gdal_proximity.py from the QGIS python console?

How do I run gdal_proximity.py from the QGIS python console?
0
votes
1answer
80 views

gdalbuildvrt error, when using in Python

I am new to python/GDAL and am running into perhaps a trivial issue. This may stem from the fact that I don't really understand how to use GDAL properly in python, or something careless, but even ...
1
vote
1answer
56 views

Polygons not appearing when creating shapefile based on criteria using GDAL and Python (area calculated properly)

I am looping over the features of a shapefile containing multiple polygons. If certain criteria are met, I want to save the current feature in a new shapefile. I am doing this using GDAL 1.10.0 with ...
1
vote
1answer
126 views

using GDAL/python to stack georeferenced images of different sizes

I am in the process of porting a code I wrote in IDL (interactive data language) to python but am running into a bit of a problem that I am hoping someone can help me with. The code goes like this: ...
3
votes
1answer
93 views

Why close a dataset in GDAL Python?

I see quite often in Python GDAL code that people close datasets at the end of their script. Why does it makes sense to close a dataset in Python GDAL? Are there any consequences if I don't do it? ...
3
votes
2answers
76 views

in python, srs.ExportToProj4() returns an empty string, why?

I have a shapefile with the following .prj file: ...
1
vote
2answers
69 views

Difference between OGRGeometry and Geometry in C++ and python

According to the documentation, there is a python version of OGRGeometry's C++ class (http://www.gdal.org/ogr/classOGRGeometry.html) which is http://gdal.org/python/osgeo.ogr.Geometry-class.html ...
6
votes
2answers
272 views

Convert points to lines with Python GDAL

I have a dictionary with points. The points are derived from a raster (see image below). The points are not sorted and are not in order. The dictionary looks for example like this: pointDict = {0: ...
2
votes
0answers
206 views

GDAL polygonize lines

I have a raster file containing roads (left image). I polygonize the raster file with GDAL (see the script below). In the end I like to have vector lines. However GDAL only gives me something like ...
1
vote
1answer
119 views

GDAL polygonize only certain raster values

I want to polygonize a raster file with GDAL. I only want to rasterize cells with a value of 0. Is it possible to specify that within the polygonize function or do I have to modify my raster before ...
2
votes
2answers
308 views

Issue Trying to create Zonal Statistics using Gdal and Python.

I am trying to create zonal statistics using Python and Gdal. I have a polygon shapefile and a raster file, and in order to do so, I am using a piece of code I found in StackExchange. The raster and ...
-1
votes
1answer
145 views

How to Geocode use GeoPy API combined with GDAL Python bindings?

My question is related to the 'How to Geocode 300,000 addresses on the fly?' topic that has been asked by Mehul Nahar. I'm interested in running the processes explained by capooti in response to mehul ...
0
votes
1answer
133 views

Why do Shapefiles and GeoJSON behave differently in GDAL Python?

I have a test.shp. I loop over the file, buffer the features, and write the buffers to a new file. I tested writing the buffers to a Shapefile and to a GeoJSON. If I try to use the new buffer layer ...
0
votes
1answer
204 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 ...
1
vote
2answers
183 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 ...
4
votes
2answers
204 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 ...
4
votes
1answer
174 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 ...