Quantcast
Channel: Question and Answer » gdal-merge
Viewing all 14 articles
Browse latest View live

What is the correct way to merge adjoining raster images?

$
0
0

I am trying to create a raster base layer from NAIP ortho imagery. Unfortunately for me, the area of interest is very near the intersection of four image files. I have tried a few approaches to combining them into a single map layer:

  • Naively grouping them together in a GeoServer Layer group
  • Combining them with GeoServer’s ImageMosaic plugin
  • Merging them with gdal_merge.py

In all cases, the result has the same visual problem of ragged black lines where the images meet. See the example image, below. The black lines appear at the edges of each of the individual files, they are not merely an artifact of merging the images, so in a sense this isn’t a surprising outcome — just annoying.

What is the correct procedure to join these orthoimages into a reasonably seamless layer? Is this even a practical thing to do?

Ugly black seams

A few more details:

  • The imagery came from the USDA Geospatial Data Gateway, National Ag. Imagery Program Mosaic listing
  • The files were in MrSID format, but I’ve also created GeoTIFF copies for the gdal_merge.py approach
  • In addition to the MrSID files, the data set included shape and prj files.
  • The images use projection NAD83 / UTM 16N, so I’ve been using EPSG 26916
  • I’m a programmer, not a GIS expert, so my knowledge of this area is pretty limited

gdal_merge.py with single band raster

$
0
0

I’m trying to mosaic the True Marble world imagery 250M geotiffs using gdal_merge.py though one of them doesn’t have RGB bands like the rest and gdal_merge fails (same number of bands is listed as a requirement in it’s documentation). This is the error I get:

python.exe : ERROR 5: TrueMarble.250m.21600x21600.B4.tif: GDALDataset::GetRasterBand(2) - Illegal band #

This is the tile causing the issue: TrueMarble.250m. 21600x21600.B4

Should I use a different mosaic tool or should I try to coerce the tile into the format gdal_merge requires somehow?

North aspect raster with QGIS Raster Calculator

$
0
0

I have QGis1.8.0-Lisboa and the Raster Terrain Analysis Plugin on Mac/OS. When I want to build a raster layer of an aspect group with the Raster Calculator (e.g.: “aspect@1>=45 AND aspect@1<135″ to do the East raster) that works. I have the good raster with a band 1 representing truly the East. Same concluding result with the 2 other exposures using AND (S & W). But for the North I do “aspect@1>=315 OR aspect@1<45″ the resulting file doesn’t have any band! nothing under band1 in Metadata (all is black for this layer on the screen).
In alternative, I want to merge a raster with “aspect@1>=135″ and a raster with “aspect@1<45″ (Raster/ Miscellaneous/Merge) (GDAL tool) but it give me a layer with a band of only one of the 2 values groups (“aspect@1>=135″ or “aspect@1<45″)!
Sorry for my levels of english and GIS.

How to batch merge rasters using FOSSGIS tools?

$
0
0

I’m working with QGIS 1.8 (gdal 1.9.2) and GRASS 6.4.3…but on Windows 7.

I “just” want to merge my raster.

I’ve got a folder with 50 GTiff raster from Lidar data.

The aim is to merge raster before or after an import into GRASS in order to do some contours…

Before GRASS, I tried gdal_merge with QGIS’s gui, without any option. I had an error message : “permission denied”.

So I tried it in GRASS with r.patch but :
First the gui don’t allows you to select multiple raster at one time…

Then I don’t know how to batch with GRASS functions in Windows…I tried the GRASS command line but can’t locate in the current mapset (didn’t understand how). When I had the windows installer for QGIS, this commandline putted you in the current mapset but it’s not the case with the basic installation of QGIS.

I’m quite locked…Any help ?

What are the differences between the photometric options for GDAL_merge?

$
0
0

I am using GDAL_merge to merge several geotiff tiles into one large tile. One of the creation options I can add is photometric.
There are several options for this.

  • MINISBLACK
  • MINISWHITE
  • RGB
  • CMYK
  • YCBCR
  • CIELAB
  • ICCLAB
  • ITULAB

What are the differences between these different outputs? I understand the MINISBLACK and MINISWHITE options, but the others are less clear.

Thanks in advance.

Mosaic Imagery to Tile Grid

$
0
0

I am hoping to come up with a script that would allow me to mosaic imagery into a polygon tile grid. My hopes is to do this with gdal or QGIS. I am wondering if anyone knows of an existing script, before I start. My first thoughts was to use gdal_merge, but I do not see a variable for using a polygon (shapefile) as the boundary. gdal_merge does have the -ul_lr function, so I know that it will work on subsets of images.

What I am looking to do is the following: From a source of ortho imagery, transfer any and all pixels that intersect with the tile grid, then move on to the next grid. There may be 10 source images (for example) that are large in size (geographic extent and disks space) that would be used to populate the individual grid tiles (ie: 1km X 1km).

Thanks….

How do I merge DEM rasters correctly?

$
0
0

I’ve been struggling with this problem for awhile. Here is a curvature raster to illustrate the problem.

I’m using 10m DEM rasters from the NRCS Data Gateway for a large portion of California. The problem is some strange tiling that appears after merging, but isn’t present in the original data (before merging). The grids create low points, so flow accumulation etc is drawn into them.

I’ve tried mosaic to new raster, create raster catalog and filter in ArcGIS 10.2, merge and build vrt in Qgis2.4 but the problem persists throughout.

Something to note is that there are apparently two sets of grids, one with regular equant shapes, and then one set where tiles overlap (on both edges of the tile). I discovered this with “build raster catalog” which creates a feature displaying the edges of the files in the catalog.

The lines are flat lows, which creates a problem trying to do any sort of slope stability or hydrologic analysis…which is the whole point of this exercise.

Thanks for any help.

merging GeoTiffs with GDAL causes grid-like artifacts

$
0
0

I’m processing ASTER DEM tiles, merging them into larger blocks (to minimize visible tile edges) and importing the contours into a postgis database. Workflow:

gdal_merge.py -of GTiff -o merged.tif tile1.tif tile2.tif
gdal_contour -i 10 -a ele -snodata -9999 merged.tif contours.shp
ogr2ogr -f PostgreSQL -nln srtm4 -append -t_srs 'EPSG:3785' contours.shp

For some reason the resulting “merged” contours have grid-like artifacts:

enter image description here

When I skip the merge step and process the same two GeoTiffs separately, there are no artifacts. I’ve tried merging with gdalbuildvrt and got the same grid effect. Why is this happening? How can I avoid this? Thanks in advance.


GDAL merge; Why add 0.1?

Using gdal_merge to merge a large amount of files (in pairs)

$
0
0

I’m new to python and how it can be applied to gis.
I have a large amount of MODIS files to go through and I’ve already extracted, reprojected and converted to GTiff the bands that I need from each HDF file using convertModisGDAL from pymodis.

Now I need to mosaic pairs of this file list. More specifically, I have this kind of files and I need to merge the h24′s with the h25′s:

MOD11A2.A2000065.h24v04.005.2007176173328_LST_Day_1km.tiff
MOD11A2.A2000065.h25v04.005.2007176173328_LST_Day_1km.tiff

MOD11A2.A2000065.h24v04.005.2007176173328_QC_Day.tiff
MOD11A2.A2000065.h25v04.005.2007176173328_QC_Day.tiff

Do you have any suggestions on how can I accomplish this with gdal_merge?

I was trying to do so something with this but I have not been very successful:

for root, dirs, files in os.walk(inputFolder):

    for hdf24 in fnmatch.filter(files,pattern_24):
        p1 = os.path.realpath(os.path.join(root,hdf24))

        for hdf25 in fnmatch.filter(files,pattern_25):
            p2 = os.path.realpath(os.path.join(root,hdf25))

            sys.argv = ['-o','outputTif12','-of','GTiff','-ot','Float64','-n','0','-a_nodata', '-9999', p1, p2]
            gdal_merge.main()

Thank you

gdal_merge shifts rasters after processing, layer stack is slightly off

$
0
0

I have experienced that gdal shifts rasters. The outputs of gdal_warp are often skewed, have different pixel sizes and so forth. A known error which has also been discussed here.

But now, I had to realize, that gdal_merge also shifts rasters! Well it is only some mm of whole MODIS tiles (pixel size 250m), but I can’t imagine what is the reason for it, all layers have the same extent, the same coordinate system and so forth. Why should gdal_merge shift inputlayers and not simply merge or stack them?

Thanks for any insights, ideas and enlightments on this issue.

[code example:

gdal_merge -separate -of GTiff -o D:/MODIS_TIF_NDVI_RECTCLIP_YEARLY_STACK/2005_PARAMETERS_NDVI_STACK.tif D:/MODIS_TIF_NDVI_RECTCLIP_SEASONAL_PARAMETERS/2005_SOS_s1 .....]

enter image description here

merge tif file with No data

$
0
0

I have to 2 tiff files, both of file have No data values as in Image 1, when I use gdal_merge to mosaic both images to one image, the No data area turns to black, which I don’t want,
How to maintain the No data in the output file. how to do that?

Image 1
Original tif files with No data values Image 2 Merged result which contains black in place of No data

Overwrite the mosaic raster generated using gdal_merge.py?

$
0
0

Is it possible to overwrite the raster generated using gdal_merge.py? When I ran the command:

% gdal_merge.py -init 255 -o out.tif in1.tif in2.tif

it works fine, but if I ran the same command and out.tif was already previously generated, it overwrites out.tif to a uniform raster (i.e., all values equal to 255).

mosaic rasters with gdal_merge.py

$
0
0

I want to mosaic 2 rasters “rasa” and “rasb” using gdal_merge.py . While running the code, it produces an error ” No input files selected”. Can somebody help me to find the error in the code?

    import subprocess
    filea = 'C:/Users/claudio/workspace/test/test1/rasa.tif'
    fileb = 'C:/Users/claudio/workspace/test/test1/rasb.tif'
    output = 'C:/Users/claudio/workspace/test/test1/output.tif'
    subprocess.call(['gdal_merge','-o',output,filea,fileb],shell=True)

when i run the above code, the output i am getting is:
enter image description here

Viewing all 14 articles
Browse latest View live