Trimimg a geotiff by a shapefile

25 views (last 30 days)
Hi,
I am new to mapping toolbox and here the thing I need help: I have a large geotiff file and I like to extract a small area of it (still in a geotiff format) based on a shape file I have access to (I tried 'maptrims' but it requires the 'RasterInterpretation' field of the 'spatial referencing object' to be 'cells' which in my case it is 'postings'). Any idea on how can I achieve this?
Thanks,

Accepted Answer

Chad Greene
Chad Greene on 20 Feb 2017
You can use geoimread to read only the data surrounding your shapefile. Get the xdata and ydata from the shapefile, then use those coordinates with geoimread.
  5 Comments
Reema Alhassan
Reema Alhassan on 10 Jun 2018
Thanks Mohammad !! but do you know if I have a shape file with many polygons how can I clip the image for each polygon ? I mean the x and y coordinates from the shape file for the hole shape but now I need to specify the coordinates if you have an idea of doing this I will be very thankful
Many thanks,
Mohammad Gohardoust
Mohammad Gohardoust on 20 Jun 2018
I'm not sure whether or not you found the answer yet, but if I got the question correctly, multiple polygons in shape files are (usually I believe) separated by a 'NaN'. Using this fact you can put a for loop after reading the shape file data, with nnz(isnan(roi.X))+1 repetitions.

Sign in to comment.

More Answers (0)

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!