All Questions
1,068 questions
47
votes
1
answer
36k
views
Getting pixel value of GDAL raster under OGR point without NumPy?
I am working on a computational model of the abundance of wild pollinators across a landscape. The model itself is complete, and I am now struggling with a post-processing step.
I have my GDAL ...
111
votes
12
answers
198k
views
Installing GDAL with Python on Windows
Can anyone explain how to install GDAL/OGR with Python on Windows?
I have Windows Vista and I have tried following the information on the website and it does not seem to bind the *.exe files for me.
...
44
votes
5
answers
16k
views
Reprojecting raster from 0 360 to -180 180 with cutting 180 meridian using gdalwarp
I have a geotiff raster image that has a coordinate system with longitudes from 0 to 360.
The horizontal center of the image is 180 longitude. See image below:
I want to transform it to EPSG:4326 SRS ...
57
votes
6
answers
86k
views
How to call gdal_translate from Python code?
Is it possible to use some gdal API to call gdal_translate from Python code? I do not mean simply executing the gdal_translate.exe from the file system, but rather call it somehow in code so I do not ...
13
votes
3
answers
18k
views
Installing ECW for QGIS in Ubuntu 12.04?
I have followed various online help guides on how to make ecw for QGIS 1.8 work in Ubuntu 12.04. I had it all working in Ubuntu 10.04 but since migration to 12.04 no such luck.
Is there a guide that ...
26
votes
1
answer
11k
views
File size inflation normal with gdalwarp?
After using gdalwarp to project and align-to-grid (via -tap) a number of rasters I noticed that the output rasters were significantly larger than the original rasters. A fairly thorough web search ...
42
votes
5
answers
71k
views
Writing numpy array to raster file
I'm new to GIS.
I have some code that converts infrared images of Mars into thermal inertia maps, which are then stored as 2D numpy arrays. I've been saving these maps as hdf5 files but I'd really ...
34
votes
6
answers
24k
views
Splitting raster into smaller chunks using GDAL?
I have a raster (USGS DEM actually) and I need to split it up into smaller chunks like the image below shows. That was accomplished in ArcGIS 10.0 using the Split Raster tool. I would like a FOSS ...
30
votes
6
answers
35k
views
Using ogr2ogr to convert GML to shapefile in Python?
I am trying to convert a GML to an ESRI shapefile using ogr2ogr utility in a python script.
I have successfully installed the GDAL/OGR package via osgeo but I am now struggling to find/understand ...
17
votes
1
answer
22k
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 ...
15
votes
4
answers
37k
views
Clipping raster layer with *raster* mask layer in QGIS
Given two input layers
The clip layer - an arbitrary layer (though in my case it's a float 1 band geotiff)
The mask layer - a paletted raster in which every pixel is either NO DATA or a single "...
42
votes
6
answers
66k
views
How to get raster corner coordinates using Python GDAL bindings?
Is there a way to get the corner coordinates (in degrees lat/long) from a raster file using gdal's Python bindings?
A few searches online have convinced me that there is not, so I have developed a ...
37
votes
4
answers
79k
views
Fully load raster into a numpy array?
I have been trying to check my filters on DEM raster for pattern recognition and it is always resulting in missing last rows and columns(like..20).
I have tried with PIL library, image load. Then with ...
18
votes
4
answers
17k
views
How to add support for FileGDB (Esri file gdb API) driver in fiona?
There has been a tons of questions on that but none of them solved my problem.
I have a machine with:
Windows 7 x64
Python 3.4.3 x64
gdal installed: gdalinfo --version --> GDAL 1.11.4, released ...
20
votes
4
answers
31k
views
gdal ImportError in python on Windows
Trying to import gdal for Python 2.7.3 on Windows XP:
>>> import gdal
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python27\lib\site-...
12
votes
5
answers
17k
views
Creating compressed GeoTIFF with QGIS Clipper tool?
I have a geo-tiff created by Pix4D which is about 375 Mb in file size.
I have clipped it to a smaller area using Qgis 2.8(using Raster ‣ Extraction ‣ Clipper), and the output file is about 900 MB in ...
33
votes
5
answers
51k
views
Installing GDAL on Linux Ubuntu Server
apt-get install python-gdal installs version 1.6.0 and this is already installed. I would like to install the 1.9.0 version.
Do I have to de-install 1.6.0 first and then compile manually or is there ...
30
votes
3
answers
42k
views
Clipping raster with vector layer using GDAL
I have installed GDAL using the Osgeo installer. How can I clip a raster layer with a vector layer programmatically? Is there any GDAL API available which can help me with this? I am using Python.
18
votes
2
answers
19k
views
Changing color of raster images based on their data values - gdal [duplicate]
Let's say I have 1 band raster images with Gray Color Interpretation and I want to change their color based on their data values. Data values -1, will be Blue, -0.5 will be Light Blue, 0 will be ...
18
votes
4
answers
30k
views
Saving project with data source path as relative in QGIS?
Is there an option in QGIS to save the project with the data source being a relative path?
I don't see the option here. QGIS Wroclaw1.7.3
13
votes
7
answers
10k
views
Calculating Image boundary / footprint of satellite images using open source tools?
I need to create the polygon outlines of several single layer raster images, not the extent/bounding box, but the area without the nodata values, as shown here: Creating shapefile showing footprints ...
60
votes
3
answers
25k
views
What is Lanczos resampling useful for in a spatial context?
GDAL includes a resampling method beyond the normal mix of nearest neighbor, bilinear, cubic and splines: "Lanczos windowed sinc resampling". I understand that its a convolution filter, but unlike ...
23
votes
1
answer
47k
views
Getting coordinate system name from SpatialReference using GDAL/Python
In Python, using GDAL, I've extracted a raster's projection as a WKT string as follows:
wkt = dataset.GetProjection()
# wkt is 'PROJCS["GDA_1994_Transverse_Mercator",GEOGCS["GDA_1994",DATUM["GDA_1994"...
19
votes
5
answers
29k
views
Using Rasterio or GDAL to stack multiple bands without using subprocess commands
Does anyone have a eloquent way of stacking multiple .tif files into a multiple band stack using Rasterio and/or GDAL?
I am looking for a way to avoid using a subprocess command like gdal_merge.py ...
16
votes
2
answers
25k
views
How to add a color table to a one band tiff using GDAL?
I have 1-band GeoTIFF file. The color interpretation for band is gray. I want a color table in order to transform my Col.tiff to Col.jpeg or Col.png.
I tried putting a color table in this tiff via a ....
13
votes
1
answer
18k
views
GDAL scripts not found in QGIS 3 on OSX
I installed QGIS 3, and tried to execute tools like "sieve" "merge" and "polygonize". All of them gave me the error message:
GDAL command output: /bin/sh: (scriptname).py: command not found
I found ...
12
votes
5
answers
30k
views
Retrieve pixel value with geographic coordinate as input with gdal
I have a list of X,Y coordinates in UTM called coords. I also have a .tif of a digital terrain model (DTM) also referenced in UTM. I would like to use the Python wrapper for gdal to return the pixel ...
6
votes
1
answer
9k
views
Reprojecting MODIS Swath data to WGS84 using GDAL [closed]
Im new to GIS and now working with MODIS04L2 Aerosol Optical Thickness image. I need to reproject the image to other coordinate system such as WGS84 for later work but now Im stuck with it. I have try ...
4
votes
2
answers
7k
views
Convert raster to CSV with lat, lon, and value columns
I'm looking for a process to convert ASCII gridded data (in this case 60min/1 degree gridded ASCII population data (GPW) from SEDAC: https://sedac.ciesin.columbia.edu/data/set/gpw-v4-population-count-...
4
votes
1
answer
4k
views
Can't install support for ECW in QGIS 3.6 / 3.4 on Ubuntu 18.04
I've been trying to install support for ECW so I can load them in latest QGIS 3.6 (also tried in QGIS 3.4.4)
Having tried the following tutorials:
https://wiki.openstreetmap.org/wiki/ECW (gdal 2.2....
3
votes
2
answers
7k
views
GDAL2Tiles: MapTiles from BSB/KAP are Switched
As an example I have a BSB file from NOAA which is a navigational map. The map has a SRS of WGS84 and a Mercator projection.
I initially translate the file from BSB format to GTiff format using the ...
1
vote
1
answer
2k
views
Reverse gdal_rasterize (-i option) does not work
When I use:
gdal_rasterize -b 1 -b 2 -b 3 -burn 255 -burn 255 -burn 255 polygon.shp tiff.tiff
I get a new tiff with a white hole in it with the shape of the polygon shp. However, when I use the ...
101
votes
27
answers
167k
views
Python GDAL package missing header file when installing via pip
I asked this question on Stack Overflow before I realised this site existed. As this site it more appropriate, I'll ask it here too.
I'm trying to install gdal from pip pip install gdal inside a ...
69
votes
8
answers
39k
views
Should GDAL be set to produce GeoTIFF files with compression? Which algorithm should be used?
I have a folder of GIS data that consists mainly of GeoTIFF files. The whole set weighs in at about 1.2 GB. I noticed that if I pack the contents into a tarball, it smashes down to about 82 MB. I ...
18
votes
2
answers
28k
views
Convert .tif with .tfw to a GeoTiff?
I have a tif image file, and a .tfw world file (created from OSM data with Mapertive). How can I (using linux command line) convert that to a GeoTIFF file? (i.e. I want to have one file, not 2). I'm ...
18
votes
8
answers
13k
views
Adding field with filename when merging shapefiles with ogr2ogr
I'm merging some shapefiles and I had some problems doing so inside QGIS, so i'm using ogr2ogr directly.
I'm doing this (in a batch):
ogr2ogr -overwrite %destination% %n1%
ogr2ogr -update -append %...
15
votes
2
answers
26k
views
Extract raster values within shapefile with pygeoprocessing or gdal
I would like to know how to get all the raster values within a polygon using gdal or pygeoprocessing, without reading the entire grid as an array.
pygeoprocessing and gdal can do zonal statistics but ...
13
votes
3
answers
23k
views
Convert huge XYZ CSV to GeoTIFF
I have a huge amount of data in the form of CSV containing UTM coordinates as X and Y and an elevation value as Z information. I need to convert these data into a DEM as GeoTIFF for further analysis. ...
12
votes
5
answers
11k
views
Vertical Datum conversion of a raster with gdal
Is there a tool available in gdal to do vertical datum conversion of a raster DEM? I'm looking for a single command line to execute the vertical datum conversion of a raster like the las2las of Liblas ...
9
votes
1
answer
9k
views
QGis Save Raster as Rendered Image
In QGIS 1.9.0 Master, when you right click on a raster in the Layers Panel and select "Save As", you can select the output mode to be "Raw Data" or "Renedered Image".
When selecting the Rendered ...
9
votes
3
answers
21k
views
Rasterizing shapefiles with GDAL and Python?
I am trying to rasterize a shapefile, and write values from a specific column of the shapefile into the resulting GTiff.
Here is what I've done so far, but that only creates a GTiff of zeros.
from ...
7
votes
3
answers
9k
views
Reclassifying rasters using GDAL and Python?
Using @SS_Rebelious very useful answer, I am trying to reclassify rasters using GDAL and Python.
I have a grayscale raster (with values ranging from 0 to 255) and I want to reclassify it to a binary ...
5
votes
3
answers
8k
views
Extracting data from a raster
I'm currently working on a project where I have to use the Corine Land Cover (CLC) map.
https://land.copernicus.eu/pan-european/corine-land-cover/clc2018
(You can download the map in the .tif format)
...
4
votes
1
answer
3k
views
How to run OGR in ArcGIS Scripts?
When I run my script outside ArcGIS it works because during execution script uses a GDAL and OGR modules from osgeo. When I use script as a tool in ArcGIS it does not work. In PySripter I can import ...
3
votes
1
answer
8k
views
How to conditionnally assign a new value to pixels of a raster image?
Given a topographic GIS raster of one country crop.tif:
Given a know pixel value such as elevation (z) is +73 :
$ gdallocationinfo crop.tif 1 1 -valonly
> 73
Given an elevation threshold n = 50 (...
2
votes
1
answer
940
views
Anti-aliased rasterization of vectors in QGIS?
I have some polygons that I want to rasterize, but in a fairly low-resolution grid (cell size 250x250m). The raster values of the area inside the polygons should normally have the same value (100), ...
33
votes
3
answers
34k
views
Accessing feature classes in file geodatabases using Python and GDAL
I am trying to access a vector dataset in an Esri File Geodatabase using Python and GDAL.
I have successfully compiled GDAL with the file geodatabase API. The FileGDB driver is working correctly since ...
28
votes
6
answers
31k
views
How to efficiently access files with GDAL from an S3 bucket using VSIS3?
So, GDAL has recently added a new feature that allows random reading of S3 bucket files. I am looking to crop GDAL images from multiple tiles of an image without having to download the whole file. I'...
24
votes
5
answers
49k
views
Installing GDAL on MacOSX?
Does anybody know what's the easiest way to install GDAL 2.0 on a MacOSX?
The usual suspects kingchaos binary distribution and homebrew seem to be stuck on GDAL 1.11
I need support for TopoJSON ...
18
votes
2
answers
16k
views
How to get GDAL to create statistics for GTiff in Python
I regularly create my own GeoTIFF rasters with GDAL in Python, e.g.:
from osgeo import gdal
from numpy import random
data = random.uniform(0, 10, (300, 200))
driver = gdal.GetDriverByName('GTiff')
ds ...