Skip to main content

I have JSON files that I am reading and using GeometryFilter to create points. GeometryFilter is looking for the coordinates as long, lat. Some of the points in the JSON input are incorecly entered as lat,long. Is there are way to read the JSON coordinates and switch the coordinates to long, lat if they are incorrectly set to lat,long? For example:

CHANGE FROM

"geometry":{

        "type":"Point",

        "coordinates":o 29.32991754843333 , -82.16997782090549]

TO

"geometry":{

        "type":"Point",

        "coordinates": -82.16997782090549, 29.32991754843333 ]

Thanks,

David

If your data is always in the same general area (and that area is not anywhere near a line running from -90,-90 to 0,0 to 90,90) then yes.

 

After the points are created you can use a CoordinateExtractor to read the coordinate values into attributes, say _x and _y, then a TestFilter to see if they're in the wrong order. Using your values as an example, a test to see if _x is larger than _y should suffice. If they are in the wrong order, you can use a VertexCreator to replace the point with a new one, where you swap the x and y coordinate attributes.


Is your input data always confined to a specific area? My first thought is to create a polygon in which all points should fall into. Use the Clipper to determine which have the correct coordinates, and which don't. Those that don't, create new points with reversed values in a VertexCreator.

 

The fact that they are both have valid coordinates makes it a little more challenging to identify which are incorrect. If the coordinates were 29.3299, -110.1699, it would be easier.🙂


If your data is always in the same general area (and that area is not anywhere near a line running from -90,-90 to 0,0 to 90,90) then yes.

 

After the points are created you can use a CoordinateExtractor to read the coordinate values into attributes, say _x and _y, then a TestFilter to see if they're in the wrong order. Using your values as an example, a test to see if _x is larger than _y should suffice. If they are in the wrong order, you can use a VertexCreator to replace the point with a new one, where you swap the x and y coordinate attributes.

Thank you for your reply. Both responses seem like they could work. I will give them a try.


Is your input data always confined to a specific area? My first thought is to create a polygon in which all points should fall into. Use the Clipper to determine which have the correct coordinates, and which don't. Those that don't, create new points with reversed values in a VertexCreator.

 

The fact that they are both have valid coordinates makes it a little more challenging to identify which are incorrect. If the coordinates were 29.3299, -110.1699, it would be easier.🙂

Thank you for your reply. Both responses seem like they could work. I will give them a try.


Reply