Advertisement
Guest User

Untitled

a guest
Jun 18th, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. tile_index = pd.read_csv('../tile_index.dat', names=['tile', 'x', 'y'], sep=' ')
  2. geometry = [Point(r.x, r.y) for ix, r in tile_index.iterrows()]
  3. tile_index = gp.GeoDataFrame(tile_index, geometry=geometry)
  4. tile_index = tile_index[(tile_index.x.between(-10, 30)) & (tile_index.y.between(-10, 30))]
  5. print tile_index.head()
  6.  
  7. tile x y geometry
  8. 202 226 -9.226 -0.724 POINT (-9.226000000000001 -0.7240000000000001)
  9. 203 227 -9.226 9.276 POINT (-9.226000000000001 9.276)
  10. 204 228 -9.226 19.276 POINT (-9.226000000000001 19.276)
  11. 205 229 -9.226 29.276 POINT (-9.226000000000001 29.276)
  12. 219 243 0.774 -0.724 POINT (0.774 -0.7240000000000001)
  13.  
  14. poly = Polygon([(0, 0), (0, 20), (20, 20), (20, 0)])
  15. P = gp.GeoDataFrame(data=[1, poly]).T
  16. P.columns = ['ID', 'geometry']
  17. print np.any(tile_index.within(P))
  18.  
  19. pt = Point(10.774, 9.276)
  20. p = gp.GeoDataFrame([[1, pt]])
  21. p.columns = ['ID', 'geometry']
  22. print p.within(P)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement