# Usage: LineToProjectTransaction <Distance> <Feature_Set> <xxbuf_shp>
# Description:
# Add Agency Projects to the master GIS Project database that are best mapped as linear features such as road or utility corridors.
# User enters the project transaction year, project number, and their initials, then digitizes a line on the map. A 100 foot wide buffer polygon is calculated from the digitized line.
# The buffer polygon is appended with attributes to Transaction_poly layer in GIS_MAD sde db.
# ---------------------------------------------------------------------------
# Import arcpy module
import arcpy
# Script arguments
Project_Year = arcpy.GetParameterAsText(0)
if Project_Year == '#' or not Project_Year:
Project_Year = "2013" # provide a default value if unspecified
Project_Number_eg_0025 = arcpy.GetParameterAsText(1)
Your_initials = arcpy.GetParameterAsText(2)
Distance = arcpy.GetParameterAsText(3)
if Distance == '#' or not Distance:
Distance = "50 Feet" # provide a default value if unspecified
Input_Line = arcpy.GetParameterAsText(4)
if Input_Line == '#' or not Input_Line:
Input_Line = "M:\\ApaGis\\Scratch\\scratch.gdb\\xxline2" # provide a default value if unspecified
TransactionPoly2 = arcpy.GetParameterAsText(5)
if TransactionPoly2 == '#' or not TransactionPoly2:
TransactionPoly2 = "Database Connections\\GIS_MAD.sde\\GIS_MAD.DBO.Transaction_Poly" # provide a default value if unspecified
# Local variables:
xxbuffer = "M:\\ApaGis\\Scratch\\scratch.gdb\\xxbuf"
GIS_MAD_DBO_Transaction_Poly = "Database Connections\\GIS_MAD.sde\\GIS_MAD.DBO.Transaction_Poly"
APANUMBER = "'"+'P'+Project_Year+"-"+Project_Number_eg_0025.upper()+"'"
# Check for the existance of in_memory\\BufferedLine output data before running Buffer.
if arcpy.Exists("M:\\ApaGis\\Scratch\\scratch.gdb\\xxbuf"):
arcpy.Delete_management("M:\\ApaGis\\Scratch\\scratch.gdb\\xxbuf")
# Process: Buffer
arcpy.Buffer_analysis(Input_Line, xxbuffer, Distance, "FULL", "FLAT", "NONE", "")
# Process: Calculate Transaction Type
arcpy.CalculateField_management(xxbuffer, "TRANSACTIONTYPE", "'P'", "PYTHON", "")
# Process: Calculate APA Number
arcpy.CalculateField_management(xxbuffer, "APANUMBER", APANUMBER, "PYTHON", "")
# Process: Calculate Data Entry Date
arcpy.CalculateField_management(xxbuffer, "FEATUREDATE", "datetime.datetime.now( )", "PYTHON", "")
# Process: Calculate Feature Source
arcpy.CalculateField_management(xxbuffer, "FEATURESOURCE", "'20'", "PYTHON", "")
# Process: Calculate Staff
arcpy.CalculateField_management(xxbuffer, "STAFF", '"'+Your_initials.upper()+'"', "PYTHON", "")
# Process: Append
arcpy.Append_management(xxbuffer, GIS_MAD_DBO_Transaction_Poly, "No_TEST", "", "")
# Process: Delete
arcpy.Delete_management(Input_Line)
# Process: Delete
arcpy.Delete_management(xxbuffer)
arcpy.RefreshActiveView()