POST
|
in the following script all processes run fin until it gets to the remove, renmame, and update layers commands, however if the commands are put into a seperate script and run everything goes fine it would be best if it could run as one script, any help would be appreciated: the script where it fails: ## Import standard modules
import sys, os
## Set the necessary product code
import arcinfo
## Import arcpy module and environment module
import arcpy
import arcpy.mapping
from arcpy import env
## Set the output workspace
arcpy.env.workspace = r"G:\AGIS\2011\Special_Projects\Dist_1\Dieldrin_Well_Sampling\DieldrinParcelData.gdb\ParcelData"
## Overwrite pre-existing files
arcpy.env.overwriteOutput = True
## Sets the MXD file
IMXD = arcpy.mapping.MapDocument("CURRENT")
## Sets the Dataframe
DF = arcpy.mapping.ListDataFrames(IMXD, "Layers")[0]
Date = arcpy.GetParameterAsText(0)
NewSampleData = arcpy.GetParameterAsText(1)
PastSample = arcpy.GetParameterAsText(2)
NameStart = NewSampleData.rfind("\\") + 1
AddNewLayer = str(NewSampleData[NameStart:])
arcpy.MakeFeatureLayer_management(NewSampleData, AddNewLayer)
arcpy.SetParameterAsText(3,AddNewLayer)
arcpy.RefreshTOC()
Selection = "\"SAMPLE\" <> '' AND \"SAMPLE\" <> ' ' AND \"SAMPLE\" <> 'C' "
arcpy.SelectLayerByAttribute_management(AddNewLayer, "NEW_SELECTION", Selection)
SelectedSamples = arcpy.MakeFeatureLayer_management(AddNewLayer, "SelectedSamples")
arcpy.SetParameterAsText(4, SelectedSamples)
arcpy.RefreshTOC()
arcpy.SelectLayerByLocation_management("Volusia_Parcels", "INTERSECT", "SelectedSamples")
SelectedParcels = arcpy.MakeFeatureLayer_management("Volusia_Parcels", "SelectedParcels")
arcpy.SetParameterAsText(5, SelectedParcels)
arcpy.RefreshTOC()
OutParcels = r"Parcels_%s"%(Date)
arcpy.SpatialJoin_analysis("SelectedParcels", "SelectedSamples", OutParcels, "JOIN_ONE_TO_ONE", "KEEP_ALL")
NewParcels = arcpy.MakeFeatureLayer_management(OutParcels, "NewParcelLayer")
arcpy.SetParameterAsText(6, NewParcels)
JoinLayer = arcpy.mapping.ListLayers(IMXD, PastSample,DF)[0]
arcpy.AddJoin_management(NewParcels, "ALTKEY", JoinLayer, "ALTKEY", "KEEP_ALL")
ChangeSelection = r"%s.SAMPLE <> %s.SAMPLE"%(OutParcels, PastSample)
arcpy.SelectLayerByAttribute_management(NewParcels, "NEW_SELECTION", ChangeSelection)
arcpy.RemoveJoin_management(NewParcels, PastSample)
OutSample = r"Parcels_Changed_%s"%(Date)
arcpy.CopyFeatures_management(NewParcels, OutSample)
NewChanges = arcpy.MakeFeatureLayer_management(OutSample, "NewParcelChanges")
arcpy.SetParameterAsText(7, NewChanges)
########## These changes do not take effect ######################
arcpy.AddMessage("Removing Layers")
for ILayer in arcpy.mapping.ListLayers(IMXD):
if ILayer.name == "SelectedSamples":
arcpy.mapping.RemoveLayer(DF, ILayer)
if ILayer.name == "SelectedParcels":
arcpy.mapping.RemoveLayer(DF, ILayer)
arcpy.AddMessage("Setting Varibles")
PLayer = r"Parcels_%s"%(Date)
CLayer = r"Parcels_Changed_%s"%(Date)
arcpy.AddMessage("Renaming Layers")
for ILayer in arcpy.mapping.ListLayers(IMXD):
if ILayer.name == "NewParcelLayer":
ILayer.name = PLayer
elif ILayer.name == "NewParcelChanges":
ILayer.name = CLayer
arcpy.RefreshTOC()
IMXD.save()
arcpy.AddMessage("Setting Layer Symbology")
try:
SymbolLayer1 = arcpy.mapping.Layer(r"G:\AGIS\2011\Special_Projects\Dist_1\Dieldrin_Well_Sampling\DieldrinWellSamples.lyr")
NewLayer1 = arcpy.mapping.ListLayers(IMXD, PLayer,DF)[0]
arcpy.mapping.UpdateLayer(DF, NewLayer1, SymbolLayer1)
SymbolLayer2 = arcpy.mapping.Layer(r"G:\AGIS\2011\Special_Projects\Dist_1\Dieldrin_Well_Sampling\Parcels_Changed.lyr")
NewLayer2 = arcpy.mapping.ListLayers(IMXD, CLayer,DF)[0]
arcpy.mapping.UpdateLayer(DF, NewLayer2, SymbolLayer2)
except:
arcpy.GetMessages()
############### All STOP #########################
## Refresh map
arcpy.RefreshTOC()
arcpy.RefreshActiveView
IMXD.save() this script works if run after the previous one: ## Import standard modules
import sys, os
## Set the necessary product code
import arcinfo
## Import arcpy module and environment module
import arcpy
import arcpy.mapping
from arcpy import env
## Set the output workspace
arcpy.env.workspace = r"G:\AGIS\2011\Special_Projects\Dist_1\Dieldrin_Well_Sampling\DieldrinParcelData.gdb\ParcelData"
## Overwrite pre-existing files
arcpy.env.overwriteOutput = True
## Sets the MXD file
IMXD = arcpy.mapping.MapDocument("CURRENT")
## Sets the Dataframe
DF = arcpy.mapping.ListDataFrames(IMXD, "Layers")[0]
Date = arcpy.GetParameterAsText(0)
arcpy.AddMessage("Removing Layers")
for ILayer in arcpy.mapping.ListLayers(IMXD):
if ILayer.name == "SelectedSamples":
arcpy.mapping.RemoveLayer(DF, ILayer)
if ILayer.name == "SelectedParcels":
arcpy.mapping.RemoveLayer(DF, ILayer)
arcpy.AddMessage("Setting Varibles")
PLayer = r"Parcels_%s"%(Date)
CLayer = r"Parcels_Changed_%s"%(Date)
arcpy.AddMessage("Renaming Layers")
for ILayer in arcpy.mapping.ListLayers(IMXD):
if ILayer.name == "NewParcelLayer":
ILayer.name = PLayer
elif ILayer.name == "NewParcelChanges":
ILayer.name = CLayer
arcpy.RefreshTOC()
arcpy.AddMessage("Setting Layer Symbology")
SymbolLayer1 = arcpy.mapping.Layer(r"G:\AGIS\2011\Special_Projects\Dist_1\Dieldrin_Well_Sampling\DieldrinWellSamples.lyr")
NewLayer1 = arcpy.mapping.ListLayers(IMXD, PLayer,DF)[0]
arcpy.mapping.UpdateLayer(DF, NewLayer1, SymbolLayer1)
SymbolLayer2 = arcpy.mapping.Layer(r"G:\AGIS\2011\Special_Projects\Dist_1\Dieldrin_Well_Sampling\Parcels_Changed.lyr")
NewLayer2 = arcpy.mapping.ListLayers(IMXD, CLayer,DF)[0]
arcpy.mapping.UpdateLayer(DF, NewLayer2, SymbolLayer2)
## Refresh map
arcpy.RefreshTOC()
arcpy.RefreshActiveView
IMXD.save()
... View more
09-14-2011
05:24 AM
|
0
|
2
|
924
|
POST
|
1. right click on your model goto properties => environments => fields and make sure "Maintain fully qualified field names is unchecked" do the same for geoprocessing => environments in arccatalog, this should take of that 2. the only way to do this tat i know of is to make a templte feature class with the fields as you want them then in you model copy the template as new feature class and append the new records to it
... View more
08-17-2011
12:28 PM
|
1
|
0
|
556
|
POST
|
thanks i tried using the 08 solution file in vs 2008 also with no success in making the tlb file even after registering it manually at the command line with "C:\Program Files\Common Files\ArcGIS\bin\EsriRegasm" there is no tlb file even though it reported back that it was registered successfully do you know where to set the 'register for COM Interop' option in either 2010 or 2008 express?
... View more
08-16-2011
09:29 AM
|
0
|
0
|
284
|
POST
|
for some reason i can not get the viperpin sample in the DeveloperKit10.0 sample to work in ArcMap 10 i opened the solution file in ms vb basic 2010 express and did a build on ViperPin2010 and registered the .dll from C:\Program Files\ArcGIS\DeveloperKit10.0\Samples\ArcObjectsNet\ViperPin\VBNet\bin\Release when i go to arcmap and try to add a tool from file using the .dll it errors out with the message "can't load library from specified file" i read on an earlier post that the .tlb file must be used for adding the tool and there were instructions for creating the .tlb file using vs 2008 express http://forums.arcgis.com/threads/34290-ViperPIN-sample-quot-Can-t-load-type-library-from-specified-file-quot however the solution file will not open in vs 2008 returning a message that the solution file was made with a newer version of express, does anyone know how to create the .tlb file with ms vb 2010 express?
... View more
08-16-2011
06:42 AM
|
0
|
3
|
439
|
POST
|
Does anyone know of a way to get the bearings of a parcel to be displayed on the map? or a way to access the bearing info? I.e. I'm trying to find the bearing of a property line... there is a tool on the cogo tool bar called COGO Report that does that
... View more
08-10-2011
10:50 AM
|
0
|
0
|
520
|
POST
|
I have researched this one and can't seem to find an easy way to do it: I'm trying to join a feature class of parcel polygons with a table based on one field, which will result in a one (parcels) to many (table) join. Then, for every unique record in the table (which has multiple records for each parcel polygon), I want to duplicate or copy the matching parcel polygon and create a new feature class that contains all the records from the table with the parcel geometry. I have a script that will do it, but it is very slow as it reads through each record in the parcel feature class, matches with records in the table, then copys the geometry from the parcels for each table record and attributes accordingly. I'm just trying to find out if there's an easier/faster way to do this. If the explanation is not clear, try this: Parcel feature class primary key is the ParcelID. Table primary key is the OwnershipID, which identifies all owners of each parcel (so you can have parcel1-owner1, parcel1-owner2, parcel1-owner3, etc.). Table also contains ParcelID, which has the same parcelID for every owner of the property. This is the join field. I want to then copy the parcel geometry so that I have geometry for each owner in a new feature class. The issue is that I have to conduct further analysis on an owner basis, and I need the parcel shape for each owner in order to do this. Again, my script seems to work fine, it just takes a long time to run because it has to cycle through every record. Any suggestions? Tyler we have a model that does something similar to what you want to create our condo unit feature class we take the parcel that is the condo footprint parcel and dissolve them on a field called subnum which is the first 8 digits of our parcel id (PID), and export them out as points and add xy coordinates, then we join the points to the table with the condo units based on the first eight digits of their PID, then the join is exported out as a table with the xy coords, then that table is used to create points using the add xy data tool and finally those points are joined to the dissolved polygons with a one to many spatial join, it's clunky but we get our separate condo units it runs for about ten minutes on 29,300 + records
... View more
06-30-2011
12:12 PM
|
0
|
0
|
1795
|
POST
|
at the bottom of the table there should be a button for "Show Selected Records" if you click that then update your attributes with the field calculator it should only update the selected records
... View more
06-10-2011
07:34 AM
|
0
|
0
|
502
|
POST
|
are you doing this in a model? if so, then use make feature layer tool first with the selection query and calculate the new feature layer
... View more
06-09-2011
04:10 AM
|
0
|
0
|
502
|
POST
|
sorry i misunderstood what you are trying to accomplish, maybe you should post the question in the arcgis sever forum for a better response
... View more
05-13-2011
09:52 AM
|
0
|
0
|
170
|
POST
|
not sure of your question, do you just want the user to select a geodatabase when they fire off the model? if so then use a workspace variable in the model and make it a parameter
... View more
05-11-2011
12:24 PM
|
0
|
0
|
170
|
POST
|
on the add content i am trying to connect to an sde database but i get and error saying it can't connect to the server any help appreciated
... View more
05-10-2011
05:01 AM
|
0
|
4
|
1561
|
POST
|
here is some code that runs in an mxd from the tool box, the user chooses the layer to do a search on, the script tests the layer to see if the field to do the search on exists then tests the layer to see if it is from a file geodatabase or an sde database by checking wether the layer is versioned so that the field will have quotation marks around it in the selection query for a file geodatabase feature class the script works, but is there a better way to test for these things? ## Get the selection layer
SelLayer = arcpy.GetParameterAsText(0)
## Check to see if the selection layer has a FIELD field
try: Afld
except NameError:
pass
else:
del Afld
for flds in arcpy.ListFields(SelLayer, "FIELD"):
Afld = True
try: Afld
except NameError:
arcpy.AddMessage(r"!! There is no FIELD field in %s, please select a layer with an FIELD field !!"%(SelLayer))
quit()
else:
del Afld
## set the ALTKEY field based on the layer type
check = arcpy.Describe(SelLayer)
if check.isVersioned:
FLD = "FIELD"
else:
FLD = '"FIELD"'
... View more
04-28-2011
09:30 AM
|
0
|
1
|
340
|
Title | Kudos | Posted |
---|---|---|
1 | 01-22-2016 10:12 AM | |
1 | 01-14-2016 11:31 AM | |
1 | 08-17-2011 12:28 PM | |
16 | 09-04-2015 08:57 AM | |
1 | 01-18-2011 09:42 AM |
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:23 AM
|