py-gdalogr-cookbook icon indicating copy to clipboard operation
py-gdalogr-cookbook copied to clipboard

A cookbook full of recipes for using the Python GDAL/OGR bindings.

Results 34 py-gdalogr-cookbook issues
Sort by recently updated
recently updated
newest added

Trying the python-gdal cookbook, exactly this step: https://pcjericks.github.io/py-gdalogr-cookbook/geometry.html#buffer-a-geometry ``` poly = pt.Buffer(bufferDistance) ``` returns: `None` and: `poly.ExportToWkt()` Returns: `AttributeError: 'NoneType' object has no attribute 'ExportToWkt'`

At [clip-a-geotiff-with-shapefile](https://pcjericks.github.io/py-gdalogr-cookbook/raster_layers.html#clip-a-geotiff-with-shapefile) ``` python pixel = int((x - ulX) / xDist) line = int((ulY - y) / xDist) ``` Shouldn't that second `xDist` be `yDist`? Of course they're almost always...

I just found this out the hard way. Maybe this can be noted in the "Iterate over features" section? (Great guide by the way, it's really helpful for getting started.)

The # Add features to the ouput Layer part fills the out shp without with the n first attributes values whatever you ask. Eg IN.SHP(a1,a2,a3,a4,a5) OUT.SHP(a1,a3,a5) will receive a1,a2,a3 values...

Although the code in zonal_stats() is a good example of reading geometries, I believe using GetEnvelope() is a simpler way to get feature extent.

It seems it's better to use statistical functions from numpy.ma with masked arrays because numpy functions produce strange results. For example, median() sometimes returns masked constant. Also, mean() and average()...

In several recipes I used the wrong arguments in the GDAL create function. The documentation for function can be found [here](http://www.gdal.org/classGDALDriver.html#adb7bff9007fa5190d6cf742cf76942a8). I always mixed up the number of bands with...

See an example here: http://gis.stackexchange.com/questions/74048/setcolorinterpretation-for-a-geotiff-using-gdal-not-working

All the current examples of writing feature data are writing _new_ layers. However updating values in existing layers is a common use-case, and as I just did it for the...