1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
| #!/usr/bin/env python
# -*- coding: utf-8 -*-
import arcpy
import tkMessageBox
# objet SearchCursor()
# voir http://help.arcgis.com/fr/arcgisdesktop/10.0/help/index.html#//000v00000039000000
# on crée un curseur de recherche en lecture seule
# on récupère les enregistrements dans rows
rows = arcpy.SearchCursor(
# DB Table
"hhh.DBO.CerealesHiver",
# where clause
"TypeCereales='{tc}' AND AnneeAgricole='{aa}' AND Trimestre='{tr}'"
.format(tc=c, aa=a1, tr=v4),
# spatial_reference (keep empty)
"",
# select fields
"OBJECTID, CodeCommuneFK, Production, Rendement, Superficie, "
"TypeCereales, AnneeAgricole, Trimestre",
)
# on parcourt les enregistrements trouvés
for row in rows:
if not row.Production:
print "Zéro"
tkMessageBox.showinfo(
"Information",
"Il n'y a pas de production de ce type "
"de culture dans ce trimestre."
)
else:
# nouvelle requête
rows2 = arcpy.SearchCursor(
# DB Tables
"hhh.DBO.Communes, hhh.DBO.CerHiv{}T{}".format(c+a1, v4),
# where clause
"CodeCommune = CodeCommuneFK",
# spatial reference (keep empty)
"",
# select fields
"Shape, CodeCommuneFK, NomCommune, Production, "
"Rendement, Superficie, TypeCereales, AnneeAgricole, "
"Trimestre",
)
# on parcourt les enregistrements trouvés
for row2 in rows2:
# ...etc...
pass
# end for
# end if
# end for |
Partager