[GIS] How to create aux.xml file

coordinate systemgeoreferencingmobile-atlas-creatorqgisraster

After starting to use MOBAC to create offline background maps I found the aux.xml files very useful as QGIS automatically sets the CRS so this would be useful for my colleagues with smaller GIS knowledge.

Is it possible to generate such file for particular projection using WKT or .prj file? I am able to get both from spatialreference.org

Sample file from MOBAC for EPSG:3395 is here:

PROJCS["World_Mercator",GEOGCS["GCS_WGS_1984",DATUM["WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Mercator_1SP"],PARAMETER["False_Easting",0.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",0.0],PARAMETER["latitude_of_origin",0.0],UNIT["Meter",1.0]]

I use mostly only few CRS – epsg:4326, 32633, 900913, 3395 – so I could always create a copy of current *.aux.xml and rename it to fit the raster dataset name.

Best Answer

This was a proposed feature for QGIS which seems to have slipped down the priorities of the developers for the time being. However the feature request page outlines the syntax of the aux.xml file so it should be possible to write a simple python script to get all of the required parameters from the raster file and SpatialReference.org and write them to an xml file with the required filename.

XML parsing is a massive pain and generally it is best to use a pre-written parser such as beautifulsoup, however since this will write the same file structure every time it should be possible to manage in pure python.

Related Question