필터 지우기
필터 지우기

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.

조회 수: 9 (최근 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
Venkata Ram Prasad Vanguri 2022년 10월 28일
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

카테고리

Help CenterFile Exchange에서 Data Import and Export에 대해 자세히 알아보기

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by