Private Sub ProjectShapefile() Try Dim pGApp As IGxApplication = m_application Dim pGxObj As IGxObject = pGApp.SelectedObject Dim pGxDataset As IGxDataset If (TypeOf (pGxObj) Is GxShapefileDataset) = False Then 'If pGxObj.Category <> "Shapefile" Then MsgBox("Make a valid Selection") Exit Sub 'End If End If Dim pSpatRefFact As ISpatialReferenceFactory Dim pPCS As IProjectedCoordinateSystem Dim pSpatialRef As ISpatialReference pSpatRefFact = New SpatialReferenceEnvironment pPCS = pSpatRefFact.CreateProjectedCoordinateSystem(esriSRProjCSType.esriSRProjCS_NAD1983UTM_17N) Dim gxShape As GxShapefileDataset = New GxShapefileDataset gxShape = pGxObj pGxDataset = pGxObj Dim pGeoDataset As IGeoDataset = pGxDataset Dim pGeoDatasetEdit As IGeoDatasetSchemaEdit = gxShape If pGeoDatasetEdit.CanAlterSpatialReference = True Then ' Alter the target layer's spatial reference pGeoDatasetEdit.AlterSpatialReference(pPCS) Else Exit Sub End If ' Get the spatial reference information and export it to a prj file pSpatialRef = pGeoDataset.SpatialReference pGApp.Refresh(pGxObj.Parent.FullName) Catch ex As Exception MsgBox(ex.Message) End Try End Sub
Private Sub ProjShapefile() Dim pGxApp As IGxApplication = m_application Dim pGxObj As IGxObject = pGxApp.SelectedObject If (TypeOf (pGxObj) Is GxShapefileDataset) = False Then MsgBox("Make a valid Selection") Exit Sub End If Dim pGxDataset As IGxDataset = pGxObj Dim pDataset As IDataset = pGxDataset.Dataset Dim pGeoDataset As IGeoDataset = pDataset Dim pSpatRefFact As ISpatialReferenceFactory Dim pPCS As IProjectedCoordinateSystem Dim pSpatialRef As ISpatialReference pSpatRefFact = New SpatialReferenceEnvironment pPCS = pSpatRefFact.CreateProjectedCoordinateSystem(esriSRProjCSType.esriSRProjCS_NAD1983UTM_17N) Dim pGeoDatasetEdit As IGeoDatasetSchemaEdit = pGeoDataset If pGeoDatasetEdit.CanAlterSpatialReference = True Then pGeoDatasetEdit.AlterSpatialReference(pPCS) Else MsgBox("error") Exit Sub End If pGxApp.Refresh(pGxObj.Parent.FullName) End Sub
Les membres connectés peuvent publier, suivre les mises à jour, et plus encore. Nouveau ici ? Inscrivez-vous gratuitement.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.