does anyone know how to extract ONLY the elevation of a country ?
Show older comments
I am capable to use this
however , i would like to have ONLY the elevation of a country and not of the surrounding countries....
e.g. for cameroon ...
I tried to trim the elevation along the border of a country (imported as shapefile) but I am not really successful ...
please help
THX
M
Answers (1)
What you want to do is a zonal statistics, but I don't know how to do it properly in MATLAB (I have some sub-optimal solution though, see below). In ArcGIS, you would enable the extension Spatial Analyst and use a tool called "Zonal Statistics as Table". You would set the zonal feature class to be a polygon feature class of countries (or even select/extract the polygon(s) that correspond to relevant country/ies), set the zonal field to be a field of country codes, and use the raster of elevations as the raster to summarize. The output would provide you with statistics (sum, mean, std, min, max, count, range, etc) of the raster of elevation, per country code (structured as a table).
You can somehow achieve this in MATLAB by converting the polygon feature class of countries into a raster of country codes, with the same resolution as the raster of elevation. You also build a raster of pixels uniformly equal to 1 with the same resolution. Then you use ACCUMARRAY to obtain sums of elevations and sums of 1's for each country code. These allow you to compute an average elevation for each country. You can shorten the computation time by selecting only pixels from the raster of elevation that correspond to pixels with the relevant country code in the raster of country codes.
Assuming you had the raster of country codes available as a numeric array, the raster of elevations available as a numeric array.. if the code corresponding to the country you are interested in were 147, you could do something like
mask = codesRaster == 147 ;
elevations = elevationsRaster(mask) ;
You would then have all elevation values that correspond the country 147 and you could perform any count/stat/other based on them.
Categories
Find more on Vector Data in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!