开发者

ArcGIS and ACCESS table

I'm new to Python in combination with ArcGIS. I have a shape file with different regions A,B and C and an Access table :

开发者_运维知识库

feature region

1 A

1 B

2 C

3 A

3 B

Now I'm trying to select one of the features and corresponding regions to give same a different color. Is there a good way doing this with python? Thanks a lot for any idea.

cheers eactor


I think I got it by my own. Here are some important hints:

1)Join the table and shape file with the corresponding row:

arcpy.AddJoin_management("regionsshape","NAME","region_table","NAME")

2)Loop over the table and do selection:

rows = arcpy.SearchCursor("region_table")
  for row in rows:
     arcpy.SelectLayerByAttribute_management("regionsshape","NEW_SELECTION","FEATURE_NAME='" + row.getValue("NAME") + "'")

now you only have to include what you want to do with the selection in my case produce a layer file:

arcpy.MakeFeatureLayer_management("regions",row.getValue("id"))  
  arcpy.SaveToLayerFile_management(row.getValue("id"),"C:/temp/"+row.getValue("id")e+".lyr","ABSOLUTE")
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