gdal

Elevation (XYZ) data to slope/gradient map using python

Elevation (XYZ) data to slope/gradient map using python Question: I have a text file with Easting (x), Northing (y), and Elevation data (z) as shown below: x y z 241736.69 3841916.11 132.05 241736.69 3841877.89 138.76 241736.69 3841839.67 142.89 241736.69 3841801.45 148.24 241736.69 3841763.23 157.92 241736.69 3841725.02 165.01 241736.69 3841686.80 171.86 241736.69 3841648.58 178.80 241736.69 3841610.36 …

Total answers: 2

How to prevent GDAL from writing data source to disk when de-referenced

How to prevent GDAL from writing data source to disk when de-referenced Question: I need to extract the raster (stored as a numpy array) from a file. Following the very popular OGR Cookbook, I am reading in an OGR layer (geojson) and then rasterizing the vectors. I read that array using GDAL’s ReadAsArray() function. That …

Total answers: 1

Create a Geotiff file from scattered data in python

Create a Geotiff file from scattered data in python Question: I have a dataset of points (latitude, longitude, value) and i want to create a Geotiff file from these points. latitude,longitude and the value are float32 numbers I want to generate a custom raster that interpolate over those points. Link I want to obtain a …

Total answers: 1

installing Gdal on Windows 10 with python 3.6.4: fatal error C1083: Cannot open include file: 'cpl_port.h'

installing Gdal on Windows 10 with python 3.6.4: fatal error C1083: Cannot open include file: 'cpl_port.h' Question: So I am trying to pip install gdal but got an error. extensions/gdal_wrap.cpp(3168): fatal error C1083: Cannot open include file: ‘cpl_port.h’: No such file or directory error: command ‘C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.13.26128\bin\HostX86\x64\cl.exe’ failed with exit status 2 …

Total answers: 2

Gdal_rasterize nodata_value does not work

Gdal_rasterize nodata_value does not work Question: I want to rasterize a source layer made of polygons. No matter what value I assign to “NoData_value”, the outcome in my array is always = 0. I am using python 3.4. Can anyone help me understand please ? source_srs = source_layer.GetSpatialRef() x_min, x_max, y_min, y_max = source_layer.GetExtent() # …

Total answers: 1

Get the Values of an image in Python

Get the Values of an image in Python Question: I have a GeoTIFF and I need to get the values of each pixel. I proceeded this way : import gdal from gdalconst import * im = gdal.Open(“test.tif”, GA_ReadOnly) band = im.GetRasterBand(1) bandtype = gdal.GetDataTypeName(band.DataType) scanline = band.ReadRaster( 0, 0, band.XSize, 1,band.XSize, 1, band.DataType) scanline contains …

Total answers: 2

Rasterio Geotiff Coordinate Translation

Rasterio Geotiff Coordinate Translation Question: I have some geotiff files but the coordinates are slightly off. I want to use rasterio’s API (or other python geo API like pygdal) to geometrically translate (shift) the image. For example, how do I move the image’s coordinates ‘north’ by a single pixel width. When displayed with a tool …

Total answers: 1

Error while installing GDAL

Error while installing GDAL Question: I’m trying to install GDAL through pip. But I’m getting this error: extensions/gdal_wrap.cpp:3089:27: fatal error: cpl_vsi_error.h: No such file or directory #include “cpl_vsi_error.h” ^ compilation terminated. error: command ‘x86_64-linux-gnu-gcc’ failed with exit status 1 I used these commands: sudo apt-get install libgdal-dev export CPLUS_INCLUDE_PATH=/usr/include/gdal export C_INCLUDE_PATH=/usr/include/gdal pip install GDAL Can …

Total answers: 6

Increase extent of vector layer with OGR or GDAL?

Increase extent of vector layer with OGR or GDAL? Question: When using the OGR library or GDAL library with Python script, is it possible to increase the extent of a vector layer without actually adding new data points? In my specific case, I would like to increase the extent of vector layers associated with gpx …

Total answers: 2

How to copy the spatial reference from a shapefile to a geotiff raster?

How to copy the spatial reference from a shapefile to a geotiff raster? Question: I have constructed a python script that constructs a geotiff raster from a shapefile. At present the geotiff produced does not contain the spatial reference of the shapefile. How do I copy the spatial reference from the shapefile to the geotiff? …

Total answers: 1