Extract Data Points within a Closed Boundary.

16 次查看(过去 30 天)
I have a large array of geographical data in which the first two columns are latitude and longitude respectively. Remaining columns contain other data like the prominance of a peak located at that particular lat and long. I also have a matrix of lattitude and longitude pairs that define the borders of a particular closed area like a State or Country (thanks to Chad Green's borders.m code in the File Share section).
What I need to do is extract all the data from the large array that are inside or on the border of the particular area I choose. I'm not trying to find the number of points within or on the boundary but looking for a new output matrix which contains the lat & long point along with the other associated column data from the original large array.
I'm guessing Matlab may already contain a function for this operation which is probably faster than any brute force code I would write. I don't have the mapping toobox, just basic Matlab.
Thanks
  3 个评论
Image Analyst
Image Analyst 2020-8-22
How large? Tens of millions of rows? Hundreds of millions of rows? Billions of rows? Anyway I think going down row-by-row using inpolygon() might be the approach to use.
Shawn
Shawn 2020-8-22
The input data set can be as large as 25 million rows and 6 to 10 columns. It might be possible to trim it down by some pre-processing, like getting rid of points with a negative latitude if the area of interest is in the northern hemisphere and so forth to focus down to a smaller input matrix.
I'm looking at inploygon now for the first time. At first glance, it looks like it returns a vector containing 1 for an input row that's inside the boundary and 0 for an input row outside the boundary. So for an input matrix of 25 million rows inpolygon would return a vector of equal length.
My typical use for Matlab is feedback control design, so this is new territory for me.
Thanks

请先登录,再进行评论。

回答(1 个)

Shawn
Shawn 2020-8-25
Jonas and Image Analyst
Thanks for the pointer to inpolygon(). That solved my problem and was resonably fast sorting through 7.8 million records, taking only a few seconds.

类别

Help CenterFile Exchange 中查找有关 Geographic Plots 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by