Baltic-RCC / EMF

Repository for Open Source EMF implementation
Mozilla Public License 2.0
8 stars 3 forks source link

Create Geographic Location Profile for IGM-s #53

Open Haigutus opened 3 months ago

Haigutus commented 3 months ago

Summary: Query geojson from openstreet maps substation/line locations. Get substation/line mRID and named from EQ profile. Map geojson names and substaion/line names.

  1. Query geo data from open street maps (example query - https://overpass-turbo.eu/s/1Iem) NB! Use geojson format as export
  2. Get relevant objects form IGM (substations, etc.) using triplets data.type_tableview("Substation")
  3. Fuzzy search/map names form open street maps and object names form EQ (https://pypi.org/project/thefuzz/)
  4. Generate CIM GL profiles instance using triplets
    1. cim:CoordinateSystem
    2. cim:Location (Location -> PowerSystemResources and Location -> CoordinateSystem
    3. cim:PositionPoint (PositionPoint -> Location)

geojson Example - https://geojson.org/

{
  "type": "Feature",
  "geometry": {
    "type": "Point",
    "coordinates": [125.6, 10.1]
  },
  "properties": {
    "name": "Dinagat Islands"
  }
}

CIM GL Example

    <cim:CoordinateSystem rdf:ID="_aeae4b90-1057-9c4b-b328-824fd84955e4">
        <cim:CoordinateSystem.crsUrn>urn:ogc:def:crs:EPSG:4326</cim:CoordinateSystem.crsUrn>
    </cim:CoordinateSystem>
    <cim:Location rdf:ID="_b315a61a-1b3f-2348-bbb6-97ae8309f715">
        <cim:Location.PowerSystemResources rdf:resource="#_0047886e-1940-4cca-8ea7-f7066fd04d1e"/>
        <cim:Location.CoordinateSystem rdf:resource="#_aeae4b90-1057-9c4b-b328-824fd84955e4"/>
    </cim:Location>
    <cim:PositionPoint rdf:ID="_374827bb-db2a-3342-84f4-cb39a934de1d">
        <cim:PositionPoint.Location rdf:resource="#_087838f1-1a92-394d-afc6-dfbdc454d77b"/>
        <cim:PositionPoint.sequenceNumber>1</cim:PositionPoint.sequenceNumber>
        <cim:PositionPoint.xPosition>24.8</cim:PositionPoint.xPosition>
        <cim:PositionPoint.yPosition>59.3</cim:PositionPoint.yPosition>
    </cim:PositionPoint>
import overpass
import geopandas as gpd

# Initialize the Overpass API
api = overpass.API(timeout=500)

# Fetch data from Overpass API
res = api.get("""
    area[name="Granollers"][admin_level=8];
    (way["highway"](area);
     relation["highway"](area);
    );
""", verbosity='geom')

# Convert the Overpass response (GeoJSON) to a GeoDataFrame
gdf = gpd.GeoDataFrame.from_features(res)
Haigutus commented 3 months ago

What needs to be added for CIM export, in addition to the GL object themselves

you need to add two attributes like this

  1. Model.messageType=GL
  2. label=export file name

How: pandas.concat([data, pandas.DataFrame([{"ID": "GL_FULLMODEL_ID", "KEY": "Model.messageType", "VALUE": "GL", "INSTANCE_ID": "GL_INSTANCE_ID"}])])

Haigutus commented 3 months ago

@gpoderys limit scope under this ticket and move full scope to MS8

gpoderys commented 2 months ago

Currently GL profile is generated with multiple elements that point to a single PowerSystemResource. This is due to some of the lines in OpenStreetMaps being split into separate segments, and I was unable to group them together, since their coordinates don't always match up from one segments end to another's start. Splitting line coordinates into separate points and then merging them together didn't work either, because there is no way to sequence those points to show whrere each line begins and ends. With current state of the data, my only idea was to do manual labor and join segmented lines into LineStrings, but I never got around to it. Also I wasn't able to find a way to use OverpassTurbo to query for HVDC lines, but I know it should be possible.

For now this task is on hold.