15
votes
What's the difference between gdalwarp and gdal_merge for mosaicing
I just happened to come across this question and a potential answer when looking for something else.
gdal_merge.py uses nearest neighbor resampling. If you want control
over the resampling used, ...
13
votes
Accepted
Why does reprojection with gdalwarp change pixel size?
gdalwarp is doing the right thing: preserving total resolution of your image by changing the pixel-size.
WGS 84 / Pseudo-Mercator projection is heavily distorted when moving away from the equator. ...
11
votes
Difference between gdalwarp and projectRaster
Nice and reproducible question. Personally, I'd expect that the reason for the difference is in the implementations of the bilinear reprojection. You can obviously look into source code for the two ...
11
votes
Reprojecting a raster to match another raster using GDAL
http://www.gdal.org/gdalwarp.html says
-t_srs srs_def:
target spatial reference set. The coordinate systems that can be passed are anything supported by the
OGRSpatialReference....
10
votes
Accepted
How to create transparent tif images using GDAL?
Use gdaldem to add color to your tif file.
gdaldem color-relief input.tif style.txt -alpha output.tif
style.txt looks like this, each line having up to five values. First one is the raster's pixel ...
10
votes
Accepted
GDAL Warp to in-memory raster
The best solution for you would be the VSIMEM filesystem which lets you save outputs of gdal utilities into a filesystem stored in memory.
gdal.Warp('/vsimem/reprojected.tif', ds, srcSRS=in_proj, ...
9
votes
Accepted
How do I change the pixel size in GDAL without changing the extent?
Here's a quick script I put together to correct the cell size of a folder of GeoTiff rasters:
import os, sys
from osgeo import gdal
from osgeo import gdalconst
WorkingFolder = sys.argv[1] # first ...
9
votes
Accepted
How to replicate gdalwarp -cutline in Python to cut out tif image based on the extents.kml file
Using the GDAL Python bindings (GDAL >= 2.1), it should be:
from osgeo import gdal
input_raster = "path/to/rgb.tif"
output_raster = "path/to/rgb_output_cut.tif"
input_kml = "path/to/extent.kml"
ds =...
9
votes
Accepted
Averaging overlapping rasters with GDAL
The following approach worked pretty well.
First I build virtual raster.
gdalbuildvrt raster.vrt -srcnodata 0 -input_file_list paths.txt
paths.txt is file with following content:
a.tif
b.tif
Then ...
8
votes
Accepted
gdalwarp can't find libgrass_dgl or libgrass_vector files
I had the same issue. Might be a bug in gdal configuration or something. To fix it, do this:
sudo ln -s /usr/lib/grass72/lib/libgrass_* /usr/lib/
8
votes
Accepted
Artifacts in gdalwarp output (from polar stereographic to azimuthal equidistant)
I would suggest trying to add the -et (error threshold) option with a lower thresholds than the default.
If you try a lower -et threshold the horizontal artifact should disappear
Or try changing ...
8
votes
How to fix positive North-South Pixel size in GeoTIFF with GDAL
I had the same problem. I used gdalwarp to correct the NS resolution of xyz files and converted them to tif (in one step). Here is my solution in bash:
for file in *.xyz;
# adjust NS resolution
...
8
votes
Crop raster in memory with python GDAL bindings
With GDAL 2.2.0+ use the VSIMEM filesystem (http://www.gdal.org/gdal_virtual_file_systems.html). It allows you to treat blocks of memory as a file within the virtual file system. This version uses ...
7
votes
What's the difference between gdalwarp and gdal_merge for mosaicing
gdal_merge.py loads all files into memory before processing them. therefore it is not able to process large files if your memory is small. see here
7
votes
Convert MODIS HDF file in sinusoidal projection into GeoTIFF using Python GDAL
You can either leave the -s_srs empty or use +proj=sinu +R=6371007.181 +nadgrids=@null +wktext
gdalwarp -of GTIFF -s_srs '+proj=sinu +R=6371007.181 +nadgrids=@null +wktext' -r cubic -t_srs '+proj=...
7
votes
Accepted
How to use gdal2tiles on a custom tiff image recieved from providers to generate tiles
I think all you need to do is reproject it using:
gdalwarp -co TILED=YES -co COMPRESS=DEFLATE -t_srs EPSG:3857 image.tif newImage.tif
and then tile it:
gdal2tiles.py newImage.tif
If your file is ...
7
votes
Accepted
How to make Processing algorithms use default parameter values in QGIS 2.14?
It turns out you can actually use default parameter values calling Processing algorithms from PyQGIS using a different syntax. I didn't find it in the docs, but that's what we have GIS.SE for :D.
...
7
votes
Accepted
gdalwarp cutline without using a shapefile
It should be possible by using the -csql parameter http://www.gdal.org/gdalwarp.html and SQLite dialect http://www.gdal.org/ogr_sql_sqlite.html. Gdalwarp does not have an option for selecting the SQL ...
7
votes
Accepted
File size inflation using GDAL
Your existing data is compressed. You're getting an increase in file-size because the default is uncompressed and you aren't specifying a compression option (-co compress=LZW).
However, it's a ...
7
votes
Accepted
How to get Amersfoort 28992 in QGIS?
You hit the already classical problem: do not change the layers's CRS, instead use Menu Raster > Projections > Warp (reproject) (in case of raster layers).
Alternatively, you could have the same ...
6
votes
Gdal: clipping a raster with another raster
The solution in Python directly, without making shape:
import gdal
from gdalconst import GA_ReadOnly
data = gdal.Open('img_mask.tif', GA_ReadOnly)
geoTransform = data.GetGeoTransform()
minx = ...
6
votes
Accepted
Raster interpolation with gdalwarp, and replicating with python API
You have now a better way to do.
Since RFC 59.1 : GDAL/OGR utilities as a library, you can use gdalwarp from Python directly without using any call to the command line utility but using really the ...
6
votes
Accepted
Convert MODIS HDF file in sinusoidal projection into GeoTIFF using Python GDAL
You might get unexpected results because your dataset crosses the 180° meridian. As a consequence, the tile is squeezed around the globe when reprojected to WGS84. To avoid that, you have to cut the ...
6
votes
Accepted
Understanding gdalwarp reprojection
Just display your raster in a GIS software in UTM 32N:
You see that the raster is rotated in the new CRS, and the former Lower Left point is not the most southward point anymore.
Since gdalwarp ...
6
votes
Accepted
Gdalwarp dstnodata problems
Since GDAL 2.1 it's possible to use GDAL/OGR utilities as library functions. So this is an alternative way to accomplish this task:
from osgeo import gdal
input_raster = r"c:\blah\someinputtiff.tif" ...
6
votes
Accepted
how can 2 geotiff rasters be aligned and forced to have same resolution in python using gdal?
Select which image you want to use as reference and check the pixel size of that with gdalinfo. Then warp the second image to have the same pixel size with gdalwarp http://www.gdal.org/gdalwarp.html ...
6
votes
How to edit the GDAL/OGR console call in QGIS 3.0?
This can be done using Python console.
First copy (or write) a GDAL command and edit in a text viewer. For instance:
gdaldem hillshade C:/MyInputFile.tif C:/MyOutputFile.tif -of GTiff -b 1 -z 1.0 -s ...
6
votes
Use gdal to set multiband raster values to no data
The syntax is documented on the manual page https://www.gdal.org/gdalwarp.html as
If more than one value is supplied all values should be quoted to keep
them together as a single operating system ...
6
votes
Clipping GeoTIFF with shapefile?
In QGIS, you can use the iterator of the clip tool to iterate over the polygon shapefile, and it will clip the GeoTiff raster based on each polygon inside the polygon shapefile.
For example, the ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
gdalwarp × 742gdal × 513
coordinate-system × 152
gdal-translate × 144
python × 128
qgis × 108
raster × 98
geotiff-tiff × 81
clip × 38
pyqgis × 20
dem × 19
georeferencing × 17
netcdf × 17
proj × 17
gdal2tiles × 17
modis × 16
resampling × 16
gdalbuildvrt × 16
gdal-merge × 15
rasterio × 13
vrt × 13
shapefile × 12
resolution × 11
r × 8
qgis-3 × 8