ThinkGeo.com    |     Documentation    |     Premium Support

ProjectionConverter failing on certain projections

I am using ArcGISServerRestLayer to load https://sampleserver6.arcgisonline.com/arcgis/rest/services/CommercialDamageAssessment/MapServer as an image on my map.
Uri - https://sampleserver6.arcgisonline.com/arcgis/rest/services/CommercialDamageAssessment/MapServer/export

Params:
imageSR - 4326
bboxSR - 4326
format - Png32
layers - show:0
transparent - true

It shows up fine on the map, but I want to be able to zoom to the layer’s extent. To do this, I subclassed the layer and I keep track of the layer’s original extent + spatial reference.
According to the url, that info is:
XMin: -1.3600354970999997E7
YMin: -3.2737046408942908E7
XMax: 1.4931975595786437E7
YMax: 9556749.855657622
Spatial Reference: PROJCS[“NAD_1983_HARN_StatePlane_Illinois_East_FIPS_1201”,GEOGCS[“GCS_North_American_1983_HARN”,DATUM[“D_North_American_1983_HARN”,SPHEROID[“GRS_1980”,6378137.0,298.257222101]],PRIMEM[“Greenwich”,0.0],UNIT[“Degree”,0.0174532925199433]],PROJECTION[“Transverse_Mercator”],PARAMETER[“False_Easting”,984250.0],PARAMETER[“False_Northing”,0.0],PARAMETER[“Central_Meridian”,-88.33333333333333],PARAMETER[“Scale_Factor”,0.999975],PARAMETER[“Latitude_Of_Origin”,36.66666666666666],UNIT[“Foot_US”,0.3048006096012192]]

I override HasBoundingBox and GetBoundingBoxCore(). In GetBoundingBoxCore(), I am making a new converter: new ProjectionConverter(_originalLayerProjection, _currentMapProjection);
where _originalLayerProjection is the wkt string above, and _currentMapProjection is just new Projection(4326);

Then I do a converter.Open(), but it fails with ‘System.ArgumentException’ in ThinkGeo.Core.dll.
Here are the important properties of the converter when .Open() is called:

Does that mean it isn’t possible to convert between the two?

Hi Dan,

ProjectionConverter expects Proj projection strings, not WKT. For WKT input, please convert it to Proj first:

  var sourceProj4 = Projection.ConvertWktToProjString(wkt);
  var converter = new ProjectionConverter(sourceProj4, 4326);
  converter.Open();

We verified your Illinois HARN StatePlane WKT works correctly with this approach.

In the latest build (v15.0.0-beta051), we also improved ProjectionConverter to detect WKT input earlier and throw a clearer exception that points users to Projection.ConvertWktToProjString instead of the lower-level PROJ error.

Thanks,
Ben

1 Like

Yup that was it. Thank you!

You are always welcome!