0

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?

  • 5
    It's a proprietary binary format. You could read the bytestream, but you'd have to reverse-engineer it to have meaning, and the format mutates with each release. Finally, it doesn't contain much data, just metadata. – Vince Apr 12 '17 at 17:57
3

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.

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.