Point Coordinates Not Showing Properly in the AGOL Map Viewer

724
4
Jump to solution
04-20-2020 02:19 AM
AldwinGregorio
New Contributor III

Hi, 

I'm loading data from a GeoJSON object in python. I'm sure I am properly assigning my point coordinates in "geometry" key like this: 

and creating a featureSet from the cases dict (GeoJSON)  and load it to my hosted feature layer in AGOL. 

But in my AGOL's map viewer, all points are concentrated in [0,0] coordinates. Checking the service URL, whenever I query the features and return them in HTML or in JSON format, it shows the correct (x,y) geometry. But when I return them in geojson, it shows wrong (x,y) values. Any idea how this is even possible? Thank you! 

JSON:

HTML:

GeoJSON:

0 Kudos
1 Solution

Accepted Solutions
AldwinGregorio
New Contributor III

This works fine now. I just reprojecting the coordinates I'm getting from geocoding addresses. Geocoding returns coords value in 4326 so I just convert those values to 3857 in my code. Thank you Egge-Jan Pollé‌ for the idea.  

from arcgis import geometry
def reproject_coords(coords):
    input_geom = [{'x': coords[0], 'y': coords[1]}]
    result = geometry.project(geometries=input_geom, in_sr=4326, out_sr=3857)
    return [result[0]['x'], result[0]['y']]

View solution in original post

4 Replies
Egge-Jan_Pollé
MVP Regular Contributor

Hi Aldwin Gregorio,

I guess the CRS (Coordinate Reference System) of your featureSet is something like 102100 or 3857 (most probably both), which is Web Mercator, while the CRS of your input data is not...

You can check this by asking for it's spatial_reference like this:

In [28]:
fs.spatial_reference
Out[28]:
{'wkid': 102100, 'latestWkid': 3857}

So, you will have to convert your input data to Web Mercator during the import process.

HTH,

Egge-Jan

0 Kudos
AldwinGregorio
New Contributor III

Hi Egge-Jan Pollé‌, 

Thank you for your reply. I checked the spatial_reference of my featureset and saw that the CRS is in {'wkid': 4326}. So I explicitly changed the CRS by overriding the spatial_reference property of my FeatureSet to {'wkid': 102100, 'latestWkid': 3857}. However, my points are still displayed in the wrong locations. 


I am looking into this module (arcgis.features module — arcgis 1.8.0 documentation ) and trying to look for a function that can convert the spatial reference of my input featureset, but spatial_reference is the only available one from the list. I tried including the datum_transformation when I'm calling the edit_features() but getting this error instead.

Checking the module show me this in the layer.py 
`

Checking the from_geojson method in feature.py show me this. 


Is there an available method/function that will transform my featureset to the 3857

0 Kudos
AldwinGregorio
New Contributor III

This works fine now. I just reprojecting the coordinates I'm getting from geocoding addresses. Geocoding returns coords value in 4326 so I just convert those values to 3857 in my code. Thank you Egge-Jan Pollé‌ for the idea.  

from arcgis import geometry
def reproject_coords(coords):
    input_geom = [{'x': coords[0], 'y': coords[1]}]
    result = geometry.project(geometries=input_geom, in_sr=4326, out_sr=3857)
    return [result[0]['x'], result[0]['y']]
Egge-Jan_Pollé
MVP Regular Contributor

Hi Aldwin Gregorio,

Good to hear that my suggestion was useful and good to see that you managed to get the conversion right 🙂

BR,

Egge-Jan

0 Kudos