Thursday, November 4, 2010

Quick Python Script: Cross Section Topography

I wanted to see if it were possible to take a bunch of map measurements and create an SVG file with topographic cross section.  Turns out it is easy to do, once you find the right Python module.

I installed svg.charts, piped my measurements out to a CSV file (x,y) with the first line as a header, and generated a plot of the topography using my script.  I then loaded the topography into Inkscape, trashed the extraneous vectors (e.g., symbology, axes, legend), and scaled to the on-the-map cross section length and appropriately scaled height.  Remember that cross sections must always have the vertical scale be the same as the horizontal scale.

I could continue on and finish the cross section in Inkscape, except I doubt my TAs would approve.  So I printed it out and traced over the topography.  It matched up with the cross section line perfectly.  Hopefully the next time I'll be more efficient at this.

Although, I was considering that I could have avoided hand measurements by scanning the map and doing the following in a GIS:

  • Plot a point on top of each index contour on the cross section line
  • Give each point the appropriate elevation attribute
  • Generate a distance vs. elevation plot using a QGIS script
  • Use my script and scale appropriately using Inkscape
I won't post the script unless I'm asked.  It's really trivial, though.  But perhaps gnuplot would have been a little faster :-)

No comments:

Post a Comment