ENVIPointCloudSpatialRef

An ENVIPointCloudSpatialRef object can be created directly, or it can be retrieved though the SPATIALREF property of ENVIPointCloud. If you PRINT this object, all properties are listed, regardless of the spatial reference type.

Example 1

The following example prints spatial reference information from a LAS file:

; Create a headless instance

e = ENVI(/HEADLESS)

 

; Open a las file with spatial reference

file = FILEPATH('DataSample.las', ROOT_DIR=e.ROOT_DIR, $

SUBDIRECTORY = ['data','lidar'])

pointcloudQuery = e.QueryPointCloud(file)

 

; Get and print the spatial reference information

pointcloudSpatialRef = pointcloudQuery.SpatialRef

print, pointcloudSpatialRef

 

; Close the point cloud object

pointcloudQuery.Close

Example 2

The following example opens a LAS file with spatial reference information. It converts the contents to a new coordinate system and writes the converted contents to a LAS file with the new spatial reference information. This example may take several minutes to complete.

; Create a headless instance

e = ENVI(/HEADLESS)

 

originalFile = FILEPATH('DataSample.las', ROOT_DIR=e.ROOT_DIR, $

SUBDIRECTORY = ['data','lidar'])

pointcloudQuery = e.QueryPointCloud(originalFile)

 

; The original (source) coordinate system for the DataSample is EPSG code 32633(UTM, WGS84, Meters, Zone 33N)

sourceSpatialRef = pointcloudQuery.SPATIALREF

 

; The new (target) coordinate system is Lat Long EPSG code 4326

targetSpatialRef = ENVIPointCloudSpatialRef(COORD_SYS_CODE = 4326)

File_Mkdir, 'C:\lidar\CreatedLasFiles'

 

; Create file to write and embed the new coordinate system

reprojectedFile = 'C:\lidar\CreatedLasFiles\DataSampleLatLong.las'

writer = ENVIPointCloud(reprojectedFile, SPATIALREF=targetSpatialRef)

 

; Iterate through the original file and reproject and write 100,000 points at a time to the new file

nPoints = pointcloudQuery.NPOINTS

index = 0UL

blocksize = 100000 ; 100,000 points at a time

while (index lt nPoints) do begin

originalPoints = pointcloudQuery.GetPointsInRange(index, blocksize, ALL_ATTRIBUTES=allAttributes)

 

; Reproject the original points to lat/lon coordinate system

sourceSpatialRef.ConvertMapToLonLat, originalPoints, reprojectedPoints

 

; Write block of reprojected points to file along with all point attributes

writer.WritePoints, reprojectedPoints, ALL_ATTRIBUTES=allAttributes

index += blocksize

endwhile

 

; Save the file

writer.Save

print, 'Reprojected file written to ', reprojectedFile

 

; Close the point cloud object

pointcloudQuery.Close

 

Methods

ConvertLonLatToMap

ConvertMapToLonLat

ConvertMapToMap

Dehydrate

Hydrate

Properties

COORD_SYS_CODE (Init,Get)

An unsigned long integer containing a geographic (GEOGCS) or projected (PROJCS) coordinate system code (EPSG code).

If this property and GEOCENTRIC are 0 and COORD_SYS_STR is an empty string, then the ENVIPointCloudSpatialRef object represents an arbitrary coordinate system (the geographic location and projection is unknown).

If COORD_SYS_STR and COORD_SYS_CODE are both set in the call to ENVIPointCloudSpatialRef, the COORD_SYS_STR takes precedence and the COORD_SYS_CODE value is set to 0.

COORD_SYS_STR (Init, Get)

A string containing a geographic (GEOGCS) or projected (PROJCS) coordinate system string (Well Known Text or WKT string)

If this string is empty and COORD_SYS_CODE is 0, then the ENVIPointCloudSpatialRef represents an arbitrary coordinate system (the geographic location and projection is unknown).

GEOCENTRIC (Init, Get)

A boolean value that specifies if the coordinate system is Geocentric.

UNITS (Init, Get)

A scalar string that specifies the units of the coordinate system. Valid values are:

Units must be set if the coordinate system is arbitrary. If COORD_SYS_STR is set then UNITS are ignored as the string already contains the units.

If the coordinate system is geographic then units must be set to specify the vertical units.

Version History

ENVI 5.3

Introduced

ENVI 5.3.2 Added Dehydrate method

ENVI 5.4

Added Hydrate method

API Version

4.2

See Also

ENVIPointCloud