Initial implementation of geo.py
This commit is contained in:
		
							parent
							
								
									1d6e2e88c0
								
							
						
					
					
						commit
						9f0d889972
					
				
					 1 changed files with 15 additions and 0 deletions
				
			
		
							
								
								
									
										15
									
								
								lib/xmet/geo.py
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								lib/xmet/geo.py
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,15 @@ | ||||||
|  | import re | ||||||
|  | import shapely | ||||||
|  | 
 | ||||||
|  | def load_poly_from_file(path: str) -> shapely.Polygon: | ||||||
|  |     points = list() | ||||||
|  | 
 | ||||||
|  |     with open(path, 'r') as fh: | ||||||
|  |         data = fh.read() | ||||||
|  | 
 | ||||||
|  |         for line in data.split('\n'): | ||||||
|  |             lat, lon = re.split(', ', line) | ||||||
|  | 
 | ||||||
|  |             points.append((float(lon), float(lat))) | ||||||
|  | 
 | ||||||
|  |     return shapely.Polygon(points) | ||||||
		Loading…
	
	Add table
		
		Reference in a new issue