I have a ton of files of orbit paths which each contain a list of 63,000 latitude and longitude coordinates which make up an orbit path like this.
The files are HDF files and contain two lists, one of 63k latitude points and one of 63k longitude points in sequential order. Here is a sample file.
To select the latitude and longitude coordinates use this code:
hdf = SD(FILEPATH, SDC.READ)
lat = hdf.select('Latitude')
lon = hdf.select('Longitude')
I need to be able to filter out these files so that I only have files whose orbit paths intersect the country Greenland.
Currently I'm doing this extremely inefficiently, my solution right now goes through each point of the path of each file and checking if that point falls within Greenland, and if it does I add it to a list of files. This can take hours to do, here's what the code essentially boils down to at the moment.
#poly is a polygon around Greenland.
coords = [(-55, 59.5), (-55,67.5), (-60,67.5), (-60,75), (-73.25,75), (-73.25,79.2),
(-67.5,79.2), (-67.5,80.82), (-65.34,80.82), (-65.34,81.23), (-62,81.23),
(-62,82), (-60.25,82), (-60.25,84), (-10,84), (-10,75), (-17,75), (-17,67.5),
(-30,67.5), (-30,59.5)]
poly = Polygon(coords)
latlon = zip(latitude, longitude)
for index, lalo in enumerate(latlon):
if (poly.contains(Point(lalo[1], lalo[0]))):
greenland_files.append(f)
break
Any ideas?