Created
March 14, 2018 16:37
-
-
Save AlexArcPy/50b6481c7096cf0b66b3c2f45e79ab4f to your computer and use it in GitHub Desktop.
ArcPy to WKT and from WKT
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
import arcpy | |
# read California cities features' geometries into a WKT string | |
arcpy.Multipoint( | |
arcpy.Array([ | |
arcpy.Point(*coords) for coords in [ | |
r[0] for r in arcpy.da.SearchCursor('cities', 'SHAPE@XY', | |
"STATE_NAME = 'California'", | |
arcpy.SpatialReference(3857)) | |
] | |
])).WKT | |
# read California state feature's geometry into a WKT string | |
[ | |
r[0] for r in arcpy.da.SearchCursor('states', 'SHAPE@', | |
"STATE_NAME = 'California'", | |
arcpy.SpatialReference(3857)) | |
][0].WKT | |
# loading the Convex Hull polygon from JTS back into ArcMap | |
wkt_string = 'JTS result WKT' | |
chull = arcpy.FromWKT(wkt_string, arcpy.SpatialReference(3857)) | |
arcpy.CopyFeatures_management(chull, 'in_memory/chull') | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment