0

For the same area, I have 2 sets of images, the first is high resolution but it doesn't cover fully the area and the images have somehow uneven borders just like this picture.

enter image description here

The second one has smaller resolution, but practically covers my entire area of interest.

I want to superimpose the high resolution images on the smaller resolution image set, but without having these big black images appearing on the map, so I will have to make the black transparent. I can batch replace with ImageMagick the black color with transparent, but the problem is cannot make PNG converted from the original JP2 to work on GeoServer, while somehow I had managed to make the GeoServer work for the ECW format converted from the original JP2 files. The original .jp2 files were accompanied by .j2w georeference files. I have to mention that in order to convert the original JP2 files to PNG I use GDAL with a command line gdal_translate -of PNG "C:\Users\userDesktop\file.jp2" "C:\Users\userDesktop\file.png"

I have tried using the png.aux.xml and tried not to, tried to copy from the .prj files from another set that worked and tried not to, all to no avail...

Edit: Finally with the help of gdalinfo to make sure during each step the georeference was not lost and after various tries, the correct steps are the following 1) Jp2 to png conversion using GDAL 2) png to png_transparent conversion using ImageMagick 3) png_transparent to ecw conversion using GDAL again.

7
  • 1
    PNG is not a very good format to use - GeoTiff is going to work much better
    – Ian Turton
    Feb 4 '20 at 16:26
  • I didn't know that GeoTiff can be transparent! The thing is that again I am having difficulty to insert GeoTiff into Geoserver too using the ImageMosaic option... Feb 5 '20 at 11:39
  • can you clarify exactly what your issue is - converting jp2 to geotiff? adding images to image mosaic? or setting the background to transparent?
    – Ian Turton
    Feb 5 '20 at 11:44
  • Ian I can convert .jp2 to .tif (using GEOTIFF) in GDAL as well as .png files that GDAL produces extra a tiny .png.aux.xml file that is like <PAMDataset> <GeoTransform> 3.8800000000000000e+005, 2.0000000000000001e-001, 0.0000000000000000e+000, 4.4958000000000000e+006, 0.0000000000000000e+000,-2.0000000000000001e-001</GeoTransform> <Metadata domain="IMAGE_STRUCTURE"> <MDI key="INTERLEAVE">PIXEL</MDI> </Metadata> </PAMDataset> Feb 5 '20 at 12:53
  • I also do not have any problems setting the backround to transparent. There must be something with georeferencing these kind of files as I had no issues when using the .ecw format Feb 5 '20 at 13:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.