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

Rencontres QGIS 2025

L'appel à participation est ouvert jusqu'au 19 janvier 2025!

#1 Thu 03 March 2005 10:45

Frederic Sanchis
Invité

contruction de polyligne partir d'une table a champs xy multiples

Bonjour a tous

j'ai recupere une table (dbf) representant des reseaux. chaque enregistrement correspond a un troncons et possede entre autre champs, des champs X1, Y1 , X2, Y2.......X6, Y6 . ces champs donnent les coordonnees des differents sommets qui constituent chaque troncon.
il ya par ailleur un champ ID.
mon objectif , vous l'aurez compris , c'est de recontruire le reseau a partir de cette table, sans avoir a la restructurer , cad reorganiser la table pour n'avoir q'un champ X et Y + un ID cree de toute piece et un champ ordre : cette methode permet avec ET geowizard de creer le reseau mais elle ne permet pas de recuperer le champ ID de depart dans le shp polyline d'arrivee et est assez longue.
Donc si vous connaissez un script ou outil capable de creer ce reseau directement a partir de la table de depart, je vous serais tres reconnaissant de me faire partager ce savoir : pour l'instant , mes recherches sont restees vaines.

rq : je dispose d'Arcwiew 3 et 8.3

merci d'avance

kele

 

#2 Thu 03 March 2005 13:07

Loic Donot
Invité

Re: contruction de polyligne partir d'une table a champs xy multiples

Bonjour,

Sous arcview 3, il vous faudra utiliser le script gen to shape (gen2shp,
disponible je pense sur arcscript) apres avoir cree un fichier .gen.
Vous pouvez convertir un shape en .gen (pour examiner le format) a l'aide du
script shape to generate fourni de base (je crois) avec arcview 3.
Quand aux versions 8 & 9, j'ignore si il est possible, sans developpement,
de parvenir au meme resultat...il semble en tout cas que le format generate
ne soit plus reconnu par ces versions.

Bon courage.

Loic DONOT,
CETE Mediterranee - Departement de l'informatique
GeoPol
BP 37000 - 13791 Aix en Provence Cedex 03
Tel : 04 42 24 72 57
Fax : 04 42 60 79 86

