Select to view content in your preferred language

Write Point Geometry out to a Feature Service from XML, after DMS to DD Conversion.

1906
10
Jump to solution
01-30-2024 02:10 PM
Labels (1)
Gene_Sipes
Regular Contributor

I am polling an external website for XML data that will then update a hosted feature service with point data for stream gauges. One of the issues with the XML data is that the lat and long are in DMS as strings. To solve this I am using field calculators to extract the degrees, minutes, and second values, convert them to double type values, and perform simple math to convert them to decimal degrees. That all works well. The issue I am having is figuring out how to write those converted latitude and longitude values out to the hosted feature service as geometries. I am curious if the fact that the latitude and longitude values are being calculated on the fly, and so is the geometry, that when I go to build my geometry those calculated latitude and longitude values only exist in memory and are not available to the "toPoint()" function. I have even tried breaking out the latitude, longitude, and geometry calculations to their own field calculator processors, but no luck. It's really hard to explain what issue I am encountering, so I appreciate it if you have read this far, and maybe you have some suggestions? 

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
Gene_Sipes
Regular Contributor

Ok I worked it out. 

I needed to set up my input definition to include the two new fields that I was going to convert my DMS values to DD values to. Then in the geo event service, set up my field calculators to convert the values from DMS to DD and store in those new fields. Finally map them out to my output. Screenshots below for each piece of the pie. Hopefully someone gets something from this in the future! 


XML Feed:
https://hayscounty.wetec.us/WETMap/public/hayswlpublic.xml

Input Definition with new fields highlighted:

Gene_Sipes_0-1707921110650.png

XML Input Connector:

Gene_Sipes_1-1707921183020.png

Hosted feature service output connector, make sure Update only is "NO":

Gene_Sipes_7-1707921753764.png

 

Output Definition, with geometry output:

Gene_Sipes_2-1707921262582.png

Geoevent Service outputs to a hosted feature service, and sends email.

Gene_Sipes_3-1707921359671.png

 

Example Field Calculator that converts the XML DMS string value to a double DD value. 

Gene_Sipes_4-1707921465614.png

In the field mapper, using the DD values for latitude and longitude to construct the geometry. 

Gene_Sipes_5-1707921551317.png

 

Data mapped to hosted feature service. 

Gene_Sipes_6-1707921646774.png

 

 

 

 

 

View solution in original post

0 Kudos
10 Replies
JeffSilberberg
Frequent Contributor

In the Field Calculator Add Mapping - Geometry and in the Arcade use the point() function. 

Replacing my $feature fields with your calculated ones. 

Point({"x":$feature.longitude,"y":$feature.latitude,"spatialReference":{"wkid":4326}})

 

0 Kudos
Gene_Sipes
Regular Contributor

I'll give it a try. Should I just do all of my calculations within a field mapper? That is convert my laititude, longitude, and geometry all from one field mapper processor. Rather than trying to use seperate field calculators for each operation? I have pasted images of my setup below. 


0 Kudos
Gene_Sipes
Regular Contributor

This is what ends up happening. My latitude and longitude correctly convert, but geometry is null. 

Gene_Sipes_0-1706654006536.png

 

0 Kudos
JeffSilberberg
Frequent Contributor

Your arcade expression needs to be something more along the lines of -- 

Where you create two variables to contain the lat/lon in Degrees and then use them in the point() function.

You could sider using convertDirection() or just use the formula you have already locally.

var lat_dd = ConvertDirection($feature.latitude, angleType: DMS, angleType: DEGREES);  //Not Tested
var lon_dd = ConvertDirection($feature.longitude, angleType: DMS, angleType: DEGREES); //Not Tested
return(Point({"x":lat_dd,"y":lon_dd,"spatialReference":{"wkid":4326}}));
 
 
0 Kudos
Gene_Sipes
Regular Contributor

That makes sense, but I am not sure how to write more than one line expressions in the field calculator or the field mapper. 

Gene_Sipes_0-1706802377820.png

 

0 Kudos
JeffSilberberg
Frequent Contributor

 

I either Field Calc or Field Map, click on the Configure Arcade Expression.  Be sure to test/run it after you have it built.

 

JeffSilberberg_0-1706814176847.png

 

0 Kudos
Gene_Sipes
Regular Contributor

Ah man... I gues my version doesn't have that button. I am using 10.9.1 (build 28388). 

From my screenshot you can see it is bare bones. What version do you have?

Gene_Sipes_0-1706815037002.png

 

 

0 Kudos
JeffSilberberg
Frequent Contributor

Sorry, the difference is geoEvent versus Velocity. 

Maybe build the Arcade in NotePad++ and then pater it as a line into that.  

I do not currently have a geoEvent I can access to get the corresponding action.

0 Kudos
Gene_Sipes
Regular Contributor

Yea, no dice. I built the expression in VS Code and pasted into the field mapper for the geometry, but it writes out a null value for geometry.

Gene_Sipes_0-1706887227268.pngGene_Sipes_1-1706887257036.pngGene_Sipes_2-1706887274547.png

Logs are citing that I have invalid field mapping for both my Point function and my variables lat_DD and long_DD

 

Thanks for you help so far. 

 



0 Kudos