Select to view content in your preferred language

PROJECTING WGS1984(102100) GEOMETRY TO WKT

611
1
05-22-2023 12:23 PM
ACHANUMA
New Contributor

Hi Friends,

I am trying o project  certain points in wgs84 (wkid: 102100) to a custom projection (wkt shown below) in a WAB widget (running on jsapi 3.27 ) .  FYI, i cannot use a wkid as its a custom projection with modified parameters.

    PROJCS["NAD_1983_UTM_Zone_11N",GEOGCS["GCS_North_American_1983",DATUM["D_North_American_1983",SPHEROID["GRS_1980",6378137.0,298.257222101]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Transverse_Mercator"],PARAMETER["False_Easting",1640416.666666667],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",-117.0],PARAMETER["Scale_Factor",0.9996],PARAMETER["Latitude_Of_Origin",0.0],UNIT["Foot_US",0.3048006096012192]]

 

My Sample Code:

// input SPRS

var inputSRS=new SpatialReference({

            wkid:102100
        });
 
// Output SPRS
var outputSrs = new SpatialReference({"wkt": 'PPROJCS["NAD_1983_UTM_Zone_11N",' +
        'GEOGCS["GCS_North_American_1983",DATUM["D_North_American_1983",' +
        'SPHEROID["GRS_1980",6378137.0,298.257222101]],' +
        'PRIMEM["Greenwich",0.0],' +
        'UNIT["Degree",0.0174532925199433]],PROJECTION["Transverse_Mercator"],' +
        'PARAMETER["False_Easting",1640416.666666667],PARAMETER["False_Northing",0.0],' +
        'PARAMETER["Central_Meridian",-117.0],' +
        'PARAMETER["Scale_Factor",0.9996],'+
        'PARAMETER["Latitude_Of_Origin",0.0],'+
        'UNIT["Foot_US",0.3048006096012192"'
    });
 
 // Projection logic 
 
projection.load().then(lang.hitch(this,function()
        {
       
            var projectedPoints = projection.project(inputPoints, this.outputSrs);
            projectedPoints.forEach(function(point) {
                console.log(point.x, point.y);        
              });
        }));
 
 
I getting the below error msg when the code tried to project the input points. Just wondering of jsapi 3.27 version has a known bug with SPRS that are defined using wkt instead of wkid. 
 
init.js:115 Error: Illegal Argument Exception: Cannot create SpatialReference from text.
at d.F (geometryEngine.js:537:23)
at b.OY (geometryEngine.js:1152:308)
at b.uR (geometryEngine.js:1145:481)
at g.Ao (geometryEngine.js:1145:167)
at d._getTransformation (geometryEngine.js:1276:490)
at p (projection.js:4:417)
at l (projection.js:4:273)
at d.project (projection.js:5:422)
at Object.<anonymous> (Widget.js?wab_dv=2.14:584:46)
at init.js:64:337 'Error: Illegal Argument Exception: Cannot create SpatialReference from text. \n at d.F (https://js.arcgis.com/3.27/esri/geometry/geometryEngine.js:537:23)\n at b.OY (https://js.arcgis.com/3.27/esri/geometry/geometryEngine.js:1152:308)\n at b.uR (https://js.arcgis.com/3.27/esri/geometry/geometryEngine.js:1145:481)\n at g.Ao (https://js.arcgis.com/3.27/esri/geometry/geometryEngine.js:1145:167)\n at d._getTransformation (https://js.arcgis.com/3.27/esri/geometry/geometryEngine.js:1276:490)\n at p (https://js.arcgis.com/3.27/esri/geometry/projection.js:4:417)\n at l (https://js.arcgis.com/3.27/esri/geometry/projection.js:4:273)\n at d.project (https://js.arcgis.com/3.27/esri/geometry/projection.js:5:422)\n at Object.<anonymous> 
 
Your help is appreciated.
A
0 Kudos
1 Reply
UndralBatsukh
Esri Regular Contributor

Seems like you have an issue in the WKT text. The WKT is supported when projecting. For instance, there is two pp here: PPROJCS I removed this and was not able to project it. So I have used this WKT: https://spatialreference.org/ref/epsg/nad83-utm-zone-11n/esriwkt/ and projection happens as expected.

This codepen shows a proof of concept in 4.26. https://codepen.io/U_B_U/pen/RwevmgB?editors=1000

 

0 Kudos