I have a Canopy Height Model with detected tree top points. I exported the CHM as a geotiff using maprefpostings. I now want to export the tree top points as a shapefile.

5 次查看(过去 30 天)
Kia ora team,
Here is the code that gives me a georeferenced Canopy Height Model as a geotiff. The code below runs well and is succesfully doing what I need.
gridRes = 0.1;
[Z,xlimits,ylimits] = pc2dem(pointCloud(normalizedPoints), gridRes, CornerFillMethod="max");
R = maprefpostings(xlimits,ylimits,size(Z))
p = readCRS(lasReader);
R.ProjectedCRS = p;
disp(p)
g = p.GeographicCRS
g.Spheroid
[Zcrop,Rcrop] = mapcrop(Z,R,xlimits,ylimits);
data_file = "chm_new_zealand.tif"
epsgCode = 2193
geotiffwrite(data_file, Zcrop, Rcrop, CoordRefSysCode=epsgCode)
wktstring(p, "Format","formatted")
Now, the following is the code from a toolbox that detects the tree tops in the CHM and stores them as Intrinsic coordinates in two separate tables - 'treeTopCollId' and 'treeTopRowId'.
% detect tree tops
[treeTopRowId, treeTopColId] = helperDetectTreeTops(canopyModel, gridRes, minTreeHeight);
% visualize treetops
figure
imagesc(canopyModel)
hold on
plot(treeTopColId, treeTopRowId, "rx", MarkerSize=4)
title("canopyModel with detected tree tops")
axis image
I have been trying to figure out a way to use IntrisictoWorld/IntrinsictoGeographic functions but to no avail so far. Could I somehow export these tree top points and convert them to a 3D Esri Shapefile or maybe even a Geopackage? Would highly appreciate any help or leads!
(PS: I do not like R so really want to figure this in MATLAB!)
Thanks team! :)

回答(1 个)

Venkata Ram Prasad Vanguri
Hi,
Mapping Toolbox supports writing X, Y, Z data to a shapefile.
To convert data to shape file follow below steps:
  1. Convert the row/column indices to X and Y using intrinsicToWorld function
  2. Create column vectors of the X and Y values and with those column vectors, create a mappointshape array
  3. Construct a table with Shape as the variable name for the first column, and add the mappointshape array as the first column
  4. Create a second column with the variable name of Height, convert Zcrop to a column vector, and add these values to the table in Height.
  5. Write geospatial table to a shapefile

产品


版本

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by