Put lat/lon points onto an 80km x 80km grid
1 view (last 30 days)
Show older comments
Hello,
I have a list of lat/lon points (severe weather reports) that all fall over the continental united states.
What I want to do is basically put these points onto an 80km x 80km grid, and look at whether each grid box has a report in it or not. The number of reports in each box does not matter, just whether it has a report in it or not.
So the end result should be a matrix of 1's and 0's, with each index corresponding to a certain 80km x 80km box over the US.
Thanks
0 Comments
Answers (2)
Kelly Kearney
on 1 Apr 2016
The hist3 function will do the main binning for you, once you define your bin edges. A perfect 80km x 80km grid might be a little difficult to set up in terms of lat/lon edges, but assuming you're willing to fudge it a bit, a ~0.719-deg (lat) x ~1.09 (lon) grid will be about the right resolution.
If you have exact coordinates of the 80 km x 80 km grid boxes, inpolygon could help.
Chad Greene
on 3 Apr 2016
If you need even grid spacing you'll have to work in some projected coordinates. Use projfwd to get your lat,lon data into some projected x,y coordinates. You'll have to choose a projection that minimizes distortion for the area of your data, but for an area the size of the United States every projection will have some distortion.
After your data are in projected coordinates I'd follow Kelly's advice and use hist3 to determine how many data points are in each grid cell. Using the syntax N = hist3(...) you can then get the logical matrix M you're seeking by M = N>0.
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!