0

every time I open the same lyr file I have to do data/repair data source (link to the shp file).

I tried to save/export that shp file again, and create the new layer file as well, but every time the same thing happens. The Arc does not remember the link between these two.

Moreover, when I define the data source and the shp file appears in Arc, I have to define the symboloy from scratch (via properties/symbology/import dialogue)

Any ideas how to permanently define the link between the shp and layer file in ArcGIS 10.2 for Desktop? (When drag lyr file to automatically link the shp file)

  • 1
    You can't fix it without creating a new layer (lyr) file, as for whatever reason those don't honor relative paths. However, if your shapefile isn't moving, and you repair the link and then create a new lyr file, it should be working. Is the shapefile in a remote location such as an external/usb/network drive? – Chris W Jul 1 '14 at 5:08
  • What do you mean by "every time I open the same shp file I have to do data/repair data source"? If it is using Add To Map, or drag and drop from the Catalog window to add the shapefile into your map then there should be no need to repair the data source because the aforementioned steps create the layer (and know its data source). I think you must mean that you add ("open") an existing layer file. An edit to your question would help clarify this. – PolyGeo Jul 1 '14 at 5:15
  • In the properties of the layer (ArcCatalog) go to the source tab and hit the button set data source then find the shape file and hit OK, now the layer is pointing to real data. I forgot that layers can't have relative path names, it's MXDs' that can have relative paths. – Michael Stimson Jul 1 '14 at 5:25
  • @Michael Miles-Stimson. Yes, I don't want to have an .mxd file, just the shp and layer file, correctly and permanently linked. – Mario Jul 1 '14 at 5:30
  • 1
    @MichaelMiles-Stimson re "layers can't have relative path names, it's MXDs' that can have relative paths" I think that's actually incorrect. When you create the layer you specify whether it's relative. There's no way to see or change this value but it's set internally - bad UX on Esri's part. – Stephen Lead Jul 1 '14 at 6:01
2

As you can see from the comment thread above, layer files and relative paths are a bit complicated.

The problem is that a layer file (*.lyr) can either hold absolute paths or relative paths, but there doesn't seem to be any (easy) way to ascertain which it uses, after the layer file has been created.

To create a layer file with relative paths, there are two options:

  • in ArcMap, choose > File > Map Document Properties > Store Relative Paths, then right-click on the layer and Save As Layer File; or
  • using the Save To Layer File geoprocessing tool, choose relative paths

(Obviously to choose absolute paths do the above with the other option chosen.)

So in your situation it sounds like you might need to recreate your layer file using either absolute paths or relative paths (depending on your workflow):

  • add the broken layer file to ArcMap
  • repair the source
  • re-save a new *.lyr file using the appropriate path option
  • delete the existing broken *.lyr file

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.