Skip to content

Conversion to GeoDataFrame Method (to_gdf) #362

Closed

Description

@philipc2

Overview

As per #225, visualization using Datashader expects our unstructured grid to be represented as a spatialpandas.GeoDataFrame with the following entries

  • Grid Representation: spatialpandas.geometry.MultiPolygonArray, collection of Polygons that are representative of the faces of our unstructured grid.
  • Data Variables: Values to color the polygons

Implementation

Given that all entries within a GeoDataFrame must be 1D arrays, the implementation will depend on where the to_gdf method is called.

Grid.to_gdf()

Implementation here will contain the bulk of the computations associated with represented our internal unstructured grid as a spatialpandas.geometry.MultiPolygonArray and will return a GeoDataFrame with only the Grid Representation populated (no data variables). It should handle all data-cleaning (Antimeridian Splitting, Coordinate Verification, Coordinate Transforms, etc.)

UxDataArray.to_gdf()

Will internally call Grid.to_gdf() to construct or return the cached version of the GeoDataFrame with the grid representation already populated. Additionally, will populate a column in the GeoDataFrame with a 1D entry representing the values we want to shade each Polygon (Face) with.

Below is an example showcasing how this would work considering the 1D limitation of the GeoDataFrame

# some grid with a multi-dimensional data variable ("T" with dimensions ['Time', 'Layer', 'nFace'])
uxds = ux.open_dataset(grid_file, data_file)

# not supported
gdf = uxds['T'].to_gdf()

# a 1D slide is supported 
gdf = uxds['T'][0, 0].to_gdf()

UxDataDataset.to_gdf()

Converting the entire dataset, especially if it includes multi-dimensional data variables, is not recommended/plausible.

Activity

  1. added
    new feature
    on Jun 27, 2023
  2. self-assigned this
    on Jun 27, 2023
  3. linked a pull request that will close this issueData Structures & Helpers for Visualization #354on Jun 28, 2023
  4. moved this from 📝 To Do to 🏗 In progress in UXarray Developmenton Jul 3, 2023
  5. added this to the Visualization milestone on Jul 27, 2023
  6. moved this from 🏗 In progress to ✅ Done in UXarray Developmenton Aug 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

new feature

Type

No type

Fields

Priority

None yet

Projects

Relationships

None yet

Development

No branches or pull requests

Issue actions