22 views (last 30 days)

Hey all hope you have a good time,

I have a (1 x 1171) cell which includes tables. Each table has a specific latitude and longitude (columns). All 1171 tables latetudes and longitudes together represent gridded precipitation data over the whole country in the 0.5 x 0.5 degree (longitude x latitude).

I also have some points data (in the form of a table with columns of longitude, latitude, and precipitation).

I want to delete each grid in my cell that doesn't have at least one of my points inside it.

For example: If red dots are my points (in the table that I mentioned above), I want to keep each grid that has at least one red dot inside it (I would like to keep grid if more than one point is in it). So from 130 grids in this figure below I want to keep only nine grids that have points. So if my cell was 130x336 now it is just 9x336.

I attach my cell and my points.

Thank you so much for your valuable advice.

darova
on 17 Feb 2020

Here is my achievement

clc,clear

load points.mat

load grid_datamat.mat

p = table2array(Points);

g = table2array(grid_data(:,2:3));

x = floor( (p(:,2)-24.25)/0.5 )*0.5+24.25;

y = floor( (p(:,3)-44.25)/0.5 )*0.5+44.25;

plot(p(:,2),p(:,3),'.r')

hold on

plot([x x+0.5 x+0.5 x x]',[y y y+0.5 y+0.5 y]','.-b','markersize',15)

plot(g(:,2),g(:,1),'.g')

hold off

Sign in to answer this question.

Opportunities for recent engineering grads.

Apply Today
## 3 Comments

## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/505827-selecting-parts-of-gridded-data-i-need-help-i-want-to-know-it-s-possible-or-not#comment_798215

⋮## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/505827-selecting-parts-of-gridded-data-i-need-help-i-want-to-know-it-s-possible-or-not#comment_798215

## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/505827-selecting-parts-of-gridded-data-i-need-help-i-want-to-know-it-s-possible-or-not#comment_798216

⋮## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/505827-selecting-parts-of-gridded-data-i-need-help-i-want-to-know-it-s-possible-or-not#comment_798216

## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/505827-selecting-parts-of-gridded-data-i-need-help-i-want-to-know-it-s-possible-or-not#comment_798232

⋮## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/505827-selecting-parts-of-gridded-data-i-need-help-i-want-to-know-it-s-possible-or-not#comment_798232

Sign in to comment.