I have three lat/lon points, I need to use those in order to create a range of all possible points within the polygon that the first three create.
Test every lat/lon if it matches a condition I have (if that point creates an angle of between 50 – 150 deg with the first two points, or not).
I have my code for the condition ready.
lons = [run.gdt1[1], run.gdt2[1], run.target_area[1]]
lats = [run.gdt1[0], run.gdt2[0], run.target_area[0]]
min_lat = min(lats)
max_lat = max(lats)
self.list_a = list(arange(min_lat, max_lat, 0.01))
min_lon = min(lons)
max_lon = max(lons)
self.list_b = list(arange(min_lon, max_lon, 0.01))
if len(self.list_a) < len(self.list_b):
self.list_b = self.list_b[: len(self.list_a)]
elif len(self.list_a) > len(self.list_b):
self.list_a = self.list_a[: len(self.list_b)]
self.lat_lon_list = tuple(zip(self.list_a, self.list_b))
return self.lat_lon_list
What I tried to do is to create a range between the three points and check my condition (happens on another method) on every point in the new list.
My output was:
I realized my problem is that using the min/max to create the list, creates a list only between those two points (which I don't really understand because I figured that if a point is in the range of the other two it will create a polygon of the points).
So, how can I create a list that consists of all the points that lay between those three points? (I'm using jumps of 0.1, but if too many points will return it can be narrowed down)
My desired output is a list of all points in this triangle (gdt1
, gdt2
, target_area
are lat/lon.
Best Answer
If I wanted to generate a set of points spaced equally within the polygon, here's how I would do it using shapely (based off of this answer):
For example, if you have three points at long/lat of
(1, 5)
,(2, 8)
, and(1, 8)
and usespacing=0.1
:gives
(if you wanted, you could use numpy.round_ to prevent the annoying floating point stuff)