I am trying to create a rotated rectangle in lat/lon coordinates.
Basically, I have the coordinates of the center and rotation angle around the center.
Is it possible to do using, shapely or gdal, or something else?
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It only takes a minute to sign up.Sign up to join this community
affinity module supports affine transformations on any geometry, for example:
from shapely import affinity from shapely.geometry import LineString # Example geometry line = LineString([(1, 3), (1, 1), (4, 1)]) # Rotate 30 degrees CCW from origin at the center of bbox line_rot_center = affinity.rotate(line, 30, 'center') # Rotate from origin at (1, 1) line_rot_11 = affinity.rotate(line, 30, (1, 1))
Sextante has a tool that might work. It is called Transform, under the "Tools for Vector layers". To run the command, define the angle, anchor point, scale factor and translation. Sextante is an extension to gvsig, openjump, udig, others. It also runs from the command-line.
I don't see any features in Python or Shapely to do so but you can do this with JTS (Java Topology Suite) http://tsusiatsoftware.net/jts/main.html (GEOS, the lib used by Shapely is a port of JTS but JTS have more functions)
You can download the soft here http://sourceforge.net/projects/jts-topo-suite/ and launch testbuilder.sh or testbuilder.bat depending on your OS to play for discovering. After you understood, the basics you will have to do the same without GUI but with Java programming only.
http://geoscript.org/ may help you to make the glue beetween python code and java (because one implementation use Jython)
Grass can do it using v.transform.
You can use the gdal python bindings to do affine transformations http://www.gdal.org/ogr/osr_tutorial.html
Since it is built on top of proj/geos/gdal you can do the same things as in shapely + more