SHARE
TWEET

Untitled

Caiafa Jan 28th, 2020 69 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # -*- coding: utf-8 -*-
  2. """
  3. Editor Spyder
  4.  
  5. Este é um arquivo de script temporário.
  6. """
  7.  
  8. import geopandas as gp
  9. import matplotlib.pyplot as plt
  10. from shapely.geometry import Point, Polygon
  11.  
  12.  
  13. def extratic_latlon(list):
  14.     area=[(-48,-28), (-48,-22),(-41,-22),(-41,-28)]
  15.     area = Polygon(shell=area)
  16.     target_points=[]
  17.     for coords in list:
  18.         for coord in coords:
  19.             point = Point(coord)
  20.             if area.contains(point):
  21.                 print(point)
  22.                 target_points.append(point)
  23.     return target_points
  24.            
  25.  
  26. def extratic_polygon(multipolygon):
  27.     return list(multipolygon)
  28.    
  29. #Armadilha muito importante ao lidar com shape file,
  30. #todos precisam estar juntos na mesma pasta
  31. brasil = gp.read_file('/home/ladsin/Área de Trabalho/GisPython/Brasil/UFEBRASIL.shp')
  32. coords = []
  33. lat_lon = []
  34. for polygon in brasil.geometry:
  35.     if polygon.type == 'MultiPolygon':
  36.         for i in range(len(polygon)):
  37.             coords.append(polygon[i])
  38.     else:
  39.         coords.append(polygon)
  40. for coord in range(len(coords)):
  41.     lat_lon.append(coords[coord].exterior.coords.xy)
  42. coords = []
  43. for i in lat_lon:
  44.     coords.append(extratic_latlon(i))
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top