Select to view content in your preferred language

Add Point Feature to Layer, point in wrong location

1174
3
Jump to solution
06-24-2021 04:07 AM
TimothyReed1
Emerging Contributor

Good morning,

 I've been working at this for a bit and cannot seem to figure out what's going on.  I have a latitude/longitude in decimal degrees that I am trying to add to a feature service from a plugin that I am writing in the Pro SDK.  The resultant point that is created is dropped in the incorrect location (see attachments).  In the Java Runtime, I would just use CoordinateFormatter.fromLatitudeLongitude.

  What did I miss?

ResultResultCodeCode

Thanks,

Tim

0 Kudos
1 Solution

Accepted Solutions
Wolf
by Esri Regular Contributor
Esri Regular Contributor

Gary is correct, you have to change your shape's projection to match the projection of your layer:

var mapPointProjected = GeometryEngine.Instance.Project(newMapPoint, testLayer.GetSpatialReference());

then use mapPointProjected as the shape value in your attr dictionary.

View solution in original post

3 Replies
by Anonymous User
Not applicable

I would suggest anytime that a feature is put in the wrong location, to check the coordinate system.  I have seen many times when working with X, Y data initially the data being rendered in odd locations.  Just about every time the issue is the coordinate system is not correct.

0 Kudos
Wolf
by Esri Regular Contributor
Esri Regular Contributor

Gary is correct, you have to change your shape's projection to match the projection of your layer:

var mapPointProjected = GeometryEngine.Instance.Project(newMapPoint, testLayer.GetSpatialReference());

then use mapPointProjected as the shape value in your attr dictionary.

TimothyReed1
Emerging Contributor

Thanks!  That fixed my problem, I thought specifying the SpatialReference in the CreateMapPoint was good enough.