Any idea how to extract the centerline of the following polygon (Fig1) using PostGIS functions or Python modules? I was trying Voronoi Function but thats not helpful for this kind of shape. I want something like Fig2 blackline.
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
This may be a wrong tool for you, but you can do it simply with OpenJUMP and Skeletonizer plugin. Plugin can be downloaded from http://sourceforge.net/projects/jump-pilot/files/OpenJUMP_plugins/More%20Plugins/JUMP%20Skeletonizer%20Plugin/
Zip file contains a good manual. Plugin is meant for streams and water bodies but your polygon mimics a stream to me.
This is your polygon as I digitized it. Notice vertices in the center lines of inputs/outlets.
Entry points digitized on a separate layer. Points must snap to vertices on the polygon boundary.
Use the Skeletonizer tools and fill in the fields
Get the result
If your polygon is raster, digitize it.
Once your polygon is really a polygon :), a first solution lies, like @WhiteboxDev said, it's the straight skeleton, but it has the problem that, besides the centerline you want, it also returns a lot of segments radiating from that line to the border of your polygon. But if you have PostGIS 2.2+, you can use
ST_ApproximateMedialAxis() instead, which is what you want.