You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am attempting to visualize data that resides on unstructured grids. To achieve this, I am developing a to_gdf method that converts our unstructured grid representation into geometries (Polygons) that can be visualized.
I have been able to compute the geometries of the grid and collect them in a spatialpandas.GeoDataFrame, however when mapping data variables to the polygons, visualizing them with rasterize=False produces seemingly random results when compared to using rasterize=True when using the matplotlib backend.
Using the bokeh backend correctly maps the data with or without rasterization.
Here is the code for how we construct our geometries
defto_gdf(self, override=False, cache=True):
# return cached gdfifself._gdfisnotNoneandnotoverride:
returnself._gdf# obtain polygon shells for shapely polygon constructionpolygon_shells=self.polygon_shells# list of shapely Polygons representing each Face in our gridpolygons= [Polygon(shell) forshellinpolygon_shells]
# List of Polygons (non-split) and MultiPolygons (split across antimeridian)corrected_polygons= [antimeridian.fix_polygon(P) forPinpolygons]
# prepare geometry for GeoDataFramegeometry=MultiPolygonArray(corrected_polygons)
# construct our GeoDataFrame with corrected polygonsgdf=GeoDataFrame({"geometry": geometry})
# cache instance of gdfifcache:
self._gdf=gdfreturngdf
Software Version Info
uxarray on branch "philipc2/wrapped-polygons" for development spatialpandas 0.4.8 shapely 2.0.1 geoviews 1.9.6 hvplot 0.8.4 holoviews 1.16.2 xarray 2023.5.0
MCVE
# on branch "philipc2/wrapped-polygons" for development importuxarrayasuximportxarrayasxrimporthvplot.pandasimportgeoviews.featureasgfhvplot.extension('matplotlib')
# load grid and data filesmpas_root_filepath="../../test/meshfiles/mpas/other/"mpas_dataset_filepath=mpas_root_filepath+"ocean.QU.480km.scrip.151209.nc"data_path=mpas_root_filepath+"ocean.QU.480km.151209.nc"uxgrid=ux.open_grid(mpas_dataset_filepath, use_dual=False)
# faces mapped to polygons with corrected antimeridian crossing, stored as a sp.GeoDataFramegdf=uxgrid.to_gdf()
# obtain a 1D slide of temperature that maps to each faced_var=xrds['temperature'].values[0, :, 0]
gdf['d_var'] =d_var# plotgdf.hvplot.polygons(rasterize=False, geo=True, hover_cols='all', c="d_var", height=1000, width=2000, cmap='inferno') *gf.coastline
The text was updated successfully, but these errors were encountered:
philipc2
changed the title
Data not mapping properly to Polygons when rasterize=False
Data not mapping properly to Polygons when rasterize=False & Matplotlib Backend
Jun 28, 2023
philipc2
changed the title
Data not mapping properly to Polygons when rasterize=False & Matplotlib Backend
Data not mapping properly to Polygons when rasterize=False & Matplotlib Extension
Jun 28, 2023
Overview
I am attempting to visualize data that resides on unstructured grids. To achieve this, I am developing a
to_gdf
method that converts our unstructured grid representation into geometries (Polygons) that can be visualized.I have been able to compute the geometries of the grid and collect them in a
spatialpandas.GeoDataFrame
, however when mapping data variables to the polygons, visualizing them withrasterize=False
produces seemingly random results when compared to usingrasterize=True
when using thematplotlib
backend.Using the bokeh backend correctly maps the data with or without rasterization.
Here is the code for how we construct our geometries
Software Version Info
uxarray
on branch "philipc2/wrapped-polygons" for developmentspatialpandas
0.4.8shapely
2.0.1geoviews
1.9.6hvplot
0.8.4holoviews
1.16.2xarray
2023.5.0MCVE
Plots Showcasing Described Issue
Sea Surface Temperature
Raster Plot (MPL)
Non-Raster Plot (MPL)
Raster Plot (Bokeh)
Non-Raster Plot (Bokeh)
Ocean Depth
Raster Plot
Non-Raster Plot
The text was updated successfully, but these errors were encountered: