Last active
August 29, 2015 14:00
-
-
Save knu2xs/12a180eaf692fc29018d to your computer and use it in GitHub Desktop.
Scripts from my presentations at Esri's Southeast User Conference
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
| """ | |
| name: cadToArcgis.py | |
| father: Joel Mccune ([email protected]) | |
| birthdate: 01 Apr 2014 (April Fool!) | |
| purpose: Your eternal Pythonistic enlightenment...and something about | |
| CAD to ArcGIS conversion as well. | |
| """ | |
| # import modules | |
| import arcpy | |
| # variables | |
| #out_wksp = r'D:\spatialData\cad\cad_data.gdb' | |
| #input_cad = r'MillerRanch.dwg Polyline' | |
| out_wksp = arcpy.GetParameterAsText(0) | |
| input_cad = arcpy.GetParameterAsText(1) | |
| field = 'Layer' | |
| # use comprehension to create set of unique values found in layer field | |
| values = (row[0] for row in arcpy.da.SearchCursor(out_wksp, field)) | |
| # for every one of the values found in the layer field | |
| for value in values: | |
| # create a sql selection string | |
| sql = """"Layer" = '{0}'""".format(value) | |
| # reformat the output table name so ArcGIS likes it | |
| out_name = arcpy.ValidateTableName(value, out_wksp) | |
| # copy the feature class to the new location | |
| arcpy.FeatureClassToFeatureClass_conversion (in_features=input_cad, | |
| out_path=out_wksp, | |
| out_name=out_name, | |
| where_clause=sql) |
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
| """ | |
| name: Luke | |
| father: Darth | |
| date: May 04, 2014 | |
| purpose: Overcome the dark side. | |
| """ | |
| # import modules | |
| import arcpy | |
| import os.path | |
| # environment settings | |
| arcpy.env.workspace = r'D:\seuc2014\spatial_data\output_gdb.gdb' | |
| arcpy.env.overwriteOutput = True | |
| # setting variables | |
| in_dmz = r'D:\seuc2014\spatial_data\korea.gdb\dmz' | |
| in_dmz = arcpy.GetParameterAsText(0) | |
| in_airfields = r'D:\seuc2014\spatial_data\korea.gdb\Airfields' | |
| out_wksp = r'D:\seuc2014\spatial_data\output_gdb.gdb' | |
| os.path.join(out_wksp, 'target_fc') | |
| # buffering dmz by 25 miles | |
| dmz_25mi = arcpy.Buffer_analysis(in_dmz,"in_memory/dmz_Buffer","25 Miles","FULL","ROUND","NONE").getOutput(0) | |
| # clipping out airfields | |
| airfield_25mi = arcpy.Clip_analysis(in_airfields, dmz_25mi, "in_memory/Airfields_Clip").getOutput(0) | |
| # create output airfilds with heavy lift capability | |
| airfield_25mi_hl = arcpy.Select_analysis(airfield_25mi, 'hot_airfields2',"Length >= 3000").getOutput(0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment