pypsa-meets-earth / pypsa-earth

PyPSA-Earth: A flexible Python-based open optimisation model to study energy system futures around the world.
https://pypsa-earth.readthedocs.io/en/latest/
207 stars 167 forks source link

Error in calculation of line lengths #1024

Open bobbyxng opened 1 month ago

bobbyxng commented 1 month ago

Checklist

Describe the Bug

Error Message

# %%
import geopandas as gpd
import shapely
import pypsa
import pandas as pd

# %%
# Load data
# Lengths are provided in km
n = pypsa.Network("base.nc")
link_lengths = n.links.loc[n.links.tag_type == "cable",  ["v_nom", "geometry", "length"]].copy()
link_lengths = link_lengths[link_lengths.v_nom == 320]
link_lengths = gpd.GeoDataFrame(link_lengths, geometry = link_lengths.geometry.apply(shapely.wkt.loads), crs = "EPSG:4326")
link_lengths["length"] = round(link_lengths["length"], 1)
# %%
utm = link_lengths.estimate_utm_crs(datum_name = "WGS 84")
link_lengths["length_wgs84"] = round(link_lengths.to_crs(utm).length / 1000, 1)

# %%
distance_crs = "EPSG:3035"
link_lengths["length_epsg3035"] = round(link_lengths.to_crs(distance_crs).geometry.length / 1000, 1)

# %%
distance_crs = "EPSG:3857"
link_lengths["length_epsg3857"] = round(link_lengths.to_crs(distance_crs).geometry.length / 1000, 1)

image