I would like to create a mask (using poly2mask) to apply to a geotiff image, based on a single polygon in shapefile .shp format.
I have put together simple code below but evidently I have something wrong with syntax (maybe even just totally improper usage) of the worldtoIntrinsic part.
I have searched help avenues, but haven't cracked it.
Error message: (An issue with the structure of R, that I am returning by geotiffread?)
Undefined function 'worldToIntrinsic' for input arguments of type 'map.rasterref.GeographicPostingsReference'. Error in polygon_shapefileread_example (line 15) [ix, iy] = worldToIntrinsic(R,rx,ry);
Attached are the small geotiff and shapefile.
Many thanks for any help, Matt
[I R] = geotiffread('geotiff_example.tif');
roi = shaperead('shapefile_example.shp');
rx = roi.X(1:end-1);
ry = roi.Y(1:end-1);
[ix, iy] = worldToIntrinsic(R,rx,ry);
mask = poly2mask(ix,iy,R.RasterSize(1),R.RasterSize(2));