Re-project Grid in layout

484
1
Jump to solution
04-19-2021 01:24 AM
PrashantKirpan
Occasional Contributor

Hi,

I have layout which contains dataframe and gird. I've 2 maps with different projection. I'm parsing this layout programmatically and switching maps. While switching maps I want to re-project grid based on map projection. 

I've manually created projected coordinate system object and assign to map grid but new projection not reflecting in grid's coordinate property. 

Here is my sample code :

 

 MapFrame mf = (MapFrame)item;
 CIMMapFrame cimframe = (CIMMapFrame)item.GetDefinition();
if (cimframe.Grids != null)
 foreach (CIMMapGrid grds in cimframe.Grids) 
 {
  SpatialReference sr = mymap.SpatialReference;                                          
  ProjectedCoordinateSystem pcs = new ProjectedCoordinateSystem()
   {
     ..,
     ..,
     LatestWKID = sr.LatestWkid,     
     ..,
    WKID = sr.Wkid
   };
((ArcGIS.Core.CIM.CIMMeasuredGrid)grds).ProjectedCoordinateSystem = pcs;                                        
}

 

 Any help would be appreciated.

-Prashant

0 Kudos
1 Solution

Accepted Solutions
MarkusNoth
New Contributor

Hi Prashant,

As this question is more than 2 years old I think it won't help you anymore, but I've come across the same issue and I was able to resolve it using the WKT property:

var cimMapFrame = mapFrame.GetDefinition() as CIMMapFrame;
var grid = cimMapFrame.Grids.OfType<CIMMeasuredGrid>().FirstOrDefault();
var pcs = new ArcGIS.Core.Internal.CIM.ProjectedCoordinateSystem {
  WKT = spatialReference.Wkt
};
grid.ProjectedCoordinateSystem = pcs;
mapFrame.SetDefinition(cimMapFrame);

I'm not happy to use an undocumented class from ArcGIS.Core.Internal but as far as I could see there is no way around it...

Regards,
Markus

View solution in original post

1 Reply
MarkusNoth
New Contributor

Hi Prashant,

As this question is more than 2 years old I think it won't help you anymore, but I've come across the same issue and I was able to resolve it using the WKT property:

var cimMapFrame = mapFrame.GetDefinition() as CIMMapFrame;
var grid = cimMapFrame.Grids.OfType<CIMMeasuredGrid>().FirstOrDefault();
var pcs = new ArcGIS.Core.Internal.CIM.ProjectedCoordinateSystem {
  WKT = spatialReference.Wkt
};
grid.ProjectedCoordinateSystem = pcs;
mapFrame.SetDefinition(cimMapFrame);

I'm not happy to use an undocumented class from ArcGIS.Core.Internal but as far as I could see there is no way around it...

Regards,
Markus