I'm a self taught (well still learning) Python/ArcGis programmer. The company I work for does well maps.
How does one use python to create a layer?
I know I can click down to the personal Geodatabase.mdb on ArcMaps and right click and do a 'create layer' but we have a huge number of maps to create and we have a large library of GDB to make into layers on maps. I would hope the script behind that 'create layer' would be visible but it isn't.
I want to make a batch process to do all the work instead of getting on ArcMap 10.4 and doing them one by one. I presume arcpy and one (or several of the functions/methods) are used.
Thanks for any help!
No. I now see I first run the CreateFeatureclass_management and then MakeFeatureLayer. But it is going to be complicated as I have to find out where the spatial_reference template they want me to use!
Sadly they are on vacation.... Thanks anyway.
Congratulations on diving into Python! Yours is a classic example of why folks should learn Python and arcpy.
You may wish to also check out the Save to Layer File GP tool. You could implement it like:
import os, arcpy arcpy.env.workspace = r'C:\gisdata\mdb\roads.mdb' layerFileFolder = r'C:\gisdata\layerFiles' for fc in arcpy.ListFeatureClasses(): arcpy.MakeFeatureLayer_management(fc, 'tempLayer') arcpy.SaveToLayerFile_management('tempLayer', os.path.join(layerFileFolder, arcpy.Describe(fc).baseName + '.lyr'))
Hope this helps! Happy scripting.
Thanks guys, here is where I'm at.
In a created GDB we have four classes already there (in hundreds of these.)
A_003_076 - Geodatabase Feature Class
B_003_076 - Geodatabase Feature Class
C_003_076 - Geodatabase Feature Class
D_003_076 - Geodatabase Feature Class
And in a template GDB they have the same Classes but three more they want to copy.
But these three Feature Classes have some data.
F_mapgrid_number <--want to copy this Geodatabase Feature Class
G_mapgrid_number <--want to copy this Geodatabase Feature Class
H_mapgrid_number <--want to copy this Geodatabase Feature Class
So F, G, and H have to be copied AND renamed so the 'mapgrid_number' = such as '003_076'.
I created them using...
arcpy.CreateFeatureclass_management(out_path, out_name, geometry_type, template, has_m, has_z, spatial_reference)
Which works fine and ArcMap shows it up.
But now I need to copy INTO the new created F, G, and H Geodatabase Feature Class from another GDB that already has a F, G, and H Geodatabase Feature Classes that has data they want to show up on ALL of them.
Now do I create as I did above and then use arcpy.CopyFeatures_management to overlay the new F, G, and H I already have or is there some way to skip the create and just copy it across.