POST
|
I would avoid using mdbs at all costs. You will run into nothing but trouble unless you need them for a very specific purpose. That may or may not be the cause of your current issues but it is a good place to start. I agree completely. Unfortunately my company for uses them far too much for data storage and querying (and haven't upgraded the old data to gdbs) so I have to adapt to it.
... View more
09-10-2013
07:37 AM
|
0
|
0
|
743
|
POST
|
Here is the complete section of code just in case it helps anyone in the future:
#Create field map for spatial joins
arcpy.AddMessage("Mapping fields for future use in iteration")
mapFields = ["ITEM_ID", "PRIME_GEO"]
fieldMappings = arcpy.FieldMappings()
for mapField in mapFields:
fieldMap = arcpy.FieldMap()
fieldMap.addInputField(aoi, mapField)
fieldMappings.addFieldMap(fieldMap)
#Begin iterations for each country
arcpy.AddMessage("Beginning loop")
for country in countries:
cc = str(countries )
#Feed in featureclasses
arcpy.AddMessage("Reading input featureclasses into in-memory layers")
arcpy.MakeFeatureLayer_management(countryGdbLTDS + "/StructurePnt", "buildingLyr", dqBuilding)
#define output location for temp building tables
buildingOutput = scratch + "/" + cc + "_AOI_Building"
#Spatially join buildings
arcpy.AddMessage("Testing for existing building output files. Any found will be deleted")
if arcpy.Exists(buildingOutput):
arcpy.Delete_management(buildingOutput)
arcpy.AddMessage("Deleted")
arcpy.AddMessage("Performing Spatial join on Building points")
arcpy.SpatialJoin_analysis(aoi, "buildingLyr", buildingOutput, "JOIN_ONE_TO_ONE", "KEEP_COMMON", fieldMappings,"INTERSECT", "", "")
else:
arcpy.AddMessage("None Found to delete")
arcpy.AddMessage("Performing Spatial join on Building points")
arcpy.SpatialJoin_analysis(aoi, "buildingLyr", buildingOutput, "JOIN_ONE_TO_ONE", "KEEP_COMMON", fieldMappings, "INTERSECT", "", "")
appendList.append(buildingOutput)
... View more
09-10-2013
07:35 AM
|
0
|
0
|
743
|
POST
|
Your code works for me. Are you sure the two fields exist in your source table? Wow- after reading your post, I closed down ArcMap and my python editor, reopened Arc, ran it and it worked. And even better, it worked as desired! Normally I like to follow up with what fixed the issue, but I don't think I can in this case. Thank you all for taking the time to read the thread.
... View more
09-10-2013
07:30 AM
|
0
|
0
|
743
|
POST
|
If it helps, here is how my fields come mapped out of model builder:
##arcpy.SpatialJoin_analysis(AOI, BUILDING_P_-_StructurePnt, v_CC__AOI_build, "JOIN_ONE_TO_ONE", "KEEP_COMMON", "ITEM_ID \"ITEM_ID\" true true false 150 Text 0 0 ,First,#,C:\\Users\\\\Documents\\Units.mdb\\AOI,ITEM_ID,-1,-1", "INTERSECT", "", "")
... View more
09-10-2013
07:16 AM
|
0
|
0
|
743
|
POST
|
Thanks for the input! I also have never used field mappings before which is why I have a hunch I am making a laughably simple mistake. I have scoured every help file and blog post relating to the subject and still have come up empty. addTable was a good tip, but I am still getting the 999999 error. Back to the drawing board for me!
... View more
09-10-2013
07:08 AM
|
0
|
0
|
743
|
POST
|
Hi all, My script is working except the field mappings. When I remove that parameter from the spatial join, it runs fine (but doesn't include the desired field in the output). When I add the fieldMappings parameter to the spatial join, the script throws the beloved ERROR 999999: Error executing function. Thus, I know the problem isolated to how I am imputing the fieldMappings parameter which also makes me believe it is a basic misunderstanding on my part regarding how to utilize field mappings. Here is a code snippet of the issue:
mapFields = ["ITEM_ID", "PRIME_GEO"]
fieldMappings = arcpy.FieldMappings()
for mapField in mapFields:
fieldMap = arcpy.FieldMap()
fieldMap.addInputField(aoi, mapField)
fieldMappings.addFieldMap(fieldMap)
arcpy.SpatialJoin_analysis(aoi, "buildingLyr", buildingOutput, "JOIN_ONE_TO_ONE", "KEEP_COMMON", fieldMappings, "COMPLETELY_WITHIN", "", "")
PS. Of the two tables involved in the join, I only really need to retain the ITEM_ID (and resulting count) field after the join. If there is a better way to do this than field mapping, please share your idea!
... View more
09-10-2013
06:26 AM
|
0
|
8
|
4180
|
POST
|
Hi all, I have been experiencing this problem repeatedly. I am trying to import some models (both "homemade" and from the 3D warehouse), GIS vector data (building footprints, roads, etc), and GIS raster layers (elevation and imagery). I have tried .tif, .png, and .bmp and also have run the "Export Raster World File" tool on them. Everything is in the correct UTM zone in ArcMap, but it seems there is an issue reading in the coordinates in CityEngine. Has anyone experienced this and have any tips? Thank you
... View more
03-25-2013
07:21 AM
|
0
|
7
|
5515
|
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:24 AM
|