Skip to main content
edited tags; edited title
Link
PolyGeo
  • 65.4k
  • 29
  • 114
  • 345

ArcMap 10.3 - Hyperlink Script to Open Shapefile in ArcMap?

proper code wrap - note the {} button above the text. highlight your plain text entered code and press that to make it easy
Source Link
Chris W
  • 15.8k
  • 2
  • 29
  • 47

I'm new to pythonPython and need some help please...

I have a shapefile (Index.shp) that is used as an index for the world splitting it into 264 areas (polygon). I'm trying to create a pythonPython script (for the ArcMap Hyperlink ScripScript section of this Index.shp) that will add another shapefile to the current ArcMap project based on the polygon the user has clicked on with the hyperlink tool. The Index.shp has an attribute field called File_Name with the shapefile name to be opened.

I was able to get some information online, but I still can't figure out how to get it to work. Any help would be greatly appreciated...

Here's my code to far:

`import arcpy

#get the current map document mxd = arcpy.mapping.MapDocument("CURRENT")

#set the directory to bathy shapefiles fc = "C:\GIS_Data\Bathymetry\Global"

#get the data frame df = arcpy.mapping.ListDataFrames(mxd,"*")[0]

#create a new layer - [File_Name] = bathy shapefile name bathy_file = (fc+ [File_Name] +'.shp')

newlayer = arcpy.mapping.Layer(bathy_file)

#add the layer to the map at the bottom of the TOC in data frame 0 arcpy.mapping.AddLayer(df, newlayer,"AUTO_ARRANGE")`

import arcpy

#get the current map document
mxd = arcpy.mapping.MapDocument("CURRENT")  

#set the directory to bathy shapefiles
fc = "C:\GIS_Data\Bathymetry\Global"  

#get the data frame
df = arcpy.mapping.ListDataFrames(mxd,"*")[0]

#create a new layer - [File_Name] = bathy shapefile name
bathy_file = (fc+ [File_Name] +'.shp')

newlayer = arcpy.mapping.Layer(bathy_file)

#add the layer to the map at the bottom of the TOC in data frame 0
arcpy.mapping.AddLayer(df, newlayer,"AUTO_ARRANGE")

I'm new to python and need some help please...

I have a shapefile (Index.shp) that is used as an index for the world splitting it into 264 areas (polygon). I'm trying to create a python script (for the ArcMap Hyperlink Scrip section of this Index.shp) that will add another shapefile to the current ArcMap project based on the polygon the user has clicked on with the hyperlink tool. The Index.shp has an attribute field called File_Name with the shapefile name to be opened.

I was able to get some information online, but I still can't figure out how to get it to work. Any help would be greatly appreciated...

Here's my code to far:

`import arcpy

#get the current map document mxd = arcpy.mapping.MapDocument("CURRENT")

#set the directory to bathy shapefiles fc = "C:\GIS_Data\Bathymetry\Global"

#get the data frame df = arcpy.mapping.ListDataFrames(mxd,"*")[0]

#create a new layer - [File_Name] = bathy shapefile name bathy_file = (fc+ [File_Name] +'.shp')

newlayer = arcpy.mapping.Layer(bathy_file)

#add the layer to the map at the bottom of the TOC in data frame 0 arcpy.mapping.AddLayer(df, newlayer,"AUTO_ARRANGE")`

I'm new to Python and need some help please.

I have a shapefile (Index.shp) that is used as an index for the world splitting it into 264 areas (polygon). I'm trying to create a Python script (for the ArcMap Hyperlink Script section of this Index.shp) that will add another shapefile to the current ArcMap project based on the polygon the user has clicked on with the hyperlink tool. The Index.shp has an attribute field called File_Name with the shapefile name to be opened.

I was able to get some information online, but I still can't figure out how to get it to work.

Here's my code to far:

import arcpy

#get the current map document
mxd = arcpy.mapping.MapDocument("CURRENT")  

#set the directory to bathy shapefiles
fc = "C:\GIS_Data\Bathymetry\Global"  

#get the data frame
df = arcpy.mapping.ListDataFrames(mxd,"*")[0]

#create a new layer - [File_Name] = bathy shapefile name
bathy_file = (fc+ [File_Name] +'.shp')

newlayer = arcpy.mapping.Layer(bathy_file)

#add the layer to the map at the bottom of the TOC in data frame 0
arcpy.mapping.AddLayer(df, newlayer,"AUTO_ARRANGE")
Source Link

ArcMap 10.3 - Hyperlink Script to Open Shapefile

I'm new to python and need some help please...

I have a shapefile (Index.shp) that is used as an index for the world splitting it into 264 areas (polygon). I'm trying to create a python script (for the ArcMap Hyperlink Scrip section of this Index.shp) that will add another shapefile to the current ArcMap project based on the polygon the user has clicked on with the hyperlink tool. The Index.shp has an attribute field called File_Name with the shapefile name to be opened.

I was able to get some information online, but I still can't figure out how to get it to work. Any help would be greatly appreciated...

Here's my code to far:

`import arcpy

#get the current map document mxd = arcpy.mapping.MapDocument("CURRENT")

#set the directory to bathy shapefiles fc = "C:\GIS_Data\Bathymetry\Global"

#get the data frame df = arcpy.mapping.ListDataFrames(mxd,"*")[0]

#create a new layer - [File_Name] = bathy shapefile name bathy_file = (fc+ [File_Name] +'.shp')

newlayer = arcpy.mapping.Layer(bathy_file)

#add the layer to the map at the bottom of the TOC in data frame 0 arcpy.mapping.AddLayer(df, newlayer,"AUTO_ARRANGE")`