|
POST
|
I am using 10.3.1 and will be moving to 10.4.1 shortly. My goal is to create as many "live" layers as possible by integrating to other SQL databases, and then pushing out services for use in web maps. Example: ParcelID on the feature in the enterprise geodatabase is joined to GISID for tax rolls in the tax database. When GISID's information is updated it permeates through to the web map. I would like to use spatial views, which I know can be written if the data resides in the same database. Is registering the tables from Database 1, Database 2, etc. and then making the spatial views in the enterprise geodatabase the way to go? Any limitations or impacts on the data in the original database? Or is there a better way? Is it not possible? What is the best course of action?
... View more
12-13-2016
02:10 PM
|
0
|
8
|
5598
|
|
POST
|
I was hoping I would not have to, but it looks like that is going to be the answer.
... View more
10-18-2016
08:53 AM
|
0
|
0
|
2451
|
|
POST
|
Well I have done a few things. I have run the geoprocessing tool both in ArcMap and ArcCatalog using the same parameters minus the export. I used NoAddresses in Scratch, and used the same locator, same output with no problems. I then spelled it all out in the python window in ArcMap and ArcCatalog and crash. I do not know if it is a 10.3.1 thing or what. So what I have determined thus far is that it is a script thing, as the geoprocessing tool worked just fine.
... View more
10-18-2016
08:44 AM
|
0
|
2
|
2451
|
|
POST
|
After looking at into this further. The script produces a geocoded result, but crashes before line 48 "print "Reverse Geocode Successful", and does not delete the unneeded scratch export. Is there a better way of doing what I trying to do? Is something corrupted? I am at a loss.
... View more
10-18-2016
08:09 AM
|
0
|
0
|
2451
|
|
POST
|
Hi Bruce, I do not think that will be an option for me. We would like to use our own GeoCoder as to not consume a bunch of credits. I appreciate the suggestion. David.
... View more
10-18-2016
08:05 AM
|
0
|
0
|
2451
|
|
POST
|
I figured it out. Line 41 edit.startEditing(False, True)edit.startEditing(False, True)
# Should Be
edit.startEditing(False, False)
... View more
10-12-2016
07:23 AM
|
1
|
0
|
1489
|
|
POST
|
Hello All, I am switching over from the testing environment to the enterprise geodatabase, using the script template from Allison posted above and incorporated a few other items as well. When I run the script against the enterprise geodatabase I get the following error: "workspace already in transaction mode" in line 47. "for row in fcrows:" I am wondering if the section Cursors and Locking of the following link has something to do with it: Accessing data using cursors—Help | ArcGIS for Desktop and how I would take care of such an issue. SQL 2008 R2 if that matters. Here is my full code: #-------------------------------------------------------------------------------
# Name: module1
# Purpose:
#
# Author: Dbuehler
#
# Created: 07/09/2016 and Last updated 10/12/2016
# Copyright: (c) Dbuehler 2016
# Licence: <your licence>
#-------------------------------------------------------------------------------
import arcpy
#----------------------------------------------------------------------------------------------------
# The First part of this script calculates Concern IDs. It relies on a table to store the next available ID. This does away with the need to rely on ObjectIDs which get exponential in the ArcGIS Editing.
# This segement was written by Allison Muise of ESRI
#----------------------------------------------------------------------------------------------------
# workspace containing fc and table
workspace = r'C:\GISScripts\GRSTasksConnection.sde'
# Feature class needing id values in field Report_ID
fc = r'C:\GISScripts\GRSTasksConnection.sde\COMGIS2.GIS.GeoConcerns' #r'C:\ESRITest\GeoReportingSystem\Testing9116\Testing9716.gdb\GeoReportingManagement\GeoReporting'
# table that manages ID values. 3 fields:
# - RPTTYPE - text field - an index for the type of report getting an id assigned so multiple ids can be managed in one table
# - NEXTVAL - long int - the next value to use in the id sequence
# - INTERVAL - long int - the number of values to jump between id values
tbl = r'C:\GISScripts\GRSTasksConnection.sde\COMGIS2.GIS.GR_IDTable' # "//C:/GISScripts/GRSTasksConnection.sde/COMGIS2.GIS.GR_IDTable"
# value to search for in the RPTTYPE field in the table to find the right sequence
inc_type = 'GeoReporting'
# get next id value and interval from table
with arcpy.da.SearchCursor(tbl, ['NEXTVAL', 'INTERVAL'], where_clause = """RPTTYPE = '{}'""".format(inc_type)) as tblrows:
for row in tblrows:
sequence_value = row[0]
interval_value = row[1]
# Start edit session
edit = arcpy.da.Editor(workspace)
edit.startEditing(False, True)
edit.startOperation()
# find and update all features that need ids
with arcpy.da.UpdateCursor(fc, 'ConcernID', where_clause="""ConcernID is null""") as fcrows:
for row in fcrows:
# Calculate a new id value from a string and the current id value
# row[0] = "C{}".format(sequence_value)
row[0] = "C16{:04d}".format(sequence_value) #alt: pad sequence value with 4 zeros
fcrows.updateRow(row)
# increment the sequence value by the specified interval
sequence_value += interval_value
# update the table values for next time
with arcpy.da.UpdateCursor(tbl, 'NEXTVAL', where_clause="""RPTTYPE = '{}'""".format(inc_type)) as tblrows:
for row in tblrows:
row[0] = sequence_value
tblrows.updateRow(row)
#----------------------------------------------------------------------------------------------------
# This section calculates the information of several fields. The goal is to off load as many calculations from GeoEvent Processor and rely on GeoEvent Processor to really just sent emails
# It relies on dictionarys within a dictionary to accomplish field calculations. Watch out as the 4 and 5 fields are out of schema sequence. Darren Wiens - GIS Analyst out of Prince George, BC aided via an example.
#----------------------------------------------------------------------------------------------------
# Set other variables
pContact = "PrimaryContact"
contactInfo = "PrimaryInformation"
pDept = "PrimaryDepartment"
sql = """{} is NULL AND {} IS NULL AND {} IS NULL""".format(pContact, contactInfo, pDept)
options = [[1, 'Damaged or Missing Street Sign', 'Street Division', '715-486-2081', 'Street Division', 'GRS_StreetPD'], [1, 'Fire Hydrant Issue', 'Marshfield Utilities Water', '715-387-1195', 'Marshfield Utilities Water', 'GRS_Leaks'], [1, 'Icy Intersection or Road', 'Street Division', '715-486-2081', 'Street Division', 'GRS_StreetPD'], [1, 'Pothole', 'Street Division', '715-486-2081', 'Street Division', 'GRS_StreetPD'], [1, 'Public Parking Issue', 'Police Department', '715-384-3113', 'Police Department', 'GRS_Police'], [1, 'Public Vegetation Concern', 'Street Division', '715-486-2081', 'Street Division', 'GRS_Streets'], [1, 'Road Obstruction', 'Street Division', '715-486-2081', 'Street Division', 'GRS_StreetPD'], [1, 'Street Light Issue', 'Marshfield Utilities Electrical', '715-387-1195', 'Marshfield Utilities Electrical', 'GRS_MU_Electric'], [1, 'Street Parking Issue', 'Police Department', '715-384-3113', 'Police Department', 'GRS_Police'], [1, 'Traffic Issue', 'Engineering', '715-486-2034', 'Engineering', 'GRS_TrafficPD'], [1, 'Traffic Signal Issue', 'Engineering', '715-486-2034', 'Engineering', 'GRS_TrafSignPD'], [1, 'Vision Obstruction', 'Engineering', '715-486-2034', 'Engineering', 'GRS_EVegAndObstruct'], [1, 'Water Bubbling From Street', 'Marshfield Utilities Water', '715-387-1195', 'Marshfield Utilities Water', 'GRS_Leaks'], [1, 'Other', 'Street Division', '715-486-2081', 'Street Division', 'GRS_StreetPD'], [2, 'Cracked Sidewalks', 'Engineering', '715-486-2034', 'Engineering', 'GRS_Esidewalk'], [2, 'Curb Ramp Issue', 'Engineering', '715-486-2034', 'Engineering', 'GRS_ECurbRamp'], [2, 'Slope Issue', 'Engineering', '715-486-2034', 'Engineering', 'GRS_Esidewalk'], [2, 'Snow or Ice Covered Sidewalk', 'Street Division', '715-486-2081', 'Street Division', 'GRS_StreetPD'], [2, 'Tree or Brush Clearance Issue', 'Engineering', '715-486-2034', 'ngineering', 'GRS_EVegAndObstruct'], [2, 'Uneven Sidewalk', 'Engineering', '715-486-2034', 'Engineering', 'GRS_Engineering'], [2, 'Other', 'Engineering', '715-486-2034', 'Engineering', 'GRS_Engineering'], [5, 'Garbage or Recycling Pickup', 'Street Division', '715-486-2081', 'Street Division', 'GRS_Streets'], [5, 'Other', 'Street Division', '715-486-2081', 'Street Division', 'GRS_Streets'], [4, 'Commercial Signage Concern', 'Development Services', '715-486-2077', 'Development Services', 'GRS_Zoning'], [4, 'Temporary Signage Concern', 'Development Services', '715-486-2077', 'Development Services', 'GRS_Zoning'], [4, 'Other', 'Development Services', '715-486-2077', 'Development Services', 'GRS_Zoning'], [3, 'Abandoned or Junk Vehicle', 'Police Department', '715-384-3113', 'Police Department', 'GRS_Police'], [3, 'Building Maintenance Issue', 'Development Services', '715-486-2077', 'Development Services', 'GRS_BuildService'], [3, 'Fence Concern', 'Development Services', '715-486-2077', 'Development Services', 'GRS_Ordinance'], [3, 'Fire Code Violation', 'Fire Department', '715-384-3118', 'Fire Department', 'GRS_Fire'], [3, 'Outdoor Burning', 'Fire Department', '715-384-3118', 'Fire Department', 'GRS_Fire'], [3, 'Land Use Concern', 'Development Services', '715-486-2077', 'Development Services', 'GRS_Zoning'], [3, 'Property Maintenance Concern', 'Police Department', '715-384-3113', 'Police Department', 'GRS_Ordinance'], [3, 'Setback or Property Concern', 'Development Services', '715-486-2077', 'Development Services', 'GRS_Ordinance'], [3, 'Weeds or Overgrown Vegetation', 'Street Division', '715-486-2081', 'Street Division', 'GRS_Streets'], [3, 'Other', 'Development Services', '715-486-2077', 'Development Services', 'GRS_Ordinance'], [6, 'Park Concern', 'Parks and Recreation', '715-384-4642', 'Parks and Recreation', 'GRS_Parks'], [6, 'Shelter Concern', 'Parks and Recreation', '715-384-4642', 'Parks and Recreation', 'GRS_Parks'], [6, 'Trail Concern', 'Parks and Recreation', '715-384-4642', 'Parks and Recreation', 'GRS_Parks'], [6, 'Zoo Concern', 'Parks and Recreation', '715-384-4642', 'Parks and Recreation', 'GRS_Parks'], [9, 'Electrical Service Issue', 'Marshfield Utilities Electrical', '715-387-1195', 'Marshfield Utilities Electrical', 'GRS_ElectricPD'], [9, 'Water Issue', 'Marshfield Utilities Water', '715-387-1195', 'Marshfield Utilities Water', 'GRS_Leaks'], [7, 'Dumping into a Ditch', 'Street Division', '715-486-2081', 'Street Division', 'GRS_StreetPD'], [7, 'Dumping into a Sewer', 'Street Division', '715-486-2081', 'Street Division', 'GRS_StreetPD'], [7, 'Dumping into a Stream or Pond', 'Street Division', '715-486-2081', 'Street Division', 'GRS_StreetPD'], [7, 'Other', 'Street Division', '715-486-2081', 'Street Division', 'GRS_StreetPD'], [8, 'Culvert Replacement', 'Engineering', '715-486-2034', 'Engineering', 'GRS_EDrainage'], [8, 'Ditch Flow Issue', 'Engineering', '715-486-2034', 'Engineering', 'GRS_EDrainage'], [8, 'Ponding Water', 'Engineering', '715-486-2034', 'Engineering', 'GRS_EDrainage'], [8, 'Other', 'Engineering', '715-486-2034', 'Engineering', 'GRS_Engineering']]
# What I am trying to do is update the Null PrimaryContact and PrimaryInformation fields based on a General Concern (subtype number) and a specific concern.
#Example would be General Concern = 6 and Specific Concern = Pool Issue then PrimaryContact = Parks and Recreation and PrimaryInformation = 715-555-5555
with arcpy.da.UpdateCursor(fc, ['GeneralConcern', 'SpecificConcern', 'PrimaryContact', 'PrimaryInformation', 'PrimaryDepartment', 'PrimaryEmailGroup'] , where_clause = sql) as cursor:
for row in cursor:
for option in options:
if option[0] == row[0] and option[1] == row[1]:
row[2] = option[2]
row[3] = option[3]
row[4] = option[4]
row[5] = option[5]
if not row[2] and not row[3] and not row[4] and not row[5]: # not 100% sure about this
print 'No Match'
cursor.updateRow(row) # update row in table with values held in row variable
#----------------------------------------------------------------------------------------------------
# This Section Looks for Reassigns and updates the primary dept, and their info. It is based on similar coding as above.
#----------------------------------------------------------------------------------------------------
reassignYes = "ReassignedTo"
reassignemail = "ReassignedEmailSent"
sql = """{} IS NOT NULL OR {} = 1""".format(reassignYes, reassignemail)
reassignOptions = [[51, 'Development Services', 'Development Services', '715-486-2077', 'GRS_Zoning', 1], [52, 'Engineering', 'Engineering', '715-486-2034', 'GRS_ETrafficSignal', 1], [53, 'Fire Department', 'Fire Department', '715-384-3118', 'GRS_Fire', 1], [54, 'Marshfield Utilities Electrical', 'Marshfield Utilities Electrical', '715-387-1195', 'GRS_MU_Electric', 1], [55, 'Marshfield Utilities Water', 'Marshfield Utilities Water', '715-387-1195', 'GRS_MU_Water', 1], [56, 'Parks and Recreation', 'Parks and Recreation', '715-384-4642', 'GRS_Parks', 1], [57, 'Police Department', 'Police Department', '715-384-3113', 'GRS_Police', 1], [58, 'Street Division', 'Street Division','715-486-2081', 'GRS_Streets', 1]]
with arcpy.da.UpdateCursor(fc, ['ReassignedTo', 'PrimaryDepartment', 'PrimaryContact', 'PrimaryInformation',"PrimaryEmailGroup","ReassignedEmailSent"] , where_clause = sql) as reassign:
for row in reassign:
for option in reassignOptions:
if option[0] == row[0]:
row[1] = option[1]
row[2] = option[2]
row[3] = option[3]
row[4] = option[4]
row[5] = option[5]
if not row[2] and not row[3] and not row[4] and not row[5]: # not 100% sure about this
print 'No Match'
reassign.updateRow(row) # update row in table with values held in row variable
# Close edit session
edit.stopOperation()
edit.stopEditing(True)
... View more
10-12-2016
07:04 AM
|
0
|
1
|
1489
|
|
POST
|
My intent is to reverse geocode points, and assign them their nearest address. I have: A master point feature class Which will ultimately need the address populated in a field A "master script" that calculates a bunch of fields on the master point feature class I would like to ultimately add a section that joins the reverse geocoded addresses, calculates the appropriate address field on the master, and removes the join and deletes all the scratch data The master script is pretty quick as to minimize down time, and would like to keep it that way My initial standalone script to reverse geocode took entirely to long to do as it was always reverse coding all the points, and as this points will increase it will eventually take longer. So, I thought lets only select from the master point feature class, export those out, reverse geocode the selection, and then join the master feature class to do the join and field calculation. However, the reverse geocoding keeps crashing. In PyScripter I get an "exceptions.EOFError:[Errno 10054] An existing connection was forcibly closed by the remote host" error. and just running the script cause python to crash. It does the first part correctly, which is exports out the features with missing addresses, but then crashes on the reverse geocoding part. Below is the code I have thus far. What am I doing wrong? Am I missing something? Do I need to clean up some variables? # import modules
import arcpy
# Set workspaces
scratchWorkspace = r'C:\ESRITest\GeoReportingSystem\Testing9116\Scratch.gdb'
selectExport = r'C:\ESRITest\GeoReportingSystem\Testing9116\Testing9716.gdb\GeoReporting'
missingAddresses = "Match_Addr"
sql = """{} is NULL""".format(missingAddresses)
print "Export Only missing Addresses"
raw_input("Press enter to continue ;)")
# Select concerns that have missing addresses and send them to a scratch workspace for geocoding
arcpy.FeatureClassToFeatureClass_conversion(selectExport, scratchWorkspace, "NoAddresses", sql)
print "Export Successful"
print "Are You Ready to Start Reverse Geocoding?"
raw_input("Press enter to continue ;)")
# Start edit session
edit = arcpy.da.Editor(scratchWorkspace)
edit.startEditing(False, True)
edit.startOperation()
#Additional Variables for reverse geocoding
needsAddress = r'C:\ESRITest\GeoReportingSystem\Testing9116\Scratch.gdb\NoAddresses'
address_locator = r'C:/ESRITest/GeoReportingSystem/Testing9116/ActiveOnlyAddresses_CreateAd'
outfc = r'C:\ESRITest\GeoReportingSystem\Testing9116\Scratch.gdb\NearestAddress2'
# Reverse Geocode the missing addresses that were selected from the main concern features
arcpy.ReverseGeocode_geocoding(needsAddress, address_locator, outfc, address_type="ADDRESS", search_distance="100 Meters")
print "Reverse Geocode Successful. Would you like to Exit?"
# Close edit session
edit.stopOperation()
edit.stopEditing(True)
raw_input("Press enter to exit ;)")
... View more
09-12-2016
08:13 AM
|
0
|
8
|
3240
|
|
POST
|
Thanks Darren, After seeing an example, I get it now. I appreciate your help on this. That works.
... View more
09-07-2016
02:26 PM
|
0
|
0
|
1553
|
|
POST
|
Darren, I am not sure how to set it up either. Hopefully, this will help clarify: GeneralConcern will have a integer 1 through 8 SpecificConcern will have a text value PrimaryContact and PrimaryInformation should be null (no sense recalculating what is already calculated) So if all the criteria are met, calculate PrimaryContact with a text value (a Department) and and PrimaryInformation with a text value (Phone Number) else do nothing and end. Example would be: Before: GeneralConcern SpecificConcern PrimaryContact PrimaryInformation 1 Traffic Issue Engineering 715-555-5555 2 Slope Issue <null> <null> 1 Traffic Signal Issue <null> <null> After: GeneralConcern SpecificConcern PrimaryContact PrimaryInformation 1 Traffic Issue Engineering 715-555-5555 2 Slope Issue Engineering 715-555-5555 1 Traffic Signal Issue Engineering 715-555-5555 Here is sample of what present in the GeneralConcern and SpecificConcern fields and what PrimaryContact and PrimaryInformation should be calculated to: GeneralConcern SpecificConcern PrimaryContact PrimaryInformation 1 Traffic Issue Engineering 715-555-5555 1 Traffic Signal Issue Engineering 715-555-5555 1 Vision Obstruction Engineering 715-555-5555 2 Cracked Sidewalks Engineering 715-555-5555 2 Curb Ramp Issue Engineering 715-555-5555 2 Slope Issue Engineering 715-555-5555 2 Tree or Brush Clearance Issue Engineering 715-555-5555 2 Uneven Sidewalk Engineering 715-555-5555 2 Other Engineering 715-555-5555 8 Culvert Replacement Engineering 715-555-5555 8 Ditch Flow Issue Engineering 715-555-5555 8 Ponding Water Engineering 715-555-5555 8 Other Engineering 715-555-5555 5 Fire Code Violation Fire Department 715-555-5555 5 Illegal Burning Fire Department 715-555-5555
... View more
09-07-2016
08:28 AM
|
0
|
2
|
1553
|
|
POST
|
I have GeoEvent Processor, which I know will do this, but I was hoping to off load it to a script as it does not need to get updated all that often in the grander scheme of the project.
... View more
09-06-2016
02:14 PM
|
0
|
0
|
1553
|
|
POST
|
My conundrum is, is it possible to calculate fields based on other fields in a stand-alone python script. An example would be a group of values bases on two fields dictates what gets calculated in two other fields such as GeneralConcern = 1 (subytype) and SpecificConcern = "Pothole" and ContactDept IS NULL and DeptInfo IS NULL, calculate ContactDept = "Street Dept" and calculates DeptInfo = "715-555-5555".? This is what I have come up with so far, but I am having a hard time wrapping my head around it. import arcpy
# Set workspaces
workspace = r'C:\ESRITest\GeoReportingSystem\Testing9116\Testing9116.gdb'
outWorkspace = r'C:\ESRITest\GeoReportingSystem\Testing9116\Scratch.gdb'
# Set feature classes
tbl = r'C:\ESRITest\GeoReportingSystem\Testing9116\Testing9116.gdb\GeoReporting'
# Set other variables
pContact = "PrimaryContact"
contactInfo = "PrimaryInformation"
sql = """{} is NULL AND {} IS NULL""".format(pContact, contactInfo)
specificCon1 = ['Commercial Signage Concern','Temporary Signage Concern', 'Building Maintenance Issue','Fence Concern', 'Land Use Concern', 'Property Maintenance Concern', 'Setback or Property Concern', 'Other'] # Mulitple General Concern Numbers
specificCon2 = ['Athletic Field Issue', 'Fairgrounds Issue', 'Park Maintenance Issue', 'Pool Issue', 'Restroom Issue', 'Shelter Issue', 'Skate Park Issue', 'Trail Maintenance Issue', 'Unsafe or Downed Tree', 'Zoo Issue', 'Other' ]
# Starting an Edit Session - DMB
edit = arcpy.da.Editor(workspace)
edit.startEditing(False, True)
edit.startOperation()
# What I am trying to do is update the Null PrimaryContact and PrimaryInformation fields based on a General Concern (subtype number) and a specific concern.
#Example would be General Concern = 6 and Specific Concern = Pool Issue then PrimaryContact = Parks and Recreation and PrimaryInformation = 715-555-5555
# See specificCon1. That variable will be a mix of several General Concern numbers like
with arcpy.da.UpdateCursor(tbl, ['PrimaryContact', 'PrimaryInformation'] , where_clause = sql) as cursor:
for row in cursor:
if value == specificCon1:
row.setValue("PrimaryContact", "Development Services"
row.setValue("PrimaryInformation", "715-555-5555")
elif value == specificCon2:
row.setValue("PrimaryContact", "Parks and Recreation"
row.setValue("PrimaryInformation", "715-555-5555")
else: == "??????":
# Closing the Edit Session - DMB
edit.stopOperation()
edit.stopEditing(True)
... View more
09-06-2016
02:07 PM
|
0
|
6
|
2177
|
|
POST
|
I got it to work. I had tried your recommendation with no success. After some trial and error and research, I figured it out. I had to use the view instead of the feature class to calculate on, and change the field variables to the use the output of the join. See below: layerName1 = "outfc_view"
layerName2 = "GRE_view"
#calcExpression ="!AldermanicSJ.NAME!"
arcpy.MakeFeatureLayer_management(outfc, "outfc_view")
arcpy.MakeFeatureLayer_management(targetFeatures, "GRE_view")
# arcpy.MakeFeatureLayer_management(targetFeatures, "GRE_view")
arcpy.AddJoin_management("GRE_view", "ConcernID", "outfc_view", "ConcernID")
print [i.name for i in arcpy.ListFields('GRE_view')]
print "Joined Up Sir"
fieldName1 = u'GeoReporting.AldermanicDistrict'
fieldName2 = u'AldermanicSJ.NAME'
calcExpression ="!"+ fieldName2 +"!"
# Replace a layer/table view name with a path to a dataset (which can be a layer file) or create the layer/table view within the script
# The following inputs are layers or table views: "GeoReporting Features"
arcpy.CalculateField_management(layerName2, fieldName1, calcExpression, "PYTHON_9.3")
... View more
09-06-2016
08:08 AM
|
0
|
0
|
609
|
|
POST
|
I should also add that when I did the line: print [i.name for i in arcpy.ListFields('GRE_view')] It showed me: [u'GeoReporting.OBJECTID', u'GeoReporting.ConcernID', u'GeoReporting.GeneralConcern', u'GeoReporting.SpecificConcern', u'GeoReporting.DescriptionOfConcern', u'GeoReporting.ReportingEmail', u'GeoReporting.DateClosed', u'GeoReporting.ConcernStatus', u'GeoReporting.PriorityLevel', u'GeoReporting.PrimaryDepartment', u'GeoReporting.PrimaryContact', u'GeoReporting.PrimaryInformation', u'GeoReporting.DeptLogging', u'GeoReporting.ReportingMethod', u'GeoReporting.FollowUpRequest', u'GeoReporting.FollowUpContactInfo', u'GeoReporting.AldermanicDistrict', u'GeoReporting.ApproriateYN', u'GeoReporting.NUMVOTES', u'GeoReporting.DaysToClose', u'GeoReporting.GlobalID', u'GeoReporting.Match_Addr', u'GeoReporting.Loc_Name', u'GeoReporting.SHAPE', u'GeoReporting.created_user', u'GeoReporting.created_date', u'GeoReporting.last_edited_user', u'GeoReporting.last_edited_date', u'GeoReporting.Address', u'GeoReporting.Visibility', u'GeoReporting.Report_ID', u'AldermanicSJ.OBJECTID', u'AldermanicSJ.Join_Count', u'AldermanicSJ.TARGET_FID', u'AldermanicSJ.ConcernID', u'AldermanicSJ.GeneralConcern', u'AldermanicSJ.NAME'] I have tried various combinations of u'AldermanicSJ.NAME', but get that 000539 error
... View more
09-02-2016
01:04 PM
|
0
|
2
|
609
|
|
POST
|
I am not quite sure what you mean by manual approach, but I have tried running things individually via arcmap, and each step of the script by itself. The only thing that does not "work" is the field calculate. I get a 000539 error Invalid field. Below is updated code. Thoughts? # import modules
import arcpy
# Set workspaces
workspace = r'C:\ESRITest\GeoReportingSystem\Testing9116\Testing9116.gdb'
outWorkspace = r'C:\ESRITest\GeoReportingSystem\Testing9116\Scratch.gdb'
targetFeatures = r'C:\ESRITest\GeoReportingSystem\Testing9116\Testing9116.gdb\GeoReporting'
joinFeatures = r'C:\ESRITest\GeoReportingSystem\Testing9116\Testing9116.gdb\GRSAldermanic'
outfc = r'C:\ESRITest\GeoReportingSystem\Testing9116\Scratch.gdb\AldermanicSJ'
fieldmappings = arcpy.FieldMappings()
fieldmappings.addTable(targetFeatures)
fieldmappings.addTable(joinFeatures)
# Replace a layer/table view name with a path to a dataset (which can be a layer file) or create the layer/table view within the script
# The following inputs are layers or table views: "GeoReporting Features", "GRSAldermanic"
arcpy.SpatialJoin_analysis(target_features=targetFeatures, join_features=joinFeatures, out_feature_class=outfc, join_operation="JOIN_ONE_TO_ONE", join_type="KEEP_COMMON", field_mapping=fieldmappings, match_option="INTERSECT", search_radius="", distance_field_name="")
print "Done with Spatial Join"
# Replace a layer/table view name with a path to a dataset (which can be a layer file) or create the layer/table view within the script
# The following inputs are layers or table views: "AldermanicSJ"
arcpy.DeleteField_management(in_table=outfc, drop_field="SpecificConcern;DescriptionOfConcern;ReportingEmail;DateClosed;ConcernStatus;PriorityLevel;PrimaryDepartment;PrimaryContact;PrimaryInformation;DeptLogging;ReportingMethod;FollowUpRequest;FollowUpContactInfo;AldermanicDistrict;ApproriateYN;NUMVOTES;DaysToClose;Match_Addr;Loc_Name;created_user;created_date;last_edited_user;last_edited_date;Address;Visibility;Report_ID;DISTRICTID")
print "Done with Deleting Fields"
layerName1 = "outfc_view"
layerName2 = "GRE_view"
#calcExpression ="!AldermanicSJ.NAME!"
arcpy.MakeFeatureLayer_management(outfc, "outfc_view")
arcpy.MakeFeatureLayer_management(targetFeatures, "GRE_view")
# arcpy.MakeFeatureLayer_management(targetFeatures, "GRE_view")
arcpy.AddJoin_management("GRE_view", "ConcernID", "outfc_view", "ConcernID")
print [i.name for i in arcpy.ListFields('GRE_view')]
print "Joined Up Sir"
fieldName1 = "AldermanicDistrict"
fieldName2 = 'AldermanicSJ.NAME'
calcExpression ="!"+fieldName2+"!"
# Replace a layer/table view name with a path to a dataset (which can be a layer file) or create the layer/table view within the script
# The following inputs are layers or table views: "GeoReporting Features"
arcpy.CalculateField_management(targetFeatures, fieldName1, calcExpression, "PYTHON")
#print "Field Calculation Done"
arcpy.RemoveJoin_management(layerName2,"AldermanicSJ")
print "Removed Join"
arcpy.Delete_management(r'C:\ESRITest\GeoReportingSystem\Testing9116\Scratch.gdb\AldermanicSJ')
print "Spatial Join feature class deleted"
... View more
09-02-2016
01:02 PM
|
0
|
3
|
609
|
| Title | Kudos | Posted |
|---|---|---|
| 5 | 05-30-2023 02:04 PM | |
| 2 | 04-11-2022 02:07 PM | |
| 1 | 10-03-2022 02:28 PM | |
| 1 | 05-05-2021 12:25 PM | |
| 1 | 09-22-2017 01:45 PM |
| Online Status |
Offline
|
| Date Last Visited |
04-03-2024
11:21 AM
|