How can I import geographical coordinates from an Excel table with a Python script?
The attached PowerFactory project includes a script called "Coordinates Import" which allows users to import geographical coordinates from GIS or other systems that are stored in an Excel file for the following element classes: ElmTerm (Busbars), ElmLne (Lines), ElmSubstat (Substations), and ElmSite (Sites). The script requires the following input parameters:
- filename: The path and filename of the Excel file containing the coordinates to be imported.
- identifier: The attribute in PowerFactory that should be used to match the data from the Excel file with the objects in PowerFactory. Commonly used identifiers include "loc_name" (Element Name) or "for_name" (Foreign Key).
After the import, the geographic diagram has to be rebuild once to show the changes.
The Excel file must contain a separate sheet for each element class to be imported, with the identifier column named after the identifier. For ElmTerm, ElmSubstat, and ElmSite, the file must also include "GPSlat" and "GPSlon" columns. For ElmLne, any number of "GPSlat(i)" and "GPSlon(i)" columns may be included, where i must start with 0. For testing the "Coordinates Import" script, an example Excel file with the required structure is attached. The attached PowerFactory project also includes a second script called "Coordinates Reset," which can be used to delete all coordinates if necessary.