Using Ruby to Export ICM InfoWorks Node, Link, and Subcatchment Grid Data to Shapefiles and a Custom Folder
Using Ruby to Export ICM InfoWorks Node, Link, and Subcatchment Grid Data to Shapefiles and a Custom Folder

Using Ruby to Export ICM InfoWorks Node, Link, and Subcatchment Grid Data to Shapefiles and a Custom Folder

This Ruby script is designed to export GIS data from an ICM InfoWorks network to a shapefile (SHP) format. Here’s a summary of its operation:

  1. It first accesses the current network using the WSApplication.current_network method.
  2. It retrieves the name of the network.
  3. It sets up an array of tables (hw_node, hw_conduit, hw_subcatchment) to be exported for ICM InfoWorks. There’s also an option to set up an array of tables for ICM SWMM, but this is currently commented out. If you want to export ICM SWMM then uncomment it and then comment the hw lines
  4. It creates a hash for the export options to override the defaults. The options include ExportFlags and SkipEmptyTables, both set to false, and Tables, which is set to the export_tables array.
  5. It prompts the user to pick a folder for exporting ICM InfoWorks SHP files and provides details about the export method, the tables to be exported, and the formats available.
  6. Finally, it exports the GIS data to the chosen folder in SHP format using the GIS_export method, with the specified options overriding the default options.

This script provides a flexible way to export GIS data from ICM InfoWorks to various formats. It allows you to customize the tables to be exported and the export options. It also includes user prompts for a more interactive experience. The exported data can then be used for further analysis or visualization in GIS applications.

Ruby Dialog with some Explanatory text
The End Result is a Shape file for Each Table
The End Result is a Shapefile for Each Table.


The Ruby Code is on our Github 01 InfoWorks ICM/01 Ruby/02 SWMM/0114 - GIS Export of Data Tables

01 InfoWorks ICM/01 Ruby/02 SWMM/0114 - GIS Export of Data Tables

This code can be used for ICM SWMM as well by changing hw for InfoWork to sw for SWMM
# Create an array for the tables to be exported for ICM InfoWorks
#
export_tables = ["hw_node","hw_conduit","hw_subcatchment"]

# Create an array for the tables to be exported for ICM SWMM
#export_tables = ["sw_node","sw_conduit","sw_subcatchment"]        
Closing Note:

Thank you for reading these articles. I appreciate your engagement and support. Thank you again, and I hope you'll join me on this ongoing journey of learning and discovery. Until next time!

Obligatory AI Image from Midjourney featuring Water




要查看或添加评论,请登录

Robert Dickinson的更多文章

社区洞察

其他会员也浏览了