Developers Knowledge Base

Read articles and post questions in this comprehensive developer community and support forum.
Showing results for 
Search instead for 
Do you mean 

Coordinate Reference System Identifiers

by Technical Evangelist on ‎06-20-2016 01:43 PM (1,237 Views)


How do I determine the EPSG Code or WKT for the Coordinate Reference System Identifier of an incoming Raster, Feature, or PointCloud data stream in my operator?


The great thing about coordinate reference system (CRS) identifier standards is that there are so many to choose from :-(


The Spatial Modeler supports an IMAGINE.CoordinateReferenceSystemID data type meant to be able to hold an identier for a CRS no matter its source. The data type holds the designation of the authority for the identification system as well as the specific authority-based identifier for the CRS at hand, referred to as the code.


The Spatial Modeler currently supports four authorities, though more can be added in the future:


EPRJ IMAGINE's coding system based on .plb content
EPSG A coded system defined by the International Association of Oil & Gas Producers
GeoKey Moniker A coded system compatible with GeoTIFF GeoKeys


The Spatial Modeler attempts to retain the native form of the CRS identifier throughout a model's execution. If you are building an operator and need to get at the CRS identifier in a specific form, however, you can use the Construct CRS ID operator internally to translate from one authority to another (if such a translation is possible). The source code for this would look something like the following:



#include <sbgeospatiallib/CoordinateReferenceSystemID.h>
#include <sbrasterlib/RasterInfo.h>

using namespace HexGeo::SpatialModeler;
using namespace HexGeo::SpatialModelerGeospatial;
using namespace HexGeo::SpatialModelerRaster;

// Get the CRS ID from the data stream
// Below we illustrate obtaining the CRS from an incoming Raster
// data stream. Similar actions for Feature, PointCloud would look
// like
// Feature: featureInputPort->GetDataPtr<FeatureInfoData>()->GetCoordinateReferenceSystemID()
// PointCloud: pointCloudInputPort->GetDataPtr<PointCloudInfoData>()->GetCoordinateReferenceSystemId()
CoordinateReferenceSystemIDPtr crsID(new CoordinateReferenceSystemID(rasterInputPort->GetDataPtr<RasterInfoData>()->GetMapBoundary()->GetCRS()));

// Use the crsid operator to translate the authority
OperatorPtr crsidOp(OperatorFactory::Create(L"IMAGINE", L"ConstructCRSID"));
CoordinateReferenceSystemIDPtr xlatedCrsId;
xlatedCrsId = crsidOp->GetPort(L"CRS")->GetDataPtr<CoordinateReferenceSystemIDData>();
catch (...)
// Unfortunately the v16.00 behavior of the operator is that if you
// supply an authority and the CRS ID cannot be translated to that
// authority it is treated as an exception
// This will be remedied in a future release
if (xlatedCrsId)
std::wstring EPSGCode(xlatedCrsId->GetCode());
std::wcout << L"EPSG Code is " << EPSGCode;