Advertisement
Guest User

Untitled

a guest
Jun 24th, 2019
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. import shapely.geometry as shpgeo, pyproj
  2.  
  3. lon, lat = (-93.2661, 44.9765)
  4.  
  5. proj = pyproj.Proj(proj="utm", ellps="GRS80", datum="NAD83")
  6.  
  7. # project into UTM to calculate distance in meters
  8. point = shpgeo.Point(*proj(lon, lat))
  9.  
  10. # get a radius 3000 meter circle
  11. bufferShape = point.buffer(3000)
  12.  
  13. # convert from utm back to lon/lat
  14. coords = shp.__geo_interface__['coordinates']
  15. # this works if shp.__geo_interface__['type'] == Polygon
  16. newCoords = [[proj(*point, inverse=inv) for point in linring] for linring in coords]
  17. bufferShape = shpgeo.shape({'type': shpType, 'coordinates': tuple(newCoord)})
  18.  
  19. print(bufferShape.centroid)
  20. print(bufferShape.bounds)
  21.  
  22. POINT (-93.26610002878017 44.97650391330887)
  23. (-93.29303779998378, 44.95738308641549, -93.23916202385492, 44.99562317086678)
  24.  
  25. bufferShape = point.buffer(3000 * 1.41421)
  26.  
  27. POINT (-93.26610005756029 44.97650782661781)
  28. (-93.30419574627818, 44.94946643426645, -93.22800390139928, 45.003546080298214)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement