Select to view content in your preferred language

Is it possible to use the grid index tool from a python script?

265
2
Jump to solution
09-20-2024 02:34 PM
rescobar
Regular Contributor

I have the following code to try to create a grid index. I want to be able to add in a scale field. However, whatever layout I have open, it doesn't seem to be picking up the page units. It ends up creating one huge index page (over 70 miles in height)

 

 

Layer = arcpy.GetParameterAsText(0)
Scale = arcpy.GetParameterAsText(1)
out_location = arcpy.GetParameterAsText(2) 
arcpy.cartography.GridIndexFeatures(out_feature_class=out_location+"//index", in_features=Layer, use_page_unit="USEPAGEUNIT", polygon_width = "9.88", polygon_height= "13.62", scale = Scale, intersect_feature = "INTERSECTFEATURE")

 

Tags (3)
0 Kudos
1 Solution

Accepted Solutions
rescobar
Regular Contributor

I was able to resolve this by just specifying inches (dimensions of my mapframe in the layout) as the unit:

 

 

Layer = arcpy.GetParameterAsText(0)
Scale = arcpy.GetParameterAsText(1)
out_location = arcpy.GetParameterAsText(2) 
arcpy.cartography.GridIndexFeatures(out_feature_class=out_location+"//index.shp", in_features=Layer, use_page_unit="NO_USEPAGEUNIT", polygon_width = "9.88 inches", polygon_height= "13.62 inches", scale = Scale, intersect_feature = "INTERSECTFEATURE")

 

View solution in original post

0 Kudos
2 Replies
DuncanHornby
MVP Notable Contributor

Have you read the usage section of the tool help? That explains how the tool functions under what scenarios.

0 Kudos
rescobar
Regular Contributor

I was able to resolve this by just specifying inches (dimensions of my mapframe in the layout) as the unit:

 

 

Layer = arcpy.GetParameterAsText(0)
Scale = arcpy.GetParameterAsText(1)
out_location = arcpy.GetParameterAsText(2) 
arcpy.cartography.GridIndexFeatures(out_feature_class=out_location+"//index.shp", in_features=Layer, use_page_unit="NO_USEPAGEUNIT", polygon_width = "9.88 inches", polygon_height= "13.62 inches", scale = Scale, intersect_feature = "INTERSECTFEATURE")

 

0 Kudos