PS : je joins le texte du script gen2shp ci dessous (a coller dans la
fenetre script d'arcview 3).

-------
-------
--------

'
' Name: GEN2SHP.AVE
'
' Headline: Converts ASCII GEN output to Point, Line or Polygon shapefile.
'
' Self:
'
' Returns:
'
' Description: Reads coordinate information from the specified file, prompts
' the user for the output shapefile type (line, point, polygon), and creates
' the shapefile. In the case of polygons the first point is used to close
' the polygon.
'
' The generated shapefile contains the original record ID inorder that
' attribute data may be joined back to the new shapefile.
'
' This script assumes that the file will containing comma-delimited
' coordinates in the standard Arc/Info Generate format:
'-
'- POINT Format:
'-   station_id, x_coordinate, y_coordinate
'-   station_id, x_coordinate, y_coordinate
'-   station_id, x_coordinate, y_coordinate
'-   ....
'-   station_id, x_coordinate, y_coordinate
'-   END
'-
'- LINE or POLYGON Format
'-   station_id
'_   x_coordinate, y_coordinate
'-   x_coordinate, y_coordinate
'-   x_coordinate, y_coordinate
'-   ....
'-   x_coordinate, y_coordinate
'-   END
'-   station_id
'-   x_coordinate, y_coordinate
'-   x_coordinate, y_coordinate
'-   x_coordinate, y_coordinate
'-   ....
'-   x_coordinate, y_coordinate
'-   END
'-   END
'-
' The script assumes that each record in the input file is a data record,
' i.e. there is no header. Coordinates are read until the end of file is
' reached or until the string END is found.
'
' Topics: Utilities, Conversion
'
' Search Keys: Gen, Generate, Shapefiles, Shapes, Shapes - creating,
' Shapefiles - creating
'
' Requires: Input file containing coordinate information.
'
' History:
'- John M Linehan
'- PanEnergy Corporation
'- Houston, TX 77056
'- 17 Apr 96
'- ArcView 2.1
' ===================================================================
'  Choose the GEN file to convert to shapefile...
' -------------------------------------------------------------------
'
genName = FileDialog.Show( *.GEN , GEN File , Select GEN File to Convert )
if (genName = nil) then
exit
end

genFile = LineFile.Make(genName, #FILE_PERM_READ)
totalRecs = genFile.GetSize

' -------------------------------------------------------------------
'  Specify the output shapefile...
' -------------------------------------------------------------------
'
defaultName  = FileName.Make( /root ).MakeTmp( shape , shp )
shpName = FileDialog.Put( defaultName, *.shp , Output Shape File )
if (shpName = nil) then
exit
end

shpName.SetExtension( shp )

' -------------------------------------------------------------------
'  Specify which kind of shapefile to create and make the new FTab...
' -------------------------------------------------------------------
'
type = MsgBox.ChoiceAsString({ Point , Line , Polygon },
Convert GEN locations to: , GEN Convert )
if (type = Nil) then
exit
end

if (type = Point ) then
shpFTab = Ftab.MakeNew(shpName,Point)
elseif (type = Line ) then
shpFTab = FTab.MakeNew(shpName, Polyline)
elseif (type = Polygon ) then
shpFTab = FTab.MakeNew(shpName, Polygon)
end

fields = List.Make
fields.Add(Field.Make( Station , #FIELD_SHORT, 4, 0))
shpFTab.AddFields(fields)
shpField = shpFTab.FindField( Shape )
idField = shpFTab.FindField( Station )

genRec = 0

av.ShowStopButton
av.ShowMsg( Converting ++genName.GetBaseName+ ... )
'
' If the user has chosen 'Point' then the FTab is written here in the
' while loop. Otherwise if 'Line' or 'Polygon' has been chosen we
' collect coordinates in the loop for writing to the FTab later...
'
if ((type = Line ) or (type = Polygon )) then
pointList = List.Make
end
' -------------------------------------------------------------------
'  POINT Generation
' -------------------------------------------------------------------
if (type = Point ) then
while (true)
buf = genFile.ReadElt       'read file until first END
if (buf = Nil) then
break
end
if (buf = END ) then
break
end
genTokens = buf.AsTokens( , )
theID = genTokens.Get(0).AsNumber
thePoint = genTokens.Get(1).AsNumber@texte-a-enlever.genTokens.Get(2).AsNumber
rec = shpFTab.AddRecord
shpFTab.SetValue( idField, rec, theID )
shpFTab.SetValue( shpField, rec, thePoint )
genRec = genRec + 1
progress = (genRec / totalRecs) * 100
proceed = av.SetStatus( progress )
if (proceed.Not) then
av.ClearStatus
av.ShowMsg( Stopped )
exit
end
end
av.ClearStatus
av.ClearMsg
shpFTab.Flush
MsgBox.Info( genRec.AsString++ records converted. , Conversion Completed
)
exit
end
'
' -------------------------------------------------------------------
'  LINE Generation
' -------------------------------------------------------------------
if (type = Line ) then
buf = genFile.ReadElt        'get line-id from first record
if (buf = Nil) then
MsgBox.Error( Input Format Problem , GEN_2_SHP )
exit
end
theID = buf.AsNumber
oldBuf = buf
buf = genFile.ReadElt        'get first coordinate pair (2nd
record)
if (buf = Nil) then
MsgBox.Error( Input Format Problem , GEN_2_SHP )
exit
end
'stop if oldBuf = buf ie:
END,END
while ((oldBuf buf) and (buf Nil))  'or if buf = EOF
oldBuf = buf
genTokens = buf.AsTokens( , )      'read x,y coordinate record
thePoint = genTokens.Get(0).AsNumber@texte-a-enlever.genTokens.Get(1).AsNumber
pointList.Add( thePoint )        'add x,y to list
genRec = genRec + 1
progress = (genRec / totalRecs) * 100  'display progress
proceed = av.SetStatus( progress )
if (proceed.Not) then
av.ClearStatus
av.ShowMsg( Stopped )
exit
end
buf = genFile.ReadElt       'get next coordinate pair(3rd
record...)
if (buf = Nil) then
MsgBox.Error( Input Format Problem , GEN_2_SHP )
exit
end
if (buf = END ) then       'end of line?, write to FTab
rec = shpFTab.AddRecord
shpFTab.SetValue( idField, rec, theID )
pl = Polyline.Make( {pointList} ) 'create line from point list
shpFTab.SetValue( shpField, rec, pl )
shpFTab.Flush
pointList = List.Make      'purge old point list, start new.
oldBuf = buf
buf = genFile.ReadElt      'get new line-id
if (buf = Nil) then
MsgBox.Error( Input Format Problem , GEN_2_SHP )
exit
end
if (buf = END ) then      'double END? - end of file, exit
av.ClearStatus
av.ClearMsg
shpFTab.Flush
MsgBox.Info( genRec.AsString++ records converted. , Conversion
Completed )
exit
else
theID = buf.AsNumber      'set new line-id
end
buf = genFile.ReadElt      'get next coordinate pair
if (buf = Nil) then
MsgBox.Error( Input Format Problem , GEN_2_SHP )
exit
end
end
end
end
'
' -------------------------------------------------------------------
'  POLYGON Generation
' -------------------------------------------------------------------
if (type = Polygon ) then
buf = genFile.ReadElt        'get poly-id from first record
if (buf = Nil) then
MsgBox.Error( Input Format Problem , GEN_2_SHP )
exit
end
theID = buf.AsNumber
oldBuf = buf
buf = genFile.ReadElt        'get first coordinate pair
if (buf = Nil) then
MsgBox.Error( Input Format Problem , GEN_2_SHP )
exit
end

while ((oldBuf buf) and (buf Nil))
oldBuf = buf
genTokens = buf.AsTokens( , )
thePoint = genTokens.Get(0).AsNumber@texte-a-enlever.genTokens.Get(1).AsNumber
pointList.Add( thePoint )
genRec = genRec + 1
progress = (genRec / totalRecs) * 100
proceed = av.SetStatus( progress )
if (proceed.Not) then
av.ClearStatus
av.ShowMsg( Stopped )
exit
end
buf = genFile.ReadElt       'get next coordinate pair
if (buf = Nil) then
MsgBox.Error( Input Format Problem , GEN_2_SHP )
exit
end
if (buf = END ) then       'end of poly?, write to FTab
startPoint = pointList.Get(0)  'set last point equal first
pointList.Add( startPoint)
rec = shpFTab.AddRecord
shpFTab.SetValue( idField, rec, theID )
pl = Polygon.Make( {pointList} )
shpFTab.SetValue( shpField, rec, pl )
shpFTab.Flush
pointList = List.Make
oldBuf = buf
buf = genFile.ReadElt      'get new poly-id
if (buf = Nil) then
MsgBox.Error( Input Format Problem , GEN_2_SHP )
exit
end
if (buf = END ) then      'double END? - end of file, exit
av.ClearStatus
av.ClearMsg
shpFTab.Flush
MsgBox.Info( genRec.AsString++ records converted. , Conversion
Completed )
exit
else
theID = buf.AsNumber      'set new poly-id
end
buf = genFile.ReadElt      'get next coordinate pair
if (buf = Nil) then
MsgBox.Error( Input Format Problem , GEN_2_SHP )
exit
end
end
end
end

av.ClearStatus
av.ClearMsg
shpFTab.Flush
MsgBox.Info( genRec.AsString++ records converted. , Conversion Completed )
' End

 

Pied de page des forums

Powered by FluxBB