I already have a georeferenced base map loaded in ArcMap. I want to find the spatial reference of this map and assign the same coordinate system to a polygon that I created. I can not get a start with the code as I am a beginner.
2 Answers
Assuming you're creating an ArcMap Add-in:
Dim pApp as IMXapplication = CType(My.ArcMap.Application, ESRI.ArcGIS.ArcMapUI.IMxApplication)
Dim pDoc As IMxDocument = pApp.Document
Dim pMap as IMap = pDoc.FocusMap ' document may contain many maps, this is the acive one'
Dim pSR as ISpatialReference = pMap.SpatialReference
This is the chain from My.ArcMap.Application
to the current maps' spatial reference.
Try taking a look at these places:
http://help.arcgis.com/en/sdk/10.0/arcobjects_net/componenthelp/index.html#//00490000003t000000
http://forums.esri.com/Thread.asp?c=159&f=1707&t=232161
This is assuming you're meaning a spatial reference from a layer you put in as a basemap. If you are using an ArcGIS basemap from ESRI, the spatial reference is usually Web Mercator but double check it in a new project's data frame.
-
Your links are related to the dataset not the data frame (IMap). Commented Jun 25, 2014 at 18:55
-
Yes... Judging from the wording of the question, I would guess they are talking about matching to the basemap and not the data frame. Like matching the polygon to the existing basemap's SR system.– BrancoCommented Jun 25, 2014 at 18:58
-
Answers consisting solely of links to other sites are generally discouraged. You should try to at least summarize if not quote the information in the links, or give some general context about the information found there.– Chris WCommented Jun 25, 2014 at 22:01
Dim SpatialReference As ISpatialReference
Now I dont know how to return the result from it. Can you please complete the code to know the spatial reference?