1

I have a table in azure databricks called prod.locations that I am connecting to in ArcGIS Pro through an OLE DB Connection\Microsoft OLE DB Provider for ODBC Drivers. This table has a column called geometry_wkb and another called geometry that look like this in table view in ArcGIS Pro:

enter image description here

This is how the same columns look when I query them in databricks directly:

enter image description here

In this particular table there are about 200k records, but there are other tables with more that I would like to do a similar exercise with.

I'd like to be able to turn this table into a line feature class, and hopefully do this on a regular basis to always have fresh spatial data.

I've come across the FromWKB ArcPy function, but I am having a hard time finding examples I can effectively backwards logic for my data given my novice ArcPy knowledge. I also get the feeling that FromWKB is just one part of the process and won't create or insert all the records iteratively.

How/what should I be doing to reach my desired output?

3
  • 2
    First off, do you want to convert the WKB (binary data) or WKT (ASCII)? (The geometry column shows as WKT.) OLE/ODBC doesn't permit geometry, but a Direct Connect connection might (natively). Converting is as simple as creating a correct SpatialReference (parameter to arcpy.FromWKB or arcpy.FromWKT), then using an arcpy.da.InsertCursor to populate all columns in the target feature class.
    – Vince
    Aug 13, 2022 at 0:32
  • I'll convert whichever one is the "easiest"-- would that be WKT since I can see the geometry column in arc through the current connection? Would you be able to show how to set that up? I have never used arcpy.da.InsertCursor either.
    – fries
    Aug 15, 2022 at 13:38
  • Just because you see it as WKT doesn't mean it is. If ArcGIS sees it as geometry, you can just use FeatureClassToFeaturecClass to copy the table. Learning to use a DA InsertCursor is way less than an hour's effort (and the documentation has multiple examples). Give it a try before asking for help.
    – Vince
    Aug 15, 2022 at 13:48

1 Answer 1

0

First you will need a feature class to store the table from Azure's geometry.

https://pro.arcgis.com/en/pro-app/latest/tool-reference/data-management/create-feature-class.htm

You'll also need some cursor to iterate over you table. I don't know if you are using something like pyodbc. I would get the geometry column values in a list.

Then you can use an insertcursor on the newly created feature class.

with arcpy.da.InsertCursor("new feature class",["SHAPE@"]) as ic:
    for wkt in data_table_geometry_list:
        geom = arcpy.FromWKT(wkt,spatial_reference_object)
        ic.insertRow([geom])

Relevant links: https://pro.arcgis.com/en/pro-app/latest/arcpy/functions/fromwkt.htm https://pro.arcgis.com/en/pro-app/2.8/arcpy/data-access/insertcursor-class.htm https://pro.arcgis.com/en/pro-app/latest/arcpy/classes/spatialreference.htm

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.