Convert Google Long Lat Strings into line work

1492
5
03-29-2018 07:49 AM
CharlesGerk
New Contributor

We have a third party product for a permitting process that currently allows the applicant to add line work via a GoogleMap application. The line work LAT and LONG data is stored in a table in a single column (one for lat one for long) that is vertical bar delimited. 

Any thoughts on how to process this data into our SDE? I can provide more information, but am lost as how to start this.

 First Latitude
 First Long
 Latitude String
 Longitude String
44.86265251
-93.34430695
 44.862652507372346|44.863808394490455|44.863838812259104|44.862835017407576
 -93.34430694580078|-93.3444356918335|-93.34125995635986|-93.3413028717041

The first lat and long are a point, the strings are the line work.

0 Kudos
5 Replies
ChrisDonohue__GISP
MVP Alum

I have not used ArcGIS Pro, but suspect the process would be similar to ArcGIS Destop.  So be aware there may be some changes in the process particular to ArcGIS Pro that will have to be worked out

Essentially the workflow is this:

1.  Clean up the field names in Excel so they are GIS-compliant 

Formatting a table in Microsoft Excel for use in ArcGIS—Help | ArcGIS for Desktop 

2.  Add a field in Excel to identify which points belong to which segments.

3.  Create a File Geodatabase (FGDB).  Add in a Feature Dataset with the appropriate coordinate system for you output.

4.  Create an XY Event Layer, then save it off as a feature class in the FGDB feature dataset.  The result will be a point feature class.

Add x,y coordinate data as a layer—ArcGIS Pro | ArcGIS Desktop 

- Make sure you choose the appropriate Geographic Coordinate system to match the lat/long data.

- Choose the appropriate Transformation when saving it.

5  Run the Points to Line geoprocessing tool.  I believe one would use the Line Field (optional) setting to choose the field created in Step 2 above so as to keep line segments connected only to related points.

Points To Line—Data Management toolbox | ArcGIS Desktop 

6.  Clean up the linework if needed and double-check the results.

7.  Once it looks good, load into your enterprise geodatabase (SDE).   Note  - specifics will depend on how your SDE is set.  Probably by using a Version, but there are other ways.

Chris Donohue, GISP

0 Kudos
RobertBorchert
Honored Contributor

That's a really horrible third party app for making lines. I would suggest getting into something that is 21st Century.

Contact the company and see if they have an app for converting the collected data into a line.

If not the manual workaround is actually quite simple provided you don't have to do it to many times and each entry has a unique identifier somewhere.

Do you have a more complete example of what the collected table looks like

0 Kudos
ThomasColson
MVP Alum

Since you mention you're using SDE, this is really easy: STGeomFromText (geometry Data Type) | Microsoft Docs 

Do that on a stand-alone table, then import the geography column into a new feature class. For updates, just write a trigger that will pass new geography from your standalone table to the SDE table. 

CharlesGerk
New Contributor

Thank you everyone for the quick responses! I will attempt at some point next week and report back!

Thank you all so much.

0 Kudos
XanderBakker
Esri Esteemed Contributor

To show you a snippet of Python code to translate the lat and lon strings into a polyline, see the example below. I converted the data that you posted into a table in a fgdb to allow easy manipulation:

... and converted the strings into a line:

Code used:

def main():
    import arcpy

    tbl = r'C:\GeoNet\LatLonString\data.gdb\LatLonData'
    fld_lat = 'LatitudeString'
    fld_lon = 'LongitudeString'
    sr = arcpy.SpatialReference(4326) # WGS 1984
    fc_out = r'C:\GeoNet\LatLonString\data.gdb\lines'

    feats = []
    flds = (fld_lat, fld_lon)
    with arcpy.da.SearchCursor(tbl, flds) as curs:
        for row in curs:
            lat_string = row[0]
            lon_string = row[1]
            lst_lat_txt = lat_string.split('|')
            lst_lon_txt = lon_string.split('|')
            if len(lst_lat_txt) == len(lst_lon_txt):
                pnts = []
                for i in range(len(lst_lat_txt)):
                    lat = float(lst_lat_txt[i])
                    lon = float(lst_lon_txt[i])
                    pnt = arcpy.Point(lon, lat)
                    pnts.append(pnt)
                polyline = arcpy.Polyline(arcpy.Array(pnts), sr)
                feats.append(polyline)

    arcpy.CopyFeatures_management(feats, fc_out)

if __name__ == '__main__':
    main()