admin管理员组

文章数量:1130349

I am using the biosurvey package trying to run a function (biosurvey::explore_data_EG) that plots 4 panels, which specifically for me are 2 large map rasters at 1km resolution for Canada, 1 biplot from the x-y coordinates and 1 kernel density of such x-y biplot.Aas far as I can see, the function is just a wrapper of base R plots (or base terra plots).

I am running this for all Canada using climate rasters from ClimateNA at 1km resolution, and a shape file for the country. Hence why is hard for me to provide reproducible code. But I will try to describe as best as I can.

When I use the function with the 1km resolution rasters it never prints the last panel in the png() device, and I do not get any error. This is the chunk I use to open the png device:

png("plots/explorePCA_CANBONv1_presel_FULL.png", height = 10, width = 15, units = "in" , res = 300)
biosurvey::explore_data_EG(m_matrixp, variable_1 = "PC1", variable_2 = "PC2") #this outputs a 4 panel plot
dev.off()

The biplot is 10M x 10M points resulting from the 1km raster

  ..$ PC1          : num [1:10003405] -3.01 -2.83 -2.81 -2.81 -2.78 ...
  ..$ PC2          : num [1:10003405] 0.1564 -0.0623 -0.0949 -0.089 -0.1386 ...

Even in remote computer clusters with 64GB of RAM, the issue is the same, so it is not a RAM issue for sure.

If I aggregate the raster, resulting in a smaller x-y matrix, it prints fine and saves the png file no problem.

So I wonder if there is an internal limitation for the png device (I tried tif, and jpeg, changed size, and resolution, and nothing solved it). Looking at the documentation of the function, there is nothing that would solve it at first sight.

A comment here indicates a limit of 4 billion pixels or so in a png device (?): File format limits in pixel size for png images?

"The standard says size is 32 bit unsigned integer so the theoretical limit would be somewhere around 4 billion pixels (nine zeros) x and y. As mentioned by Mark Ransom, a straightforward implementation of PNG would require almost 3GB to render your 30k by 30k pixel image. Firefox probably errored out when it couldn't allocate enough memory but I'm not really sure since I don't know exactly how firefox renders PNGs"

Any ideas about this would be greatly appreciated.

I am using the biosurvey package trying to run a function (biosurvey::explore_data_EG) that plots 4 panels, which specifically for me are 2 large map rasters at 1km resolution for Canada, 1 biplot from the x-y coordinates and 1 kernel density of such x-y biplot.Aas far as I can see, the function is just a wrapper of base R plots (or base terra plots).

I am running this for all Canada using climate rasters from ClimateNA at 1km resolution, and a shape file for the country. Hence why is hard for me to provide reproducible code. But I will try to describe as best as I can.

When I use the function with the 1km resolution rasters it never prints the last panel in the png() device, and I do not get any error. This is the chunk I use to open the png device:

png("plots/explorePCA_CANBONv1_presel_FULL.png", height = 10, width = 15, units = "in" , res = 300)
biosurvey::explore_data_EG(m_matrixp, variable_1 = "PC1", variable_2 = "PC2") #this outputs a 4 panel plot
dev.off()

The biplot is 10M x 10M points resulting from the 1km raster

  ..$ PC1          : num [1:10003405] -3.01 -2.83 -2.81 -2.81 -2.78 ...
  ..$ PC2          : num [1:10003405] 0.1564 -0.0623 -0.0949 -0.089 -0.1386 ...

Even in remote computer clusters with 64GB of RAM, the issue is the same, so it is not a RAM issue for sure.

If I aggregate the raster, resulting in a smaller x-y matrix, it prints fine and saves the png file no problem.

So I wonder if there is an internal limitation for the png device (I tried tif, and jpeg, changed size, and resolution, and nothing solved it). Looking at the documentation of the function, there is nothing that would solve it at first sight.

A comment here indicates a limit of 4 billion pixels or so in a png device (?): File format limits in pixel size for png images?

"The standard says size is 32 bit unsigned integer so the theoretical limit would be somewhere around 4 billion pixels (nine zeros) x and y. As mentioned by Mark Ransom, a straightforward implementation of PNG would require almost 3GB to render your 30k by 30k pixel image. Firefox probably errored out when it couldn't allocate enough memory but I'm not really sure since I don't know exactly how firefox renders PNGs"

Any ideas about this would be greatly appreciated.

本文标签: