For a project I want to open another shapefile by clicking on a specific part of a shapefile. I am using Esri ArcGIS.
As a result I want to click with Hyperlink tool at the blue buffer (that was made along a stream Network, so that the Survey date for this SPECIFIC part get´s loaded in (each river has it´s own Survey Data).
I made use of some Python script parts of this post:
Hyperlink Script to Open Shapefile in ArcMap?
Here is what I got so far:
import os
def OpenLink ( [Hyperlink] ):
dir_fc = r'C:(path of folder for shapefiles)
mxd = arcpy.mapping.MapDocument("CURRENT")
df = arcpy.mapping.ListDataFrames(mxd)[0]
newlayer = arcpy.mapping.Layer([Hyperlink])
arcpy.mapping.AddLayer(df, newlayer)
arcpy.RefreshActiveView()
return
I have a field called "Hyperlink" in the attribute table, where the path of each Survey date shapefile should be saved. In my posted script I have filled the path of an example for the whole Hyperlink field, to see if it´s working (it does for this specific example). Now I have to find a way, that I can fill the specific path in the Hyperlink field for each river and gets loaded in.
Things I need to do I think are:
- Find the path of the map mxd.filePath
- Subfolder with Survey data (each river)
- Path of map + subfolder + [Hyperlink]
- Put in new layer
Roundup: The buffers shapefile Attribute table should include the path of the reffering Survey data for each river. Use the Hyperlink tool to open the specific Survey data
I have attached a photo that shows my project: