Select to view content in your preferred language

How to convert easting and northing to a point and saved in a feature class in ArcMap

2807
2
07-11-2011 07:13 PM
GarySham
Emerging Contributor
Dear all,

I make a textbox to allow user input easting and northing of a point. After that how I can convert convert the easting and northing to a point and saved in a feature class in ArcMap ?


Regards
Gary
0 Kudos
2 Replies
RuchiraWelikala
Regular Contributor
http://edndoc.esri.com/arcobjects/9.0/samples/tables/create_a_layer_based_on_xy_data.htm

Try playing around with that code.  I personally think it might be easier to take the user input and write it to a text file and then use that text file as XY data.

Cheers
0 Kudos
MichaelRobb
Honored Contributor
Just give  a spatial Reference Environment such as createprojectedCoordinateSystem

Add point to a featurelayer

Get the spatial reference of the featureclass...

pPoint.PutCoords(x,y)  >> values from the entered by the user

then project to the featureclass

pPoint.Project(pSpatialReference)

You can then add attributes / fields to the featureclass...

pFeature.Shape = pPoint
pFeature.Store ()

I do this, but using Local Coordinates, sent to a web-service for conversion... etc.. but you will get the idea.
            'get the spatial information from the shapefile and add the new point with attributes to the point file
            'Need to look at what projection or lat/long of the shapefile where the point is being created.
            Dim pSpatialReferenceWebServices As ESRI.ArcGIS.Geometry.ISpatialReference
            Dim pSpatialReferenceEnvironment As New ESRI.ArcGIS.Geometry.SpatialReferenceEnvironment
            Dim pGeodataset As ESRI.ArcGIS.Geodatabase.IGeoDataset
            Dim pSpatialReference As ESRI.ArcGIS.Geometry.ISpatialReference

            'Spatial Reference passed from Webservies
            pSpatialReferenceWebServices = pSpatialReferenceEnvironment.CreateProjectedCoordinateSystem(pSpatialInt)


            'Add point to selected layer feautre class
            Dim pFeatureClass As ESRI.ArcGIS.Geodatabase.IFeatureClass
            pFeatureClass = pPointLayer.FeatureClass ' runtime will not occur as its in the above if statement checking for selected feature

            'get the projection of the featurelayer
            pGeodataset = pFeatureClass
            pSpatialReference = pGeodataset.SpatialReference


            Dim pPoint As New ESRI.ArcGIS.Geometry.Point
            'give the point the reference from the WkID given from the webservices
            pPoint.SpatialReference = pSpatialReferenceWebServices

            pPoint.PutCoords(pXCoord, pYCoord)

            'now project to the featureclass spatial reference
            pPoint.Project(pSpatialReference)
0 Kudos