Author Topic: Blanking values outside of multiple polygons  (Read 347 times)

Dan Ruscitto

  • Professor
  • ****
  • Posts: 55
Blanking values outside of multiple polygons
« on: October 17, 2016, 08:02:59 am »
FYI -
I've found this feature useful for map analyses -- if you set up your digitized.bln file correctly, you can extract and average results from multiple polygons:

http://www.goldensoftware.com/knowledge-base/surfer/999-i-want-to-blank-outside-several-polygons-on-a-map-but-the-entire-map-gets-blanked-resulting-in-a-horizontal-planar-grid

-Dan

mark_edwards

  • Student
  • *
  • Posts: 2
Re: Blanking values outside of multiple polygons
« Reply #1 on: September 10, 2017, 06:15:13 pm »
Hi Dan,

Thanks for sharing this link, very useful. I have a quick question as I attempt to get my .bln to cooperate with Surfer: do you end up with average values for each separate polygon, or does this generate an average value for all polygons?

-Mark

EDIT: As a follow-up, my goal was to extract a large number (~70) of polygon averages from a single map -- the polygons correspond to LA-ICP-MS spots. I wound up writing a Matlab script to calculate averages from the CalcImage quantified data file given previously calculated polygon outlines. If anyone would like to use the Matlab script, I'm happy to send it along. It's certainly not the most elegant code, but it gets the job done!
« Last Edit: September 11, 2017, 12:17:34 am by mark_edwards »

Dan Ruscitto

  • Professor
  • ****
  • Posts: 55
Re: Blanking values outside of multiple polygons
« Reply #2 on: September 11, 2017, 08:12:59 am »
Hi Mark-
With the way the script is set up now, you end up for an average for all polygons. Which was okay for what I was using it for. I'd love to see the MATLAB script if you don't mind sharing!
-Dan

mark_edwards

  • Student
  • *
  • Posts: 2
Re: Blanking values outside of multiple polygons
« Reply #3 on: September 11, 2017, 10:47:51 am »
Hi Mark-
With the way the script is set up now, you end up for an average for all polygons. Which was okay for what I was using it for. I'd love to see the MATLAB script if you don't mind sharing!
-Dan

Hi Dan, thanks for confirming -- I thought that might be the case. Here's a link to the Matlab script: https://github.com/m-edwards/EPMA_scripts

I am very new to Matlab, so I am sure this code could be shortened and made more elegant/simple. For now, though, it works! There are three files in the above Github folder. In brief, Circle_appxoximator takes a list of spot centers and diameters, and outputs a .csv file containing points that define a polygon approximating a circle around the center. The test.txt file can be used to test the code. To implement this, I open a map in Surfer, click digitize, and click on all of the centers of spots (which I locate using a photomicrograph imported into Surfer). I then use the X-Y coordinates to build the text file to put into the Circle_approximator script. This is useful for LA-ICP-MS users, but if you are more concerned with compositional zones or regions you won't have a use for this script.

The polygon extractor script then takes a folder containing all of the polygon files, and will extract the composition for each polygon from the quantified .DAT file. All of the results are compiled in a table, and exported to a text file. I did not combine these two operations into one script (i.e., circle approximator + polygon extractor). The polygon input files don't need to be circles -- they could be polygons you build in Surfer, and then save as a .csv file.

If you (or anyone else) wind up using these scripts and streamlining them, I'd be curious to see any modifications. I suspect that given the slight 'clunkiness' of the code, this would take ~an hour to set up to work for your data.
« Last Edit: September 11, 2017, 11:04:36 am by mark_edwards »