POST
|
couldn't you just call pPoint.Project(pMxApp.Display.DisplayTransformation.SpatialReference) ? Thank you. This turned out to by the answer I was looking for. I can project the point to the maps spatial reference so I don't need a coordinate system so I don't need a factory code so I don't need a PRJ. Lots of thing I no longer need. So far so good in my limited testing. Thanks again -Mark
... View more
08-30-2012
09:34 AM
|
0
|
0
|
245
|
POST
|
We have a bounding polygon in WGS 84 coordinates that we need to draw on the map. The users map data could be anything. The following code works in ArcMAP 10.0 (and prior) but does not work in 10.1 if the factory code is zero. Unfortunately a lot of shape files our customers use seem to have valid projection files but no factory codes. They show up in the dataframe properties a "custom" coordinate systems. In 10.1 is there anyway to create a coordinate system if you have a spatial reference but no factory code? Or be able to convert a WGS84 point to a "custom" coordinate? Perhaps I should ask the high level generic question as well. How can I convert a WGS84 coordinate into the maps coordinate system which can be anything ArcMAP supports. Thanks -Mark Public Function ConvertToMap(ByVal lat As Double, ByVal lon As Double, ByVal elev As Double, ByVal layer As ILayer) As IPoint 'Convert x and y to map units. m_pApp is set in ICommand_OnCreate. Dim pMxApp As IMxApplication Dim mapPoint As IPoint Dim pPoint As Point ' = m_mapPoint Dim sMessage As String = "" pMxApp = m_pApp mapPoint = pMxApp.Display.DisplayTransformation.ToMapPoint(0, 0) Dim pSpatialRefFactory As ISpatialReferenceFactory pSpatialRefFactory = New SpatialReferenceEnvironment Dim pGeographicCoordinateSystem As IGeographicCoordinateSystem pGeographicCoordinateSystem = pSpatialRefFactory.CreateGeographicCoordinateSystem(esriSRGeoCS_WGS1984) pPoint = mapPoint ' Set the Spacial Ref. to WGS 84 pPoint.Project(pGeographicCoordinateSystem) pPoint.X = lon pPoint.Y = lat Dim code As Integer Dim pProjectedCoordinateSystem As IProjectedCoordinateSystem code = pMxApp.Display.DisplayTransformation.SpatialReference.FactoryCode() ' Dont' know if map is in Geographic or Projected coordinate system so try both. Try pProjectedCoordinateSystem = pSpatialRefFactory.CreateProjectedCoordinateSystem(code) pPoint.Project(pProjectedCoordinateSystem) Catch ex As Exception pGeographicCoordinateSystem = pSpatialRefFactory.CreateGeographicCoordinateSystem(code) pPoint.Project(pGeographicCoordinateSystem) End Try Return pPoint End Function
... View more
08-29-2012
12:06 PM
|
0
|
2
|
662
|
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:23 AM
|