Using scatteredinterpolant instead of griidedinterpolant

13 次查看(过去 30 天)
I have a spatial data of fine resolution in gridded format of a CSV file. I want to use griddedinterpolant function and upscale into a little coarser format. But when I created a meshgrid with the source data lat-lon points, it has become unresponsive stating the generated grid is 28GB memory and MATLAB cannot process such huge data. So is the case when I used interp2. When I tried scatteredinterpolation function, it worked like a charm. Output files have been generated with more or less satisfying results. My question is what to do when we cannot use griddedinterpolant for gridded data of very fine spatial resolution? Is scatteredinterpolant safe to use as an alternative to griddedinterpolant in such cases?
Thank you in advance.
  3 个评论
Hitesh Bugata
Hitesh Bugata 2020-9-27
I have understood the mistake from your explanation of space occupied by using mesh grid again and again. I've realized the mistake I'm making.
Hitesh Bugata
Hitesh Bugata 2020-9-27
Can you put the space occupied comment as another answer so that I can accept it as an answer?

请先登录,再进行评论。

采纳的回答

Matt J
Matt J 2020-9-27
It looks like the latitude and longitude data in your CSV files are already meshgridded. By meshgridding them an additional time, you have created an explosion of unnecessary duplicate latitude and longitude values. See how the memory consumption grows exponentially in the following simplified illustration of what you've done:
>> x=1:30;y=2:31;
>> [X,Y]=meshgrid(x,y);
>> [XX,YY]=meshgrid(X,Y);
>> whos x y X Y XX YY
Name Size Bytes Class Attributes
X 30x30 7200 double
XX 900x900 6480000 double
Y 30x30 7200 double
YY 900x900 6480000 double
x 1x30 240 double
y 1x30 240 double

更多回答(2 个)

Image Analyst
Image Analyst 2020-9-27
Why not simply use imresize()?
  4 个评论
Image Analyst
Image Analyst 2020-9-27
You said " My question is what to do when we cannot use griddedinterpolant for gridded data of very fine spatial resolution?" so do you have gridded data (a 2-D matrix) or not? I always use scatteredInterpolant() because it's the more general of the functions and will work in all cases. Why do you say you can't use griddedIterpolant for very fine spatial resolution? What is en example of that situation?
Hitesh Bugata
Hitesh Bugata 2020-9-27
I have a fine resolution data in .CSV format in the format as atatched in the image. To use griddedinterpolant or interp2, a meshgrid or ndgrid needs to be created using lat, lon values. When I did that step, command window shows " Requested 61890x61890 (28.5GB) array exceeds maximum array size preference. Creation of arrays greater than this limit may take a long time and cause MATLAB to become unresponsive.". I need data at coarser resolution for a work.

请先登录,再进行评论。


Matt J
Matt J 2020-9-27
编辑:Matt J 2020-9-27
But when I created a meshgrid with the source data lat-lon points.
You should not create a meshgrid, since it consumes unnecessary memory. You should use the grid vector syntax,
F = griddedInterpolant({x,y},z);
where x and y are grid vectors, not meshgrids.
It may also interest you to know that what you are trying to do has already been implemented for you in the File Excahge submission imresizen(),
Unlike imresize(), it requires no toolboxes, but it also doesn't have any of the fancy pre- and post- filtering that imresize uses to improve the quality of the downsampling.

类别

Help CenterFile Exchange 中查找有关 Matrices and Arrays 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by