AnsweredAssumed Answered

Creating Lines of Graticule in Python

Question asked by shreve48 on Mar 25, 2017
Latest reply on Mar 26, 2017 by bixb0012

I am stuck with what step I need to take to create a loop statement to automate the process of creating lines of graticule in python/arcpy. What the end result is to create a shapefile that draws a polyline every 10 degrees for lines of latitude/longitude. An example would be the first line drawing at (-90,180), (90,180) and second line drawing at (-90,170), (90,170) until it gets to -180. Here's my current status of my code. 

 

# Import ArcPy
import arcpy

# Create empty shapefile
arcpy.CreateFeatureclass_management('C:/Python_Testing/Week5/Week5/Data', 'line1.shp','POLYLINE',spatial_reference=arcpy.SpatialReference(4326))
# Create cursor to insert data
cursor = arcpy.da.InsertCursor('C:/Python_Testing/Week5/Week5/Data/line1.shp', ["SHAPE@"])

# Writing a multipart feature from an array of points from the same cursor


firstPart = arcpy.Array([arcpy.Point(180, -90),
                         arcpy.Point(-180, -90)])
secondPart = arcpy.Array([arcpy.Point(180, -90),
                          arcpy.Point(180, 90)])

array = arcpy.Array([firstPart, secondPart])

polyline = arcpy.Polyline(array)
cursor.insertRow([polyline])

Outcomes