Nous utilisons des cookies pour vous garantir la meilleure expérience sur notre site. Si vous continuez à utiliser ce dernier, nous considèrerons que vous acceptez l'utilisation des cookies. J'ai compris ! ou En savoir plus !.
banniere

Le portail francophone de la géomatique


Toujours pas inscrit ? Mot de passe oublié ?
Nom d'utilisateur    Mot de passe              Toujours pas inscrit ?   Mot de passe oublié ?

Annonce

GEODATA DAYS 2024

#1 Fri 11 July 2008 15:30

calito
Participant actif
Date d'inscription: 2 Jun 2008
Messages: 112

Create a summary table

Bonjour,

Lorsque j'utilise l'outil "Summary statistics" dans ArcToolsBox pour creer ma table, on me donne la possibilité de choisir un "Case Field", puis un champ "Frequency" est créé automatiquement. Mais avec ce code que j'ai vu sur edn.esri, je n'arrive pas à preciser le "Case Field". Ensuite, je'n sais pas comment faire pour que le champ frequency soit créé automatiquement.

Code:

Public Sub CreateSummaryTable(IntCount As Integer)
  
  On Error GoTo EH
  
  Dim pDoc As IMxDocument
  Set pDoc = ThisDocument
  Dim pMap As IMap
  Set pMap = pDoc.FocusMap

  ' Find the layer named US_Counties
  Dim pLayer As ILayer
  Dim pFeatLayer As IFeatureLayer
  Set pLayer = pMap.layer(IntCount) '(intCount)
  Set pFeatLayer = pLayer
  
  ' Get the workspace of the US_Counties layer
  Dim pFeatClass As IFeatureClass
  Dim pTable As ITable
  Dim pDataSet As IDataset
  Dim pWkSpDS As IDataset
  Dim pWkSpName As IName
  Set pFeatClass = pFeatLayer.FeatureClass
  Set pTable = pFeatClass
  Set pDataSet = pTable
  Set pWkSpDS = pDataSet.Workspace
  Set pWkSpName = pWkSpDS.FullName
    
  ' The output is set to SumSample.dbf file in c:\temp
  Dim pWkSpFactory As IWorkspaceFactory
  Dim pWkSp As IWorkspace
  ' Dim pWkSpDS As IDataset
  ' Dim pWkSpName As IWorkspaceName
  Dim pOutDSName As IDatasetName
  Set pWkSpFactory = New ShapefileWorkspaceFactory
  Set pWkSp = pWkSpFactory.OpenFromFile("c:\temp", 0)
  Set pWkSpDS = pWkSp
  Set pWkSpName = pWkSpDS.FullName
  Set pOutDSName = New TableName
  pOutDSName.Name = "SumSample"
  Set pOutDSName.WorkspaceName = pWkSpName
  
  ' Make sure there is a field called state_name in the layer
  'If pTable.FindField("Shape_Area") = -1 Then
  '  MsgBox "There must be a field named state_name in US_Counties"
  '  Exit Sub
  'End If
  ' Perform the summarize. Note the summary fields string (minimum.state_name ...)
  ' below. This is a comma-delimited string that lists the generated summary
  ' fields. Each field must start with a keyword, and be followed by .fieldName,
  ' where fieldName is the name of a field in the original table.
  '
  ' If you specify the Shape field, you must use the keyword 'Dissolve'. This
  ' is not used below since we are creating a non-spatial summary table.
  Dim pGeoProc As IBasicGeoprocessor
  Dim pSumTable As ITable

  Set pGeoProc = New BasicGeoprocessor
  Set pSumTable = pGeoProc.Dissolve(pTable, False, "years", "Sum.Shape_Area", pOutDSName)
    
  ' add the table to map
  Dim pStTab As IStandaloneTable
  Set pStTab = New StandaloneTable
  Set pStTab.table = pSumTable
  Dim pStTabColl As IStandaloneTableCollection
  Set pStTabColl = pMap
  pStTabColl.AddStandaloneTable pStTab

  ' Refresh the TOC
  pDoc.UpdateContents

  Exit Sub
EH:

  MsgBox Err.Number & " " & Err.Description

End Sub

Est-ce que qqn peut m'aider? SVP.

Merci.

Hors ligne

 

#2 Thu 17 July 2008 15:00

calito
Participant actif
Date d'inscription: 2 Jun 2008
Messages: 112

Re: Create a summary table

SVP Aidez moi.
Merci.

Hors ligne

 

#3 Thu 17 July 2008 16:02

freesnowpetrel
Participant assidu
Lieu: Pretoria, Afrique du Sud
Date d'inscription: 1 Mar 2007
Messages: 222

Re: Create a summary table

