Posted Fri, 13 Oct 2023 08:56:41 GMT by Lasse Sørensen
When writing data to the sqlite database outside the MIKE+ software I have problems with writing to table with the geometry columns. There is no issue with writing to other tables like ms_Tab but I can find no documentation for the geometry. What is the format and how to write to e.g. msm_Nodes from for example python.
Posted Mon, 22 Apr 2024 15:12:30 GMT by Mathieu Hellegouarch
Hi, geometry data in the .sqlite database are stored with the SpatiaLite format. Note that a MIKE+Py package is now available for editing the MIKE+ database using Python, which will probably be helpful: DHI/mikepluspy: MIKE+Py is the official python interface for MIKE+ (github.com) [https://github.com/DHI/mikepluspy]
Posted Tue, 23 Apr 2024 06:21:03 GMT by Lasse Sørensen
Thanks for the reply, I'll look into mikepluspy. If others run into the same issue with using spatialite, I did the following: # Connect to SQLite and load SpatiaLite con = sqlite3.connect(file_sqlite) con.enable_load_extension(True) con.execute('SELECT load_extension("mod_spatialite")') # Read table content into a pandas DataFrame query = "SELECT *, AsText(geometry) AS wkt_geometry FROM msm_Node" df = pd.read_sql_query(query, con) df['geometry'] = df['wkt_geometry'].apply(wkt.loads)

You must be signed in to post in this forum.