20 votes

Georeferencing raster using GDAL and Python?

Here is an example that does roughly what you ask for. The main parameters are the geotransform array that gdal uses to describe a raster location (position, pixel scale, and skew) and the epsg code ...
user avatar
  • 2,923
19 votes
Accepted

Using GDAL command line to copy projections

I would recommend to use gdalcopyproj.py, a sample file from the GDAL repository done for this purpose as mentioned directly in the script: Duplicate the geotransform and projection metadata from ...
user avatar
  • 28.9k
17 votes
Accepted

Replicating result of gdalwarp using gdal Python bindings

I get the same results as gdalwarp from gdal.AutoCreateWarpedVRT if I set the error threshold to 0.125 to match the default (-et) in gdalwarp. Alternatively, you could set -et 0.0 in your call to ...
user avatar
  • 53.3k
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, ...
user avatar
  • 176
13 votes
Accepted

Clip raster by shapefile in parts?

Reorganise your shapefile so that one shapefile contains one feature (A,B,C in your case) only Then use a loop like for i in A B C; do gdalwarp -cutline $i.shp ... $i.tif done to create each ...
user avatar
  • 3,613
13 votes
Accepted

gdal_translate or gdalwarp to define projection

if you want to set the projection of a file with gdal tools, you should use gdal_edit.py -a_srs Both gdalwarp and gdal_translate will create a new file.
user avatar
  • 48.7k
12 votes
Accepted

Gdal: clipping a raster with another raster

I don't know if it's possible to clip a raster with an other raster but you could use gdaltindex to build the shapefile with the extent of your raster. http://www.gdal.org/gdaltindex.html
user avatar
  • 1,312
12 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. ...
user avatar
  • 6,119
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 ...
user avatar
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....
user avatar
  • 8,554
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 ...
user avatar
9 votes

Gdal: clipping a raster with another raster

For irregular polygons, and assuming that your geotiff raster file is a binary raster, you could use GDAL_Calc: GDAL_Calc.py -A Mask.tif -B CutBigImageToClip.tif --outfile=SmallerFile.tif --...
user avatar
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 =...
user avatar
8 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 ...
user avatar
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 ...
user avatar
  • 11.9k
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 ...
user avatar
  • 650
8 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, ...
user avatar
  • 650
7 votes
Accepted

Reprojecting a raster image using gdalwarp

you need to specify the type of code that you are using. Here I guess that it is EPSG C:\Program Files (x86)\FWTools2.4.7>gdalwarp -s_srs EPSG:25830 -t_srs EPSG:23030 C:\orto.e cw C:\orto_ed50.ecw
user avatar
  • 48.7k
7 votes
Accepted

jpg to geotiff transformation with gdal_translate and gcps fails

The gdal_translate document page http://www.gdal.org/gdal_translate.html may indeed give an impression that the values for Ground Control Points should be closed between brackets [-gcp pixel line ...
user avatar
  • 53.1k
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=...
user avatar
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 ...
user avatar
  • 75.5k
7 votes

Trying to clip raster in QGIS, "Cutline is not Valid"

(Option 1) You could try the option in gdalwarp to ignore invalid polygons. This is invoked using "--config GDALWARP_IGNORE_BAD_CUTLINE YES": gdalwarp -of GTiff -co "COMPRESS=DEFLATE" -tr 30 30 -...
user avatar
  • 805
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. ...
user avatar
7 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/
user avatar
6 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
user avatar
  • 841
6 votes
Accepted

Reprojecting Natural Earth raster into natearth projection with gdalwarp causing black squares?

I can reproduce the error with another Natural Earth image http://naciscdn.org/naturalearth/10m/raster/NE2_LR_LC.zip and GDAL version 2.0-dev. Write a mail into gdal-dev mailing list. I believe that ...
user avatar
  • 53.1k
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 ...
user avatar
  • 28.9k
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 ...
user avatar
  • 75.2k
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 ...
user avatar
  • 75.2k

Only top scored, non community-wiki answers of a minimum length are eligible