Bonjour

Peux tu detailler un peu plus ton probleme s'il te plait ?
Je ne comprend pas ce que tu veux faire exactement, et je ne suis peut-etre pas le seul puisque personne ne te repond...
Personnellement je ne comprend pas pourquoi tu veux utiliser ce script  VBA alors que tu sembles avoir ce que tu veux dans la toolbox ??? Est-ce pour creer un outil personnalise ?? Un script pour automatiser une action repetitive ??? Donnes nous plus de details si tu veux de l'aide.

Rodolphe

Hors ligne

 

#4 Thu 17 July 2008 16:42

Tnarbiv
Participant assidu
Lieu: Véretz
Date d'inscription: 5 Sep 2005
Messages: 392

Re: Create a summary table

calito a écrit:

Bonjour,

Lorsque j'utilise l'outil "Summary statistics" dans ArcToolsBox pour creer ma table, on me donne la possibilité de choisir un "Case Field", puis un champ "Frequency" est créé automatiquement. Mais avec ce code que j'ai vu sur edn.esri, je n'arrive pas à preciser le "Case Field". Ensuite, je'n sais pas comment faire pour que le champ frequency soit créé automatiquement.


où se trouve l'outil Summary statistics dans ArcToolbox ?


Ayez le réflexe "Développement Durable": N'imprimez ce message que si nécessaire.

Hors ligne

 

#5 Thu 17 July 2008 17:09

freesnowpetrel
Participant assidu
Lieu: Pretoria, Afrique du Sud
Date d'inscription: 1 Mar 2007
Messages: 222

Re: Create a summary table

où se trouve l'outil Summary statistics dans ArcToolbox ?


C'est dans Arctoolbox>analysis tools>statistics>Summary statistics

Hors ligne

 

#6 Thu 17 July 2008 17:24

Tnarbiv
Participant assidu
Lieu: Véretz
Date d'inscription: 5 Sep 2005
Messages: 392

Re: Create a summary table

C'est dans Arctoolbox>analysis tools>statistics>Summary statistics


ok

le champ case field correspond au champ sur lequel tu souhaites t'appuyer pour lancer la récapitulation.
le champ frequency créé automatiquement par arctoolbox est également généré par ton bout de code mais il commence par Cnt_, c'est normalement le 3è champ de ta table

dans ton code le case field correspond au troisième paramètre de cette ligne

Set pSumTable = pGeoProc.Dissolve(pTable, False, "years", "Sum.Shape_Area", pOutDSName)


soit dans ton cas le champ years

autre chose aussi : cet outil n'existe pas que dans ArcToolbox, il existe existe aussi lorsque tu as une table ouverte et que tu fais un clic droit sur le nom d'un champ. Dans le menu contextuel tu as l'outil Récapituler ou bien Summarize


Ayez le réflexe "Développement Durable": N'imprimez ce message que si nécessaire.

Hors ligne

 

#7 Thu 17 July 2008 17:48

calito
Participant actif
Date d'inscription: 2 Jun 2008
Messages: 112

Re: Create a summary table

Set pSumTable = pGeoProc.Dissolve(pTable, False, "years", "Sum.Shape_Area", pOutDSName)


Ni le troiseme parametre, ni le champ Frequency n'ont pas ete cree dans la table. J'ai vu que les champs ObjetcID et Shape_area.

Hors ligne

 

#8 Thu 17 July 2008 17:51

calito
Participant actif
Date d'inscription: 2 Jun 2008
Messages: 112

Re: Create a summary table

Ce que je voulais faire c'est que:
Dans la table attributaire il y a plusieurs objets qui ont les memes années. Donc, je voulais creer une table qui me dit pour chaque année (Champ years) voila combien d'objet qu'il y a (champ frequency).

Hors ligne

 

#9 Thu 17 July 2008 17:52

Tnarbiv
Participant assidu
Lieu: Véretz
Date d'inscription: 5 Sep 2005
Messages: 392

Re: Create a summary table

c'est bizarre, j'ai fais le test chez moi avec mes données et tout marche nickel !!!

que souhaites tu faire exactement ?
peux tu traduire ton bout de code littéralement pour que l'on comprenne mieux et que l'on puisse t'aider un peu plus ?

Dernière modification par Tnarbiv (Thu 17 July 2008 17:52)


Ayez le réflexe "Développement Durable": N'imprimez ce message que si nécessaire.

Hors ligne

 

#10 Thu 17 July 2008 18:00

calito
Participant actif
Date d'inscription: 2 Jun 2008
Messages: 112

Re: Create a summary table

Comme je l'avait dit, c'est un code que j'ai trouvé sur edn.esri.


Est-ce que je peux voir ton code?

