question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Control resolution of rasterized plots

See original GitHub issue

I’m using ds.hvplot.quadmesh to project and visualise a heatmap of geospatial data. Due to the size of the data, I have to set rasterize=True. As far as I’m aware (and I may be wrong), the only way to control the spatial resolution of the rasterization process is to specify the height and width parameters in the arguments to the plotting function. This has the undesirable effect of making all the figure element (labels, bokeh widgets, etc) super small. It would be preferable if there were a way to control the downsampling process without changing the actual size of the plot. Is there something I’m missing or am I on to something? Cheers!

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
tom-anderssoncommented, Jun 4, 2021

Hmm, this is a bit of a dilemma. 3 would save people time on searching through HoloViews documentation while adding some nice additional functionality (e.g. reducing resolution to send a plot over email, etc). Having to manually set the height and width of the underlying raster (e.g. through option 2 or 1) is a bit unintuitive for new users. The extra flexibility afforded by 1 would be useful too, though.

3 would get my main vote, but 1 would be a nice plus (with a link to the appropriate HoloViews documentation). I guess you would have to ensure users didn’t supply both rasterize_factor and rasterize_args={'height': ..., 'width': ... at the same time though.

1reaction
jbednarcommented, Jun 3, 2021

The underlying rasterize() function provides those arguments, but I don’t think they are exposed in hvPlot. To get around that, you can try code like this sketch:

from holoviews.operation.datashader import rasterize
p = rasterize(ds.hvplot.quadmesh(
        x='lon', y='lat', z=variable,
        crs=crs, projection=projection,
        width=600, height=540, cmap=cmap,
        title=title, legend='bottom', 
        global_extent=False, project=True,
    ), plot_height=300, plot_width=300)
Read more comments on GitHub >

github_iconTop Results From Across the Web

Poor resolution of raster plot when output to file - Stack Overflow
I have a reasonably high definition global map raster and want to plot to file, but cannot seem to maintain resolution.
Read more >
Rasterization for vector graphics - Matplotlib
Rasterization converts vector graphics into a raster image (pixels). ... The storage size and the resolution of the rasterized artist is determined by...
Read more >
Things to consider when setting raster quality factor
The print resolution for raster images is determined by the Raster Quality factory property. Reducing the raster quality factor may be ...
Read more >
How to perform point to raster operation and plot it with raster ...
What is the role of "resolution" in rasterize function? I think rasterize transfers points (or other spatial data) values to raster cells which ......
Read more >
Resample (Data Management)—ArcGIS Pro | Documentation
Changes the spatial resolution of a raster dataset and sets rules for aggregating or interpolating values across the new pixel sizes.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found