[GIS] Opening .mxd files in Python not via ArcPy

mxdpythonsoftware-recommendations

I am an old user of Python, but relatively new to GIS. I have a .mxd file and would like to read it into Python.

Is arcpy the only way to do so?

I tried with pyshp but it does not accept this file extension.

Is there perhaps another package for python3 for working with data in this format?

Best Answer

Mxd files are map documents containing information:

  • references to the data sources;
  • map layer symbology;
  • map document metadata;
  • optionally layout configuration;
  • some GUI layout information.

Since it is a binary file, you would need to use a piece of software that is capable of reading it. If you would like to get access to the file programmatically specifically using Python you have really three options:

  1. Use arcpy site-package that comes with ArcGIS.
  2. Use Python comtypes package that can provide an interface to ArcObjects (the COM objects ArcGIS is built upon). Read more on how you can access ArcObjects using Python in this post. There is a post on reading version of mxd file using comtypes here.
  3. Read binary data and try to parse. There is code that tries this here.
Related Question