Hors ligne

 

#11 Thu 17 July 2008 20:40

Tnarbiv
Participant assidu
Lieu: Véretz
Date d'inscription: 5 Sep 2005
Messages: 392

Re: Create a summary table

mon code est identique à celui d'edn

peux tu m'envoyer tes données pour que je puisse tester

Dernière modification par Tnarbiv (Thu 17 July 2008 20:42)


Ayez le réflexe "Développement Durable": N'imprimez ce message que si nécessaire.

Hors ligne

 

#12 Fri 18 July 2008 09:43

freesnowpetrel
Participant assidu
Lieu: Pretoria, Afrique du Sud
Date d'inscription: 1 Mar 2007
Messages: 222

Re: Create a summary table

bonjour,

Pourquoi ne pas faire ce genre de manip qui releve plus du tableur, dans un tableur a partir de ta table d'attribut au format dbf. Ce sera beaucoup plus simple et plus rapide, un simple tableau croise dynamique devrait repondre a ton besoin, si j'ai bien compris...

Rodolphe

Hors ligne

 

#13 Fri 18 July 2008 14:32

calito
Participant actif
Date d'inscription: 2 Jun 2008
Messages: 112

Re: Create a summary table

Tnarbiv a écrit:

mon code est identique à celui d'edn

peux tu m'envoyer tes données pour que je puisse tester


Voici le code:

Code:

Public Sub CreateSummaryTable(IntCount As Integer)
  
  On Error GoTo EH
  
  Dim pDoc As IMxDocument
  Set pDoc = ThisDocument
  Dim pMap As IMap
  Set pMap = pDoc.FocusMap

  ' Find the layer named US_Counties
  Dim pLayer As ILayer
  Dim pFeatLayer As IFeatureLayer
  Set pLayer = pMap.layer(IntCount) '(intCount)
  Set pFeatLayer = pLayer
  
  ' Get the workspace of the US_Counties layer
  Dim pFeatClass As IFeatureClass
  Dim pTable As ITable
  Dim pDataSet As IDataset
  Dim pWkSpDS As IDataset
  Dim pWkSpName As IName
  Set pFeatClass = pFeatLayer.FeatureClass
  Set pTable = pFeatClass
  Set pDataSet = pTable
  Set pWkSpDS = pDataSet.Workspace
  Set pWkSpName = pWkSpDS.FullName
    
  ' The output is set to SumSample.dbf file in c:\temp
  Dim pWkSpFactory As IWorkspaceFactory
  Dim pWkSp As IWorkspace
  ' Dim pWkSpDS As IDataset
  ' Dim pWkSpName As IWorkspaceName
  Dim pOutDSName As IDatasetName
  Set pWkSpFactory = New ShapefileWorkspaceFactory
  Set pWkSp = pWkSpFactory.OpenFromFile("c:\temp", 0)
  Set pWkSpDS = pWkSp
  Set pWkSpName = pWkSpDS.FullName
  Set pOutDSName = New TableName
  pOutDSName.Name = "Yeah"
  Set pOutDSName.WorkspaceName = pWkSpName
  
  ' Make sure there is a field called state_name in the layer
  If pTable.FindField("years") = -1 Then
    MsgBox "There must be a field named state_name in US_Counties"
    Exit Sub
  End If
  ' Perform the summarize. Note the summary fields string (minimum.state_name ...)
  ' below. This is a comma-delimited string that lists the generated summary
  ' fields. Each field must start with a keyword, and be followed by .fieldName,
  ' where fieldName is the name of a field in the original table.
  '
  ' If you specify the Shape field, you must use the keyword 'Dissolve'. This
  ' is not used below since we are creating a non-spatial summary table.
  Dim pGeoProc As IBasicGeoprocessor
  Dim pSumTable As ITable
  
  Set pGeoProc = New BasicGeoprocessor
  Set pSumTable = pGeoProc.Dissolve(pTable, False, "years", "Sum.Shape_Area", pOutDSName)

  ' add the table to map
  Dim pStTab As IStandaloneTable
  Set pStTab = New StandaloneTable
  Set pStTab.table = pSumTable
  Dim pStTabColl As IStandaloneTableCollection
  Set pStTabColl = pMap
  pStTabColl.AddStandaloneTable pStTab

  ' Refresh the TOC
  pDoc.UpdateContents

  Exit Sub
EH:

  MsgBox Err.Number & " " & Err.Description

End Sub

Hors ligne

 

#14 Fri 18 July 2008 14:40

Tnarbiv
Participant assidu
Lieu: Véretz
Date d'inscription: 5 Sep 2005
Messages: 392

Re: Create a summary table

je ne veux pas le code mais les données sur lesquelles tu veux tester le code !!!!


Ayez le réflexe "Développement Durable": N'imprimez ce message que si nécessaire.

Hors ligne

 

#15 Mon 21 July 2008 08:52

calito
Participant actif
Date d'inscription: 2 Jun 2008
Messages: 112

Re: Create a summary table

Tnarbiv a écrit:

je ne veux pas le code mais les données sur lesquelles tu veux tester le code !!!!


Excuse moi, je n'ai aucune droit de diffuser les données. Par contre, est-ce que tu peux me montrer ton code?

Hors ligne

 

#16 Mon 21 July 2008 09:39

Tnarbiv
Participant assidu
Lieu: Véretz
Date d'inscription: 5 Sep 2005
Messages: 392

Re: Create a summary table

je te rappelle que mon code est identique à celui d'edn !!!!

Code:

Public Sub CreateSummaryTable()
  
  On Error GoTo EH
  
  Dim pDoc As IMxDocument
  Set pDoc = ThisDocument
  Dim pMap As IMap
  Set pMap = pDoc.FocusMap

  ' Find the layer named US_Counties
  Dim pLayer As ILayer
  Dim pFeatLayer As IFeatureLayer
  Dim intCount As Integer
  For intCount = 0 To pMap.LayerCount - 1
    Set pLayer = pMap.Layer(intCount)
    If TypeOf pLayer Is IFeatureLayer Then
      If pLayer.Name = "XXXX" Then
        Set pFeatLayer = pLayer
        Exit For
      End If
    End If
  Next
  If pFeatLayer Is Nothing Then
    MsgBox "The XXXX layer was not found"
    Exit Sub
  End If

  ' Get the workspace of the DDASS layer
  Dim pFeatClass As IFeatureClass
  Dim pTable As ITable
  Dim pDataSet As IDataset
  Dim pWkSpDS As IDataset
  Dim pWkSpName As IName
  Set pFeatClass = pFeatLayer.FeatureClass
  Set pTable = pFeatClass
  Set pDataSet = pTable
  Set pWkSpDS = pDataSet.Workspace
  Set pWkSpName = pWkSpDS.FullName
    
  ' The output is set to SumSample.dbf file in c:\temp
  Dim pWkSpFactory As IWorkspaceFactory
  Dim pWkSp As IWorkspace
  ' Dim pWkSpDS As IDataset
  ' Dim pWkSpName As IWorkspaceName
  Dim pOutDSName As IDatasetName
  Set pWkSpFactory = New ShapefileWorkspaceFactory
  Set pWkSp = pWkSpFactory.OpenFromFile("c:\temp", 0)
  Set pWkSpDS = pWkSp
  Set pWkSpName = pWkSpDS.FullName
  Set pOutDSName = New TableName
  pOutDSName.Name = "SumSample"
  Set pOutDSName.WorkspaceName = pWkSpName
  
  ' Make sure there is a field called state_name in the layer
  If pTable.FindField("test") = -1 Then
    MsgBox "There must be a field named state_name in XXXX"
    Exit Sub
  End If
  
  ' Perform the summarize. Note the summary fields string (minimum.state_name ...)
  ' below. This is a comma-delimited string that lists the generated summary
  ' fields. Each field must start with a keyword, and be followed by .fieldName,
  ' where fieldName is the name of a field in the original table.
  '
  ' If you specify the Shape field, you must use the keyword 'Dissolve'. This
  ' is not used below since we are creating a non-spatial summary table.
  Dim pGeoProc As IBasicGeoprocessor
  Dim pSumTable As ITable
  Set pGeoProc = New BasicGeoprocessor
  Set pSumTable = pGeoProc.Dissolve(pTable, False, "test", "Minimum.test, Count.test, Maximum.test,Minimum.test1, Maximum.test1", pOutDSName)
    
  ' add the table to map
  Dim pStTab As IStandaloneTable
  Set pStTab = New StandaloneTable
  Set pStTab.table = pSumTable
  Dim pStTabColl As IStandaloneTableCollection
  Set pStTabColl = pMap
  pStTabColl.AddStandaloneTable pStTab

  ' Refresh the TOC
  pDoc.UpdateContents

  Exit Sub
EH:

  MsgBox Err.Number & " " & Err.Description

End Sub

Ayez le réflexe "Développement Durable": N'imprimez ce message que si nécessaire.

Hors ligne

 

#17 Mon 21 July 2008 16:07

calito
Participant actif
Date d'inscription: 2 Jun 2008
Messages: 112

Re: Create a summary table

Okey c'est bon maintenant, Merci pour ton aide Tnarbiv.

Hors ligne

 

Pied de page des forums

Powered by FluxBB