Skip to content

Commit

Permalink
fix bug in powerplant geodataframe creation
Browse files Browse the repository at this point in the history
previously, geometry column was not automatically detected
  • Loading branch information
thomas-fred committed Sep 23, 2023
1 parent d2d9513 commit 026bc8f
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions workflow/rules/preprocess/powerplants.smk
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ rule parse_powerplants:
run:
import geopandas as gpd
import pandas as pd
import pygeos

powerplants = pd.read_csv(
input.powerplants,
Expand All @@ -31,9 +30,16 @@ rule parse_powerplants:
}
)
powerplants["asset_type"] = "source"
powerplants["geometry"] = pygeos.points(powerplants.longitude, powerplants.latitude)
powerplants = gpd.GeoDataFrame(powerplants.drop(columns=["longitude","latitude"]))
powerplants = powerplants.set_crs("epsg:4326")
powerplants["geometry"] = gpd.points_from_xy(
powerplants.longitude,
powerplants.latitude,
crs="epsg:4326"
)
powerplants = gpd.GeoDataFrame(
powerplants.drop(
columns=["longitude","latitude"]
)
)
powerplants.to_parquet(output.powerplants)

"""
Expand Down

0 comments on commit 026bc8f

Please sign in to comment.