Skip to content

util.coordinates functions add 'geometry' column to GeoDataFrame #888

@emanuel-schmid

Description

@emanuel-schmid

Describe the bug
Whenever climada.util.coordinates.points_to_raster or climada.util.coordinates.set_df_geometry_points are executed a warning is raised:

FutureWarning: You are adding a column named 'geometry' to a GeoDataFrame constructed without an active
geometry column. Currently, this automatically sets the active geometry column to 'geometry' but in the
future that will no longer happen.
Instead, either provide geometry to the GeoDataFrame constructor (GeoDataFrame(... geometry=GeoSeries())
or use `set_geometry('geometry')` to explicitly set the active geometry column.

To Reproduce
Steps to reproduce the behavior/error:

  1. Create an Exposures object without a proper geometry column.
  2. Run set_geometry_points on it.
  3. Run plot_raster on it.

Code example:

import pandas as pd
from shapely.geometry import Point
from climada.entity.exposures import Exposures


exp = Exposures(data=pd.DataFrame(
    dict(
        latitude = [1,2,3]*3,
        longitude = [1]*3+[2]*3+[3]*3,
        value = range(9)
    )
), crs='EPSG:4326')
exp.set_geometry_points()
exp.plot_raster()

Expected behavior
Silent plotting.

Climada Version:

  • climada_python >= 4.0

System Information (please complete the following information):

  • Operating system and version: Windows 10
  • Python version:3.9

Additional context

  • geopandas >= 0.14

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions