title: What is the proper procedure for using MATLAB's poly2mask() with a shapefile?
body: <p>I have a shapefile (example <a href="http://sharesend.com/3w10t46i" rel="nofollow">here</a>) which I would like to convert to a binary region of interest (ROI) mask using MATLAB's <a href="http://www.mathworks.com/help/images/ref/poly2mask.html" rel="nofollow">poly2mask()</a>.</p>
  
  <p>MATLAB's description is as follows:</p>
  
  <pre><code>BW = poly2mask(x, y, m, n)
  </code></pre>
  
  <blockquote>
    <p>BW = poly2mask(x, y, m, n) computes a binary region of interest (ROI)
    mask, BW, from an ROI polygon, represented by the vectors x and y. The
    size of BW is m-by-n. poly2mask sets pixels in BW that are inside the
    polygon (X,Y) to 1 and sets pixels outside the polygon to 0.</p>
    
    <p>poly2mask closes the polygon automatically if it isn't already closed.</p>
  </blockquote>
  
  <p>This is the script I am using to convert my shapefile:</p>
  
  <pre><code>s = 'D:\path\to\studyArea.shp'
  
  shp = shaperead(s)
  x = [shp.X];
  y = [shp.Y];
  
  % use bounding box to define m and n
  m = shp.BoundingBox(2) - shp.BoundingBox(1)
  n = shp.BoundingBox(3) - shp.BoundingBox(1) 
  
  mask = poly2mask(x,y, m, n)
  </code></pre>
  
  <hr>
  
  <p>Results in the following error:</p>
  
  <blockquote>
    <p>Error using poly2mask Expected input number 1, X, to be finite.</p>
    
    <p>Error in poly2mask (line 49)
    validateattributes(x,{'double'},{'real','vector','finite'},mfilename,'X',1);</p>
    
    <p>Error in createMask (line 11) mask = poly2mask(x,y, m, n)</p>
  </blockquote>
  
  <p>I suspect there may be an issue with UTM coordinates rather than Lat/Long, however, I could use some input from someone who has experience in this.  Where am I going wrong here? </p>