Hot answers tagged

24

I know this question is a few months old, but I'm posting this in case it helps others. I developed this kludge to parse version numbers from MXD documents. It basically reads the first 4000 or so characters of an MXD document and searches for a version number. I tested with MXD versions 9.2, 9.3, 10.0, and 10.1. import re def getMXDVersion(mxdFile): ...


15

The function below is based on Ryan's idea, but is a little more direct. ArcGIS map documents are actually OLE documents, which can be parsed with the oletools module (available on pypi: https://pypi.python.org/pypi/oletools). The function opens the file and reads the version string. Tested with 9.0, 9.3, 10.1 and 10.3, but should work with anything (not ...


15

In addition to @PolyGeo's second suggestion, there is an extension called CarryMap. It does what you exactly want. It exports your MDX into an exe file that can be opened with a double-click; no other software is needed. Furthermore, it exports your map for use in Android or iOS devices as well! However, you should pay to have the extension (commercial ...


13

The way to do this is to create a map package: Map packages (.mpk) make it easy to share complete map documents with others. A map package contains a map document (.mxd) and the data referenced by the layers it contains, packaged into one convenient, portable file. The downside of this will be that with the inclusion of raster data sources, your *....


12

It's not an *.exe but you can either: export your map to a layered PDF so that anyone with the free Adobe Reader can view it use the Publisher extension to publish your map as a PMF so that anyone with the free ArcReader can view it


9

You need to save a copy of the mxd to an earlier version if you have saved the mxd in ArcGIS latest version 10.6. Based on ArcGIS help: Saving a map: New documents cannot be opened in earlier versions of the software; however, you can use the Save A Copy command to make a copy of a map document so you can open and work with it in previous versions of ...


8

I maintain several PLTS Atlas projects with north of 80 layouts per MXD. I have long paths as well as complex labeling and complex layer symbolization. The easiest solution I've found to get the file sizes down and improve performance is to use the "Save a copy" function. I've learned the hard way that the Defrag tool will re-path/disconnect features that ...


8

Short Answer: No, not directly Long Answer You need to understand that these are two different technologies. a ArcMap Document (.mxd) is a file which tells ArcMap which layers to use and how to render them etc. OpenLayers is a JavaScript Library that is used for creating application which consume Web Services. A .mxd file can only be opened in ArcMap, ...


8

What you are after may not be determinable, it requires that the document info was saved/embedded and as you've found that is not often embedded into the document. I cannot find any reference to when this data is saved/skipped. For what it's worth this is another method: import os, sys, arcpy from comtypes.client import GetModule, CreateObject BasePath = ...


8

You achieve this by having multiple data frames Working with additional data frames Then setting a difference reference scale per data frame. While in many maps, you'll only need one data frame, you can add more data frames by clicking Insert > Data Frame on the main menu. You can remove a data frame by right-clicking the data frame name in the table of ...


7

I just gave this a test using ArcGIS for Desktop 10.2 on Windows 7 SP1 and was able to create a PNG and GIF files that had a transparent background that I could verify by inserting them as pictures into Word 2010 as In Front Of Text. I followed the Exporting your map instructions from the ArcGIS 10.1 Online Help, using Rose Quartz as both Background and ...


7

As handy as R is for so many tasks, it is important to remember that 1) R is not a GIS and 2) quality mapping is downright difficult compared to creating maps with QGIS or ArcGIS. The following example borrows heavily from two R-bloggers blogs (blog 1 and blog 2). Here, I simply mapped a polygon shapefile using Google Satellite Imagery as a basemap. ...


6

Check out X-Ray, a nice set of tools for looking at structures (and differences) of MXDs and geodatabases. See links below. The tools were developed by the ESRI Local Government Data model group for working with the large municipal basemap datasets and mxds they work with but have been released for general use, and looks like is very useful add-in when ...


6

