33
It's a well known and longstanding issue that gdalwarp doesn't deal with compression well. The solution is to gdalwarp without compression then gdal_translate with compression.
To avoid two lengthy processes, gdalwarp to VRT first, it's really quick, then gdal_translate with the -co compress=lzw option.
i.e.
$ gdalwarp -tap -tr 30 30 -t_srs "etc..." -of ...
27
I propose two solutions: the first one using QGIS, the second one using Python (GDAL).
Solution using QGIS
In QGIS you may create a VRT mosaic.
Please follow this procedure (see the image below):
Load the raster in the Layers Panel;
Right-click on it and choose Save As...;
Check the Create VRT option;
Choose the folder where your outputs will be saved;
...
25
Using rasterio you could do
import rasterio
file_list = ['file1.tif', 'file2.tif', 'file3.tif']
# Read metadata of first file
with rasterio.open(file_list[0]) as src0:
meta = src0.meta
# Update meta to reflect the number of layers
meta.update(count = len(file_list))
# Read each layer and write it to stack
with rasterio.open('stack.tif', 'w', **meta) ...
21
Files ending with 'w' (tfw, jpw or jgw, bpw and so on) are world files. These files are used to geolocate rasters that otherwise have no means of geolocation. They tell the GIS where the file's origin is in the real world and the size and rotation of the pixels. however, they do not store any information about projection.
You only need a world file if ...
18
If QGIS is runnig in a 1000x1000 pixel sized window on your screen there is no need to read all 32000x32000 pixels for showing the map. GDAL tries to read data from the source image so that no data at all is read outsize the bounding box, and if image has overviews the data come from the resolution level that is best suitable for the map resolution. There is ...
17
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
one raster dataset to another, which can be useful after
performing image manipulations with other software that
ignores or discards georeferencing ...
17
Your script is missing the ds.FlushCache method, that saves to disk what you have in memory at the end of the modifications. See below a corrected version of your example. Notice that I also added two lines to set projection and geotransform as input
import os
import gdal
file = "path+filename"
ds = gdal.Open(file)
band = ds.GetRasterBand(1)
arr = band....
16
So you want a geotiff instead of a tiff with a world file (.tfw). This should be the default in GDAL (http://www.gdal.org/frmt_gtiff.html) so:
gdal_translate -of GTiff input.tif ouput.tif
It will default to geotiff.
16
Building on what @David mentioned you may use open source gdal library using python module to get image extent like this:
import gdal
from gdalconst import GA_ReadOnly
data = gdal.Open('C:/Temp/myimage.tif', GA_ReadOnly)
geoTransform = data.GetGeoTransform()
minx = geoTransform[0]
maxy = geoTransform[3]
maxx = minx + geoTransform[1] * data.RasterXSize
miny ...
16
This should get you going. The raster values are read using rasterio, and pixel centre coordinates are converted to Eastings/Northings using affine, which are then converted to Latitude/Longitude using pyproj. Most arrays have the same shape as the input raster.
import rasterio
import numpy as np
from affine import Affine
from pyproj import Proj, transform
...
16
You can do this using GDAL, it directly supports XYZ format. It doesn't matter if your coordinates are UTM, gdal_translate will output in the same coordinate system.
So to convert to GeoTIFF is as simple as:
gdal_translate test.xyz test.tif
Look at the GeoTIFF doc for output options (such as compression) and the gdal_translate doc for more usage info. In ...
15
By default an RGB image will be written to an RGB color model JPEG image, but this is not actually the most efficient way of writing to JPEG. It is better to convert to the YCbCr color space, and encode that. This is in fact the typical form of standalone JPEGs and what GDAL will produce when writing to a free standing JPEG file. Compressing a 4K x 2.6K ...
15
If using GDAL 2.1+ it's as simple as gdal.BuildVRT then gdal.Translate:
from osgeo import gdal
outvrt = '/vsimem/stacked.vrt' #/vsimem is special in-memory virtual "directory"
outtif = '/tmp/stacked.tif'
tifs = ['a.tif', 'b.tif', 'c.tif', 'd.tif']
#or for all tifs in a dir
#import glob
#tifs = glob.glob('dir/*.tif')
outds = gdal.BuildVRT(outvrt, tifs, ...
14
Short answer: I suspect there is no such standard for TIFF or GeoTIFF overviews. There are multiple implementations, methods and formats to define overviews for GeoTIFFs.
GeoTIFF is based on the TIFF format (PDF specification for Revision 6.0, from 1992). The format has support for multi-page documents or subfiles, similar to a multi-page PDF.
A GeoTIFF ...
13
gdal_translate -of GTiff C:\temp\input\a.img C:\temp\output\a.tif
and the batch option
GDAL_translate: converting ESRI GRID to Geotiff in batch
'-of GTiff' this part is probably not even required as this is the default but will do no harm.
13
I haven't found any specific commandline utility that can report if a tiff is tiled or striped. At least not directly or in a grepable form like TILED=YES.
There should be enough information in gdalinfo to make that decision, however.
I have a landsat scene, each made with gdal_translate:
landsat_tiled.tif : -co TILED=YES
landsat_notiled.tif: -co TILED=...
12
Quantum GIS now supports this feature, the resolution can be set and can include an optional world file containing georeferencing information.
In the print composer check the "World file on" box under Export settings.
12
Have you looked at using FWTools? There is a python script called gdal_merge that is available within FWTools. You can use a list as input. The command with usage would be:
gdal_merge -o c:\temp\output_image.tif -q -v --optfile c:\temp\rasterlist.txt
12
You should be able to do this using the gdal_translate command line tool.
http://www.gdal.org/gdal_translate.html
To convert to Arc/Info ASCII Grid:
gdal_translate -of AAIGrid elevation.tif elevation.asc
To convert to ASCII Gridded XYZ:
gdal_translate -of XYZ elevation.tif elevation.xyz
Binary executables of the GDAL tools are available here: http://...
12
The coordinates of the target extent have to be expressed in the target SRS:
-te xmin ymin xmax ymax:
set georeferenced extents of output file to be created (in target SRS).
Being...
>cs2cs +init=EPSG:4326 +to +init=EPSG:3857
5 43
556597.45 5311971.85 0.00
15 48
1669792.36 6106854.83 0.00
the command should be something like:
...
answered Dec 9 '13 at 17:24
Antonio Falciano
12.5k22 gold badges2626 silver badges6161 bronze badges
12
Create a box as a Spatial object and crop your raster by the box.
e <- as(extent(-16, -7.25, 4, 12.75), 'SpatialPolygons')
crs(e) <- "+proj=longlat +datum=WGS84 +no_defs"
r <- crop(worldpopcount, e)
11
here's a better answer, use gdalbuildvrt with either srcnodata or vrtnodata flag:
gdalbuildvrt -srcnodata "123 231 67" outfile.vrt input.tif
If the next application in line doesn't understand .vrt, translate to a new tif:
gdal_translate outfile.vrt final.tif
answered Mar 11 '14 at 21:27
matt wilkie
26.4k3434 gold badges127127 silver badges261261 bronze badges
11
In a generic sense, use the affine transform parameters, which should be available with any raster file format. With GDAL, this is available with GetGeoTransform(), or PostGIS' ST_GeoReference() function. After finding these six parameters, one only needs to determine which ones they are, then a function can be made to transform in linear space.
E.g., with ...
11
Are there any drawbacks to doing this?
There are softwares that are not going to be able to read BIGTIFF. It is likely that most geospatial/GIS software that consumes raster data can now handle BIGTIFF, but others might not have been updated or make assumptions about maximum sizes. BIGTIFF support did and does require some software implementation.
If you ...
11
Those files are generated in ArcGIS. Are auxiliary files for georeferencing and visualization, aren't part of GTiff as .shx or .dbf are in a shapefile.
.tfw is ESRI World file
.ovr are piramid layers
.xml is schema look and histogram
.cpg is for TIFF interpretation.
.dbf is for raster attribute table (thanks to @radouxju)
You can add .tfw using GDAL ...
11
New raster tables must be added into existing GeoPackage as subdatasets as documented in the GDAL driver manual page http://www.gdal.org/drv_geopackage_raster.html. Have a look at the fifth example
Addition of a new subdataset to an existing GeoPackage, and choose a
non default name for the raster table.
gdal_translate -of GPKG new.tif existing.gpkg -...
10
Or you can use geotifcp (http://www.remotesensing.org/geotiff/geotifcp.html).
To dump the data from a GeoTiff to a world file try listgeo (http://www.remotesensing.org/geotiff/listgeo.html).
Updated links as of 2017-05-21
http://geotiff.maptools.org/geotifcp.html
http://geotiff.maptools.org/listgeo.html
10
If you have a raster DEM already, then there is a tool that I developed in Whitebox Geospatial Analysis Tools called Remove Off-Terrain Objects, contained within the LiDAR toolbox, that works well for creating bare-earth DEMs, particularly in urban and agricultural settings. It works less well where either the terrain is steeply sloped or the forest cover is ...
10
You can easily open ASCII xyz triplicate data in QGIS under "Add Raster Data" with a "ASCII Gridded XYZ (.xyz)" file type. You can also covert it to a different format under the "Raster > Conversion > Translate (Convert format)" menu. Alternately, you can do this under the "Raster > Conversion > Rasterize" menu with a "Comma Separated Value (.csv)" file type....
10
There are two programs using the libgeotiff library that will let you export and import georeferencing info from GeoTIFFs (and other image file formats): listgeo for saving the georeferencing info into a file, and geotifcp for writing the info from that file back to the image file after it's been edited. Downloads for the libgeotiff library can be found here:...
Only top voted, non community-wiki answers of a minimum length are eligible
Related Tags
geotiff-tiff × 1700gdal × 475
qgis × 305
raster × 297
python × 227
arcgis-desktop × 149
geoserver × 121
coordinate-system × 110
gdal-translate × 77
r × 76
gdalwarp × 75
georeferencing × 69
convert × 60
rasterio × 60
export × 58
arcmap × 52
dem × 52
geotools × 48
arcpy × 41
shapefile × 40
tiles × 36
wms × 33
java × 33
netcdf × 30
clip × 29