1

I have a BMP with known georeference properties. It is in EPSG:3857, and I have an aux.xml file as well as knowing the lat/lon extent of the image. How do I convert this to GeoTIFF properly?

I have tried the following code which seems to convert the image, but gdal2tiles will not work with it because I think I am missing information.

gdal_translate -of Gtiff -a_ullr -151.8860639 56.77489167 -52.91295 14.56403889 -a_srs EPSG:3857 file.bmp out.tif

Am I missing something there? Below is the aux.xml file. I am not sure exactly how I should use it to properly create the geotif. Is there a way for gdal to open the file and add the projection information? I have also included a public link to Google Drive with the .bmp and aux.xml file, in case that might help.

<PAMDataset>
  <SRS dataAxisToSRSAxisMapping="1,2">PROJCS["WGS 84 / Pseudo-Mercator",GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4326"]],PROJECTION["Mercator_1SP"],PARAMETER["central_meridian",0],PARAMETER["scale_factor",1],PARAMETER["false_easting",0],PARAMETER["false_northing",0],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AXIS["Easting",EAST],AXIS["Northing",NORTH],EXTENSION["PROJ4","+proj=merc +a=6378137 +b=6378137 +lat_ts=0 +lon_0=0 +x_0=0 +y_0=0 +k=1 +units=m +nadgrids=@null +wktext +no_defs"],AUTHORITY["EPSG","3857"]]</SRS>
  <GeoTransform> -1.6907879268624876e+07,  1.4321638485317408e+03,  0.0000000000000000e+00,  7.7142468591213180e+06,  0.0000000000000000e+00, -1.4321638485317408e+03</GeoTransform>
  <PAMRasterBand band="1">
    <ColorInterp>Gray</ColorInterp>
  </PAMRasterBand>
</PAMDataset>
2
  • "gdal2tiles will not work with it" what exactly does it do then? Jun 2, 2020 at 18:36
  • this would have worked if u_llr were the extents derived from the (metres) coordinates in the GeoTransform (you need the dimensions of the grid to get the extent from the x/y offset and x/y scale values, x from left, y from top). gdalinfo file.bmp would report these corner coordinates, though, given that there's a .aux.xml
    – mdsumner
    Jun 3, 2020 at 2:34

1 Answer 1

2

Your coordinates in -a_ullr -151.8860639 56.77489167 -52.91295 14.56403889 are not in -a_srs EPSG:3857 because I do not believe that your data presents the Null Island.

If you have the aux.xml file you should not need to do anything special because both the projection and coordinates are stored into the xml file. Keep the aux.xml and the image file in the same directory and use:

gdal_translate -of Gtiff file.bmp out.tif
1
  • Yes, this works! I was looking for a way to integrate the xml file and I had no idea it would be automatic. I didn't see this question before so hopefully it will be helpful to others in the future.
    – David
    Jun 2, 2020 at 19:30

Your Answer

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

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