Last active
July 31, 2019 18:05
-
-
Save bixb0012/11b7156568d488e48a820fa3f97928b3 to your computer and use it in GitHub Desktop.
ArcPy: Create Latitude and Longitude Lines
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!python | |
# Reference: 1) https://pro.arcgis.com/en/pro-app/arcpy/classes/spatialreference.htm | |
# 2) https://pro.arcgis.com/en/pro-app/arcpy/classes/array.htm | |
# 3) https://pro.arcgis.com/en/pro-app/arcpy/classes/point.htm | |
# 4) https://pro.arcgis.com/en/pro-app/arcpy/classes/polyline.htm | |
import arcpy | |
SR = arcpy.SpatialReference(4326) | |
interval = 5 # Interval of latitude and longitude lines, multiple of 1 degree | |
density = 10 # Density of vertices between each degree | |
# Example 1: Creating densified polylines | |
long_lines = [ | |
arcpy.Polyline( | |
arcpy.Array(arcpy.Point(x, -90 + y/float(density)) | |
for y | |
in range(180*density + 1)), | |
SR | |
) | |
for x in range(-180, 180 + interval, interval) | |
] | |
lat_lines = [ | |
arcpy.Polyline( | |
arcpy.Array(arcpy.Point(-180 + x/float(density), y) | |
for x | |
in range(360*density + 1)), | |
SR | |
) | |
for y in range(-90, 90 + interval, interval) | |
] | |
# |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment