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!
Thanks but the create feature class has linkrot. At least it cannot find it. How did you find it?
Paul
got it. Thanks!
Question.. which comes first. the layer or the feature class?
Thanks.
Serious question or classic joke?
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.
Heya Paul,
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.
Micah
Thanks guys, here is where I'm at.
In a created GDB we have four classes already there (in hundreds of these.)
MAPGRID_003_076.gdb
MapGrid
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.
CountyCode_MapGrid-template.gdb
MapGrid
F_mapgrid_number <--want to copy this Geodatabase Feature Class
A_mapgrid_number
G_mapgrid_number <--want to copy this Geodatabase Feature Class
B_mapgrid_number
H_mapgrid_number <--want to copy this Geodatabase Feature Class
C_mapgrid_number
D_mapgrid_number
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.
Thanks,
Paul