You should write an ArcMap Addin Extension. In the extension, listen to DocumentOpened event and from there, show your form. Useful Link To create the extension, use Arcgis visual studio template. Then change SetupEvents method like this: private void SetupEvents() { m_docEvents = ArcMap.Document as IDocumentEvents_Event; ...


6

An .mxd file specifies one particular way of rendering some data. The .mxd file references your data (by file name, by IP address, by URL, etc, depending on the data). But it does not contain the data. In the ArcGIS world, an .mxd file is often simply called "a map". (The acronym "MXD" stands for "map document".) And yes, you can create as many ...


6

The reason why this code is failing is down to you missing () off the save method on your MXD, so you were not saving your changes. This code worked for me import arcpy print "This script turns off the following layers:" mxd = arcpy.mapping.MapDocument(r"C:\Scratch\newcode.mxd") for lyr in arcpy.mapping.ListLayers(mxd): print lyr.name lyr.visible = ...


6

If you are referring to opening multiple mxd's within the same window, this isn't possible. You can open multiple mxds at once thought the windows explorer though. (This is what I would usually do if I needed multiple sessions) Select the mxds you require within the folder (ie Folder, Desktop, My Computer, etc.) Then the Enter Key This should boot up all ...


6

Almost. An mxd is a project file that contains (amongst others) layer definitions. You might say that an mxd is a collection of layer files, but besides that, it has for instance a pagelayout, a map, and other stuff. A layer in an mxd can be exported to a lyr file, and a lyr file can also be imported. However, the mxd does not hold references to lyr files. ...


5

Why not make everything relative to your MXD? This approach only works if what you are doing can have all the data stored in sub-folders relative to your MXD. This works well with small projects. But you don't say where your data is? If they are spread across multiple drive spaces then as suggested by @PolyGeo the map package is probably your only option. ...


5

As far as I know, which may not be very far, you can't do that. An mxd is a separate document from the data it contains. Many CAD programs can use shapefiles, although again you wouldn't get symbology. For text, try converting it to annotation and maybe that will export to CAD. Do this on a copy of your data. I'm more used to bringing CAD into Arc than Arc ...


5

I ran this recently on many maps (not thousands though!): import arcpy import os import glob def fix_data_sources(mapDoc): sde = r'\\arcserver2\SDE_Connections' bad = [] mxd = arcpy.mapping.MapDocument(mapDoc) for lyr in arcpy.mapping.ListLayers(mxd): if lyr.supports('SERVICEPROPERTIES'): if lyr.serviceProperties['Server'...


5

To create a multi-value input of MXD files in a tool dialog and create a Python list from them you can do the following: Write a short script like: import arcpy mxdString = arcpy.GetParameterAsText(0) mxdList = mxdString.split(";") arcpy.AddMessage(mxdList) Add the Script above to a toolbox with its parameter defined as below with MultiValue: ...


5

So this should solve your question. This fundtion will list all the data sources found in any MXD file within a folder and it's subfolders. It'll save the CSV in the folder you specify to begin the search from. Change the name of the CSV on line 22 if you need to. The CSV is written with Path, FileName, FileType import os import csv import arcpy def ...


5

My understanding is that Background Geoprocessing runs as a separate process and, unlike Foreground Geoprocessing, is unaware of your current ArcMap environment. Consequently, I don't think you'll have success with your current approach. AutoSaving maps is not the same as AutoSaving edits but you could look at Incremental "auto save" in ArcMap ...


5

To follow up on my comment, the code you posted does work, but does not automatically open the newly imported map. I checked with members of the arcpy.mp team and at the time of writing there is no function or option on importDocument to automatically open the imported document. In time the functions might be enhanced (I've passed this feedback to the team) ...


5

The problem might be a very simple typo in this case, no big deal at all. The code posted in your question is providing a reference to the callable object with the name mxd.save, it doesn't appear to be actually executing the save method onboard the mxd object. The original code here will pass through silently without error, which is indeed frustrating/...


5

As mentioned in the comments, if you can get all the MXDs in a single location, you can run over each MXD and find each layer stored within. The below code will return a dictionary of layers' datasources used in each MXD of a directory and the MXD name which they're found in. import arcpy import os mxdDir = r'C:\path\to\directory\of\MXDs' mxdDict = {} ...


5

"Recommended" is subjective to your own organization needs and requirements. We can't really answer that question. Instead, if you're asking "can I put an MXD into source control"? Generally, yes you can put anything into source control. The problem with putting an MXD (binary file) into source control is there isn't a way for SC to understand differences. ...


4

The MXD format is proprietary to Esri and only readable by products of the ArcGIS Platform (and ArcObjects). Consequently, I think the most likely way that you will be able to read an MXD without using ArcGIS at some time in the future, is if you submit an ArcGIS Idea for an Open API to the MXD format to be developed, and that idea attracts a compelling ...


4

I don't believe python and arcpy expose that sort of functionality (I could be wrong?). You are asking to drive the map window in the second mxd based upon the first mxd, so an existing and running Application (ArcMap) is responding to events in another ArcMap session. This is heading into the realms of ArcObjects and .Net for that using something called ...


Only top voted, non community-wiki answers of a minimum length are eligible