I got tasked with taking some data from a completely unrelated system and putting it into our SQL Server database for use with our ArcGIS server, and I can't for the life of me figure out how to create, use, manipulate, convert, etc SDEBINARY data.
There are tables which contain the xminx, xmaxx, etc entries and then have a 'points' column which shows a bunch of hex data and I can only assume it's the geometry of the shape or point. From what I can tell, it's SDEBINARY data but I could be wrong.
How can I convert my lat/long pairs to this SDEBINARY?
Also, how can I convert it back from SDEBINARY to something readable?
Thanks,
Sanders
I have access to their entire production database, so I have all three tables.
I must admit, I am confused by this last response. If the three tables exist in a production database, it is likely the production database is a geodatabase, right? It would be highly unusual to have 3 geodatabase-type of tables sitting an a database that isn't a geodatabase. Is the production database a geodatabase? If not, do you have any idea how/why 3 tables that are specific to a geodatabase are residing in a non-geodatabase?
Hi Matthew,
From what I understand, you have lat/lon fields in a non-Esri table that come from another system. You want a method of adding the records as point features into an existing SDEBINARY feature class stored in an enterprise geodatabase using either SQL or Python?
For that, you could always create an on-the-fly SHAPE field within a view of the original tabular data and use a built-in SQL function for its definition, such as STPointFromText (geography Data Type) | Microsoft Docs. From Python (ArcPy site package), reference the view as an input layer and Append—Help | ArcGIS Desktop (Python example at the bottom of the page) into the SDE Binary data. In that case, you won't have to reverse engineer the Binary storage and will still be within Esri best practices.
Please let me know if this is what you're looking for.
I think what the OP has is a dump of either one or more database tables (I asked which tables earlier and haven't heard back yet) that make up a SDEBINARY feature class. Since his spatial data appears to be SDEBINARY, SQL Server tools like STPointFromText won't know how to work with it because the SQL Server tools are expecting WKT/WKB. It seems a feature class wasn't exported using Esri tools but one of the tables that make up a feature class was dumped using database tools.
If there was a simple way to convert SDEBINARY (not fully intact feature classes, just raw SDEBINARY data) to WKB, that would be the way to go, I think. Since the SDE command line tools have been retired, I am struggling to think of what options are available.
You're absolutely right that STPointFromText won't work converting SDEBINARY to other formats, however, I think OP has a few issues merged into that one question. His final being, "How can I convert my lat/long pairs to this SDEBINARY?"
Simply getting lat/lon pairs into SDEBINARY is the easy part, but once it's in there, I don't know of a way to quickly translate that type back out to lat/lon (or WKB for that matter) completely within SQL, if that's what OP means by "readable". Other than constantly recalculating geometry on new columns within the feature class, since SDEBINARY is a proprietary spatial type, I can't think of a way to do it easily.
Jay Strahan wrote:
Simply getting lat/lon pairs into SDEBINARY is the easy part,
How would I go about doing this?
You are correct though: I have a non-Esri table that uses lat/long pairs to store geodata (points, and lines). My main goal is to take that table and add its entries into a customer's database which is used with ArcGIS. The customer's database has 3 tables (base(?), f, and s). I'm taking my data and inserting it accordingly, but the customer's F table uses SDEBinary instead of lat/longs. I'm struggling with finding an easy way to convert my lat/longs into SDEBinary.
Eventually I'll want to be able to transform them back from SDEBinary, but that can wait.
How do you suggest I convert lat/long to SDEBinary?
If you're looking for a way to do this without using Esri software to convert, I don't think it's possible. If you are open to using multiple steps, then it's more likely. The first issue is that lat/lon fields are not geometry. They're coordinates, probably a number field. We need to get them into a spatial format.
One way to do that is (like Xander Bakker said earlier) to use XY events and make the lat/lon pairs into a point layer. The problem with XY event layers is that they're static (Make XY Event Layer—Help | ArcGIS for Desktop).
Another method, since you're working directly in SQL Server, is to use STPointFromText (geography Data Type) | Microsoft Docs to convert the coordinate pair into points in a view definition, not a physical table, with a shape column. The new column is a true shape and like SDEBINARY, MS Geometry is another kind of spatial type. It can be read and automatically be recognized as points if dragged into ArcMap. It's a little slower to draw since it performs these conversions every time you pan/zoom/redraw, but if you're just looking for a method for a limited number of points, it's not a deal breaker.
Once ArcMap could potentially read the source (originally lat/lon) through its shape column, you can use ArcGIS tools to append the data and map the attribute fields accordingly. Here's where it gets limiting for your use case. Every different spatial type is written differently in its values. You'll need Esri tools to convert between them. Running an Append tool (which can be scripted through ArcPy) will automatically make the conversion between source and destination behind the scenes with client-side processing.
Thanks for all the help. I've since realized I need to bite the bullet and just use ArcPy. It did exactly what I needed it to do, and with much ease (after a steep learning curve!). The downside is that I have modules that do not work with the Python environment used by ArcPy, so I am rewriting some of my existing code.
Thanks again!
Hi JAY!
Right, it sounds like someone had an SDEBINARY feature class in SQL Server then just gave him the base, s and f tables (the f table will have a points column with a hex data).
If that is the case, then there are better methods to send this data to you in the future.
Joshua, thanks for all the help you provided. In the end I realized I just need to use ArcPy. Unfortunately, some of my existing code doesn't work in the Python interpreter supplied by ArcGIS Desktop, and therefor needs rewriting.
Thanks again for not only helping me with the problem, but helping me learn as I dove straight into ArcGIS.