export a .gen file as shapefile? - Forum - iMOD
iMOD Forum
export a .gen file as shapefile?
Kristina Gumgowski, modified 3 Years ago.
export a .gen file as shapefile?
Youngling Posts: 13 Join Date: 3/18/21 Recent Posts
Hi,
I have an exisiting .gen file and would like convert it to a shapefile. Is there any way to do this in iMOD? Further, I am wondering if there are other methods to convert it using software like ArcGIS or QGIS? At the moment I am unable to load it in one or the other..
Thanks
Kristina
I have an exisiting .gen file and would like convert it to a shapefile. Is there any way to do this in iMOD? Further, I am wondering if there are other methods to convert it using software like ArcGIS or QGIS? At the moment I am unable to load it in one or the other..
Thanks
Kristina
Frans Roelofsen, modified 3 Years ago.
RE: export a .gen file as shapefile?
Padawan Posts: 51 Join Date: 11/11/13 Recent Posts
Hi Kristina,
I never converted a GEN file into a Shape file but I think it is possible.
First of all it is good to know that there are two types of GEN file. 1) The iMOD binary format and 2) the ASCII format. The latter is the same format as the ungenerate file from ARCGIS (see also https://desktop.arcgis.com/en/arcmap/10.3/tools/coverage-toolbox/ungenerate.htm). If you want to do a conversion, always have your GEN file in the ASCII format. I prefer to user Python for pre- and post processing of data.
You can read a GEN file as a geopandas dataframe and save it as a shape. Your script could look like this:
- My experience is that if the header of a polygon in the GEN file contains a string, the code above yields an error.
- While the GEN format is the ungenerate format for ARCGIS, perhaps the Python site package ArcPy provides helpful methods. I have no experience with ArcPy
In addition. You are probably already familiar with the conversion of a SHP file to a GEN file. In iMOD from the main menu FILE you can choose IMPORT and click on "Import Esri Shape file".
Kind regards,
Frans
I never converted a GEN file into a Shape file but I think it is possible.
First of all it is good to know that there are two types of GEN file. 1) The iMOD binary format and 2) the ASCII format. The latter is the same format as the ungenerate file from ARCGIS (see also https://desktop.arcgis.com/en/arcmap/10.3/tools/coverage-toolbox/ungenerate.htm). If you want to do a conversion, always have your GEN file in the ASCII format. I prefer to user Python for pre- and post processing of data.
You can read a GEN file as a geopandas dataframe and save it as a shape. Your script could look like this:
1 | import geopandas as gpd |
2 | file='SURFACE_WATER.GEN' |
3 | gdf = gpd.read_file(file) |
4 | file=r'SURFACE_WATER.shp' |
5 | gdf.to_file(file) |
- My experience is that if the header of a polygon in the GEN file contains a string, the code above yields an error.
- While the GEN format is the ungenerate format for ARCGIS, perhaps the Python site package ArcPy provides helpful methods. I have no experience with ArcPy
In addition. You are probably already familiar with the conversion of a SHP file to a GEN file. In iMOD from the main menu FILE you can choose IMPORT and click on "Import Esri Shape file".
Kind regards,
Frans
Kristina Gumgowski, modified 3 Years ago.
RE: export a .gen file as shapefile?
Youngling Posts: 13 Join Date: 3/18/21 Recent Posts
Hi Frans, thanks for all your support. The .gen file I have available is in the iMOD binary Format. I could not clearly understand from your answer: Is the Python Code applicable for the binary .gen file or only for the ASCII-Format? Is it possible to go from binary-gen to ascii-gen? I am sorry if my questions are so trivial.
Kind regards,
Kristina
Kind regards,
Kristina
Frans Roelofsen, modified 3 Years ago.
RE: export a .gen file as shapefile?
Padawan Posts: 51 Join Date: 11/11/13 Recent Posts
Hi Kristina,
The Python code is not yet applicable for the binary gen file. The code example I gave, uses the well-known site package Geopandas. There is also the iMOD-python site package (see https://oss.deltares.nl/web/imod/imod-python-toolbox) In the next release of this iMOD-Python package, a special method is included to read also the binary version.
For now: you can change the GEN format into ASCII. In iMOD go to the main menu Edit, choose Create Features and click on Create a GEN. In the window, open your binary file and save it in the ESRI ASCII format.
Kind regards,
Frans
The Python code is not yet applicable for the binary gen file. The code example I gave, uses the well-known site package Geopandas. There is also the iMOD-python site package (see https://oss.deltares.nl/web/imod/imod-python-toolbox) In the next release of this iMOD-Python package, a special method is included to read also the binary version.
For now: you can change the GEN format into ASCII. In iMOD go to the main menu Edit, choose Create Features and click on Create a GEN. In the window, open your binary file and save it in the ESRI ASCII format.
Kind regards,
Frans
Kristina Gumgowski, modified 3 Years ago.
RE: export a .gen file as shapefile?
Youngling Posts: 13 Join Date: 3/18/21 Recent Posts
Hi Frans,
that did the trick! Thanks a lot. Also, I will attempt to include imod-python into my work process. Have a great day!
that did the trick! Thanks a lot. Also, I will attempt to include imod-python into my work process. Have a great day!