SpatialReference of MPK using Pthon Script with ArcGIS Runtime SDK java 10.1.1

3330
5
11-11-2013 01:19 AM
RavindraSingh
Occasional Contributor
Hi All Folks,

I want to get the spatial Reference of 'MPK' file using python.
My Python code is as follows::
mpk = arcpy.mapping.MapDocument("c:\myMpks\world.mpk")
dataFrames = arcpy.mapping.ListDataFrames(mpk)
myCRS = frame.spatialReference.name

the above code is working fine when I run the python script in ArcMap10.1.

But when I Run this by creating gpk, and run then its gives ServerException and my gpk gets currupted.

I would like to confirm followings::
     
     
  • Is arcpy.mapping.MapDocument() supported in ArcGIS Runtime SDK?
  •  
     
  • If above is supported then, how to achieve the result?
  •  
     
  • If above is not supported then, what could be the alternative?
  •  
your suggestions are welcomed.

--
Ravindra Shekhawat.
0 Kudos
5 Replies
EricBader
Occasional Contributor III
Question: How did you create your .gpk? I assume you shared your GP result from Desktop.
If so, on the Geoprocessing Package dialog, did you make sure that the Support ArcGIS Runtime option was checked?
0 Kudos
EliseAcheson1
Occasional Contributor
Could you expand on your workflow?
I'm wondering why you are trying to access the mpk info via a geoprocessing package.

As an alternative I would suggest spinning up a map service via creating a local dynamic layer from the mpk, then you can get the spatial reference of the map service. For example:

ArcGISLocalDynamicMapServiceLayer serviceLayer = new ArcGISLocalDynamicMapServiceLayer("c:\\USCitiesStates.mpk");
serviceLayer.addLayerInitializeCompleteListener(new LayerInitializeCompleteListener() {
      
  @Override
  public void layerInitializeComplete(LayerInitializeCompleteEvent e) {
    SpatialReference spRef = ((ArcGISLocalDynamicMapServiceLayer)e.getSource()).getDefaultSpatialReference();
    System.out.println(spRef) ;       
  }
});
serviceLayer.initializeAsync();
0 Kudos
RavindraSingh
Occasional Contributor
Question: How did you create your .gpk? I assume you shared your GP result from Desktop.
If so, on the Geoprocessing Package dialog, did you make sure that the Support ArcGIS Runtime option was checked?


Hi Eric Bader,

Yes, Support ArcGIS Runtime option was checked.
0 Kudos
RavindraSingh
Occasional Contributor
Hi Elise Acheson,

This way I am able to get the CRS. But Lets say if i have to add multiple MPKs in my Project, then the response of ArcGISRuntime server is not good. so tp overcome this problem. I am thinking to create a single gpk service and this same service will be used for getting the CRS of any mpk, the only thing is, you have to give the path of that mpk.

if i remove following code from python:
mpk = arcpy.mapping.MapDocument("c:\myMpks\world.mpk")
dataFrames = arcpy.mapping.ListDataFrames(mpk)
myCRS = frame.spatialReference.name

then the gpk service works perfect (It doesnot get crashed.)
0 Kudos
SachinKanaujia
Occasional Contributor III
Your first test should be on an mxd to see if it works at all !!!
0 Kudos