POST
|
I am new to python and need help. Looked for my answer but don't know if I am even using the correct terminology. I have a model in which I iterated through rows and performed a set of processes on each. For example a feature class with 10 features and on each of the 10 features I wanted to create an individual feature class....or... for each row create a raster based on the field (e.g.) ID. I am trying to turn this to python due to a host of reasons. Here is what I have so far, but I cannot get it to work. Any help would be appreciated. # Import arcpy module print "Starting...." import arcpy from arcpy import env # Check out any necessary licenses arcpy.CheckOutExtension("spatial") env.overwriteOutput = True selectingfeatures = "\\\\silver\\clients\\SYN\\Projects\\P696\\8_BaseMine\\Processing\\TEMP\\trans1.shp" Trans1_shp = "\\\\silver\\clients\\SYN\\Projects\\P696\\8_BaseMine\\Processing\\TEMP\\trans1.shp" basecldem = "\\\\silver\\clients\\SYN\\Projects\\P696\\8_BaseMine\\Data\\From_Client\\20141023_DataDumpFromBrent\\ClosureSurface\\basecldem" TEMP = "\\\\silver\\clients\\SYN\\Projects\\P696\\8_BaseMine\\Processing\\TEMP" Zone3_shp = "\\\\silver\\clients\\SYN\\Projects\\P696\\8_BaseMine\\Processing\\TEMP\\Zone2.shp" transarea = "\\\\silver\\clients\\SYN\\Projects\\P696\\8_BaseMine\\Processing\\TEMP\\transarea" RegionGRP = "\\\\silver\\clients\\SYN\\Projects\\P696\\8_BaseMine\\Processing\\TEMP\\regiongrp" ZonalMean = "\\\\silver\\clients\\SYN\\Projects\\P696\\8_BaseMine\\Processing\\TEMP\\zonalmean" ZoneArea = "\\\\silver\\clients\\SYN\\Projects\\P696\\8_BaseMine\\Processing\\TEMP\\zonearea" Transition__n_ = "\\\\silver\\clients\\SYN\\Projects\\P696\\8_BaseMine\\Processing\\TEMP\\transition_%n%" I_trans1 = "I_trans1_FID" selectingLayer = arcpy.MakeFeatureLayer_management(selectingfeatures) rows = arcpy.SearchCursor(selectingLayer) #cursor = arcpy.SearchCursor(fc) #row = cursor.next() #while row: # print(row.getValue(field)) for row in rows: arcpy.FeatureClassToFeatureClass_conversion(row, TEMP, "Zone2.shp", "", "ID \"ID\" true true false 4 Short 0 4 ,First,#,\\\\silver\\clients\\SYNCRUDE\\Projects\\P696\\8_BaseMine\\Processing\\TEMP\\trans1.shp,ID,-1,-1", "") print "Finished PFC 2 FC...." # Process: Polygon to Raster arcpy.PolygonToRaster_conversion(Zone3_shp, "ID", ZoneArea, "CELL_CENTER", "NONE", "1") print "Finished Polygon to Raster...." # Process: Extract by Mask arcpy.gp.ExtractByMask_sa(basecldem, Zone3_shp, transarea) print "Extract by Mask...." # Process: Region Group arcpy.gp.RegionGroup_sa(ZoneArea, RegionGRP, "FOUR", "WITHIN", "ADD_LINK", "") print "Finished Region Group...." # Process: Zonal Statistics arcpy.gp.ZonalStatistics_sa(RegionGRP, "VALUE", transarea, ZonalMean, "MEAN", "DATA") print "Finished Zonal Statistics...." # Process: Raster Calculator arcpy.gp.RasterCalculator_sa("If( \"%basecldem%\" > ( 0.5 + \"%ZonalMean%\" ), 0, 1 )", Transition__n_) print "Finished Raster Calcualtor"
... View more
12-05-2014
01:19 PM
|
0
|
1
|
2558
|
POST
|
Why is it that ARC map can process something 100 times and then on the 101 error out? I need to shut down Arcmap and restart it every so often for it to work properly. When I get some down time I need to learn some of this open source GIS!!! This is frustrating..... just needed to vent!
... View more
12-02-2014
03:49 PM
|
0
|
1
|
4048
|
POST
|
Hi All, I have a model within a model. Each model has an iterator. The sub model has a iterate feature class instance and the main model has an iterate row selection. I need for each feature class a field calculated based on the individual polygon locations within the area of the selected row. I have tries to pass the sub model to a collect values tool and use that as a parameter for the main model but "make feature layer" does not allow that as an input. How do I get each instance of the iterate sub model into the make feature layer command to create my selection? Thanks, David
... View more
11-24-2014
03:02 PM
|
0
|
2
|
4048
|
POST
|
I imagine my answer has something to do with the 'Calculate Value' model only tool. I just don't know what to put in there.
... View more
11-24-2014
08:20 AM
|
0
|
1
|
473
|
POST
|
Hi again all, I have a model with an iterator. I want the name of the end output to be related to the input. The input name has many characters, most of which are of no consequence. The input names are consistent with (e.g.) XXX_NAMEiWANT_XXX. So I was wondering if there is a way to pull RIGHT( LEFT( %NAME%, 13) , 9 ) to the end file name. Where can I put this function to get my %name%? Thanks David
... View more
11-24-2014
08:09 AM
|
0
|
3
|
4469
|
POST
|
Hi All, I have a model that I run more than once sometimes and I use %'s to define the names of outputs when I can. I am running into an issue when the output already exists in the location I am directing it to, the output changes its name to the actual name not the %value% as I have defined. This is brutal as I have iterators and i need each iteration to be unique. I have a delete and re-create folder in there right now, but that is painful. Is there another way? Thanks, David
... View more
11-21-2014
02:30 PM
|
0
|
1
|
3786
|
POST
|
I am in model builder and need to delete the field map automatically after each iteration. Is there a tool that does this? Thanks, David
... View more
11-21-2014
09:14 AM
|
0
|
0
|
1922
|
POST
|
Thanks, but how does this relate to my problem?? Field names themselves are not my issue, it is their presence or absence in the field map of the feature class to feature class tool. How do I delete a field map as a precondition to running FC2FC?
... View more
11-20-2014
02:01 PM
|
0
|
0
|
444
|
POST
|
Each iteration creates a new filename going into the feature class to coverage. This affects an interior ID field for tracking features within the coverage. Is there a tool or something I can attach as a precondition to delete the field map?
... View more
11-20-2014
01:45 PM
|
0
|
1
|
444
|
POST
|
Get field value gets the area that is being clipped's name in order to name the new files created. The step is the feature class to feature class at the end. The field map is populated after the first feature goes into the tool and it won't forget it.
... View more
11-20-2014
01:20 PM
|
0
|
6
|
1510
|
POST
|
The goal is to have the fields of the input file to make it to the output. Fields from the last iteration are staying in so when there are new fields it the field map does not contain them. If the field map was removed, it would populate with the newest inputs fields and forget about the time before. Does that clarify? Thanks
... View more
11-20-2014
12:58 PM
|
0
|
10
|
1510
|
POST
|
Hi All, I have a model that has a feature class to feature class inside of it with an iterate. As the first iterated item goes into the FC2FC it loads the field map with all of its fields. I need to drop all field map fields before each iteration of the FC2FC. Once before the tool starts iterating and then successively after each iteration. I cannot find anywhere how to delete the field map (bring all fields in input to the output). Thanks, David
... View more
11-20-2014
12:12 PM
|
0
|
13
|
5105
|
POST
|
Figured out a process in case anyone was wondering.... 1. Create a copy of the shapefile (must have Unique KEY) 2. Union this copy with the original 3. Remove all records that have the same key; Key1 = Key 2 (there will now be 2 UKEYs) 4. Remove duplicate features by area or length (hopefully unique amongst groups) 5. Erase result from original shape 6. Merge #4 with #5
... View more
09-22-2014
12:08 PM
|
0
|
0
|
310
|
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:23 AM
|