Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I have data for several rain stations, i have averaged the data and given each county a value. Some counties have null values and I would like to pull the data from the all the bordering counties and use that to create an average for the null data county.

here is what i have so far

#Make Feature layer of counties that have 'NULL' for TCPT MNTM
#Select all counties that touch the boundaries of a single NULL county
#Average TCPT and MNTM values for selected counties
#Store average back in original counties layer

arcpy.MakeFeatureLayer_management(countyData,"badRows","\"MNTM\" = 'NULL'")
arcpy.MakeFeatureLayer_management(countyData,"goodRows","\"MNTM\" >= 0")

# a snippet i pulled from model builder and exported python code snippet

arcpy.SpatialJoin_analysis("Dissolved_Counties",climateData,"Average_Temperature_For_Texas_Counties","JOIN_ONE_TO_ONE","KEEP_ALL","""FIPS "FIPS" true true false 5 Text 0 0 ,First,#,Dissolved_Counties,FIPS,-1,-1;Shape_Length "Shape_Length" false true true 8 Double 0 0 ,First,#,Dissolved_Counties,Shape_Length,-1,-1;Shape_Area "Shape_Area" false true true 8 Double 0 0 ,First,#,Dissolved_Counties,Shape_Area,-1,-1;TPCP "TPCP" true true false 4 Long 0 0 ,Mean,#,Climate_Data_for_Texas,TPCP,-1,-1;MNTM "MNTM" true true false 4 Long 0 0 ,Mean,#,Climate_Data_for_Texas,MNTM,-1,-1""","INTERSECT","#","#")


###

i guess i am stuck here, i had before used the arcpy.GenerateNearTable_analysis to generate the values for the 4 nearest counties (but they werent always bordering and it needs to be bordering counties)

anyway if anyone would give me a little help i would much appreciate it

share|improve this question
add comment

1 Answer 1

A little more detail would help us understand your question. It might be that you want to interpolate a surface from your points and then get per-county averages with zonalstatisticsastable. This would eliminate null values.

Outside of that, your best bet might be:

SelectLayerByLocation_management (in_layer, {overlap_type}, {select_features}, {search_distance}, {selection_type})

There are a lot of selection_types, like "BOUNDARY_TOUCHES" and "SHARE_A_LINE_SEGMENT_WITH", that you might be able to use. Odds are good you'll have to cursor through all your null counties, applying a SelectLayerByLocation_management() based on each feature, and then figuring out a value to replace null with.

Truly automating evaluation of adjacent neighbors is fairly complicated, usually relying on topology. I'm not expert with this but I don't think there are pre-built rules for adjacency. You can check the The sample code below gives you an example of some of the most used topology functions. I wouldn't do this unless this was a big or recurring job. It's fairly expensive to learn and to run, at least in my fumbling hands.

PRMS_Topo = 'PRMS_Topo'
arcpy.CreateTopology_management(db_output_fd, PRMS_Topo, '')
arcpy.AddFeatureClassToTopology_management(PRMS_Topo, 'ICAs', '1', '1')
arcpy.AddRuleToTopology_management(PRMS_Topo, 'Must Not Overlap (Area)', 'ICAs', '', '', '')
arcpy.AddRuleToTopology_management (PRMS_Topo, 'Must Not Have Gaps (Area)', 'ICAs', '', '', '')
arcpy.ValidateTopology_management(PRMS_Topo, 'Full_Extent')

The spatial statistics toolbox could be of use, but would require some filtering to use for only adjacent/touching counties.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.