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?
Unfortunately no. Shapely is basically an extension of GEOS, which does not offer any affine transformation abilities. If you are wondering if "how is this done in PostGIS?", they have this capability in liblwgeom, which is a general lightweight geometry function library (DB independent).
The most direct way to rotate (x,y) coordinates is to dig into the mathematics a bit, and use
As of Shapely version 1.2.17 there is an affinity module to do just this.
|show 1 more comment|
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)
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
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.