7

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
3
  • 2
    you just need to set your transparency. depending on your colorspace probably 255
    – Brad Nesom
    Commented Jun 7, 2013 at 15:08
  • Thanks, Brad Nesom, that was it (with 0, not 255). Repost your comment as an answer and I will accept it. Briefly, though, I ran the merge again, this time using gdalwarp, and included arguments -srcnodata 0 -dstnodata 0.
    – dgvid
    Commented Jun 8, 2013 at 16:45
  • is it possible to provide at least two neighboring images? Is the data open? Commented Jun 12, 2013 at 7:05

1 Answer 1

4

Answering my own question: Those black pixels in the images represent a "NoData" value. If I tell the gdal merge code that pixels with a color value of 0 are "NoData," it can correctly stitch the images together. (The "NoData" value isn't necessarily set to 0, it can be any value not otherwise used in the image, but in the case of NAIP ortho images, it was 0.)

The gdal_merge.py program accepts an optional -n argument to set the nodata color value, however I had a problem using that on my system. Apparently, setting the -n option causes the Python code to go through a branch that tries to import a package that I was missing.

Rather than fiddle with the missing package, I chose to merge my four GeoTIFF image files using the gdalwarp tool. I passed the same coordinate system for both source and target, since I just wanted to merge, not warp. I specified the nodata value of 0 by passing the arguments -srcnodata 0 -dstnodata 0.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.