Clear Filters
Clear Filters

Area of geoclip-ed geopolyshapes

4 views (last 30 days)
Thomas
Thomas on 10 Mar 2023
Answered: Anurag on 22 Nov 2023
I'm trying to find the area of regularly spaced coordinate quads that intersect a country. I have a shape file of country boundaries that I am able to read in as well as latitude/longitude bounding pairs from a climate model grid (e.g. for a single quad in the model grid: latitude =[50.625 52.500] longitude = [0.000 1.875]). I need to find the intersected area between each quad in the model grid and each country.
I can get the country boundaris and quad coordinate data into geopolyshapes and then do the intersection with geoclip, but from there am unable to calculate the area of the clipped geopolyshape, nor can I extract the lat/lon coordinates to do it some other way.
The solutions I've seen focus on reading in shape files using "readgeotables", which I could do for the country boundaries but can't do for the climate model grid coordinates since they are being extracted from netCDF files that contain the data.
In the end, my objective is to calculate the spatially waited average of different climate variables acoss each country.
Any insight or help will be much appreciated. Thanks!

Answers (1)

Anurag
Anurag on 22 Nov 2023
Hi Thomas,
I understand that you need to calculate the weighted average of some variables across the country, which intersects the regularly spaced quadrilaterals.
In order to resolve your issue please refer to the following steps to calculate the weighted average of variables across the country that intersect the regularly spaced quadrilaterals:
  • Read country boundaries from a shapefile using “shaperead”
  • Create a polygon for each quad using “polyshape”
  • Compute the intersection between quad polygons and country polygons using “intersect”
The following code snippet demonstrates how the intersection between quad polygons and country polygons are calculated using the intersect function:
intersectedPolygons = polyshape.empty;
for i = 1:length(countryData)
intersection = intersect(quadPolygon, countryData(i).Geometry);
if ~isempty(intersection)
intersectedPolygons(end+1) = intersection;
end
end
  • Calculate the area of each intersected polygon using “area”
  • Use the areas to compute the spatially weighted average of climate variables across each country.
Please refer to the following MathWorks documentation links for more information on ‘shaperead’, ‘polyshape’, ‘polyshape intersect’ and ‘area’:
Hope this helps!

Products


Release

R2022b

Community Treasure Hunt

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

Start Hunting!