其他
ArcGIS中分类标注以及常用的标注Python代码
The following article is from GIS二师兄 Author 西西艾尔
1000
NE
[NAME] + ‘\n’ + [Number] + ‘\n’ + [Direction]
def FindLabel ( [Name] ):
return [Name].split(“,”)[1]
def FindLabel ( [Name] , [Code] ):
return [Name] [:2] + ‘\n’ + [Code]
def FindLabel ( [Name]):
return [Name].replace(“CountyRoads”,”CR”)
def FindLabel ([Name]):
import re
output = re.sub(“[^0-9 ]”, “”, [Name])
return output
def FindLabel([Name],[Code]):
if str([Name]) == “None” and str([Code]) != “None”:
return [Code]
elif str([Name]) != “None” and str([Code]) == “None”:
return [Name]
elif str([Name]) == “None” and str([Code]) == “None”:
return “”
else:
return str([Name]) + ” ” + str([Code])
def FindLabel ( [Name] ):
mxd = arcpy.mapping.MapDocument(“CURRENT”)
lyr = arcpy.mapping.ListLayers (mxd,”Example”)[0]
q='”NAME”=’+”‘”+[NAME]+”‘”
tbl=arcpy.da.TableToNumPyArray(lyr,”Name”,q)
n=len(tbl)
return ‘%s(%s)’ %([Name],str(n))
def FindLabel([Code]):
if [Code] is not None:
value = float([Code])
if 1 < value < 50:
return round(value, 3)
elif 50 <= value < 100:
return round(value, 2)
else:
return round(value, 1)
else:
return None
GIS制图 | 复刻《这里是中国》(附DEM、全国遥感影像练习数据下载)