# Shapefile opening failure

**URL:** <https://mapwindow.discourse.group/t/shapefile-opening-failure/433>\
**Category:** MapWinGIS\
**Created:** [January 26, 2020, 7:34pm UTC](https://mapwindow.discourse.group/t/shapefile-opening-failure/433 "2020-01-26T19:34:16Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![george](https://avatars.discourse-cdn.com/v4/letter/g/71e660/32.png) [@george](https://mapwindow.discourse.group/u/george)\
**Post date:** [January 26, 2020, 7:34pm UTC](https://mapwindow.discourse.group/t/shapefile-opening-failure/433/1 "2020-01-26T19:34:16Z")

</div>

Hi @pmeems,

I have MapWinGIS 4.9.5.0 installed.  
With “MapWinGIS.Shapefile.Open” method I am trying to open a shapefile, which has only ‘ShapeType.MULTI\_PATCH’ shapes.  
However the ‘Open’ method fails.  
I can open the file with no issues in QGIS 3.10.2.

Does Shapefile class support MULTI\_PATCH shapes?  
Here is the shapefile:

> **[Gofile - File sharing platform, anonymous and free](https://gofile.io/?c=sVTAHA)**
>
> Gofile is a free and anonymous file-sharing platform. You can store and share data of all types (files, images, music, videos etc...). There is no limit, you download at the maximum speed of your connection and everything is free.

And help would be appreciated.

Best regards,  
George

---

<div class="post-metadata">

**Author:** ![jerryfaust](https://yyz2.discourse-cdn.com/free1/user_avatar/mapwindow.discourse.group/jerryfaust/32/378_2.png) [@jerryfaust](https://mapwindow.discourse.group/u/jerryfaust)\
**Post date:** [January 26, 2020, 11:37pm UTC](https://mapwindow.discourse.group/t/shapefile-opening-failure/433/2 "2020-01-26T23:37:57Z")

</div>

Hello @george

[MULTIPATCH Shapefile types aren’t supported by MapWinGIS](https://www.mapwindow.org/documentation/mapwingis4.9/_enumerations_8cs.html#a96d6460f5cd3c49b4c12be5a38c82b4e). That said, MapWinGIS uses GDAL to load many of the vector file types, and the [GDAL Shapefile driver](https://gdal.org/drivers/vector/shapefile.html#vector-shapefile) says it supports MultiPatch, **but that it will turn them into TINs** (which I know nothing about). But the point is that you might be able to use GDAL, opening the file as an [OgrLayer](https://www.mapwindow.org/documentation/mapwingis4.9/class_ogr_layer.html) rather than opening as a simple Shapefile. What happens after that I don’t know, but you could try it out and see what happens.

Perhaps others have more experience with this.

Regards,  
Jerry.

---

<div class="post-metadata">

**Author:** ![george](https://avatars.discourse-cdn.com/v4/letter/g/71e660/32.png) [@george](https://mapwindow.discourse.group/u/george)\
**Post date:** [January 27, 2020, 6:03am UTC](https://mapwindow.discourse.group/t/shapefile-opening-failure/433/3 "2020-01-27T06:03:44Z")

</div>

Thank you @jerryfaust,  
Is there some rough example code that I can follow for the OgrLayer opening of the shapefile?  
I’ve never used this class.

---

<div class="post-metadata">

**Author:** ![jerryfaust](https://yyz2.discourse-cdn.com/free1/user_avatar/mapwindow.discourse.group/jerryfaust/32/378_2.png) [@jerryfaust](https://mapwindow.discourse.group/u/jerryfaust)\
**Post date:** [January 27, 2020, 7:08am UTC](https://mapwindow.discourse.group/t/shapefile-opening-failure/433/4 "2020-01-27T07:08:55Z")

</div>

Hello @george

If you declare an OgrLayer and call [OpenFromFile](https://www.mapwindow.org/documentation/mapwingis4.9/class_ogr_layer.html#aa8825c498c2aa78909c7459139bfd9f7), passing in the name of a Shapefile, OGR will use it’s Shapefile driver to open the file. What happens after that in terms of converting to a TIN, I’m not sure, but I would then just try adding the layer to the map. In c# it would be something like:

```
OgrLayer ogr = new OgrLayer();
if (ogr.OpenFromFile(pathToShapefile, false))
{
    axMap1.AddLayer(ogr, true);
}

```

If I have more time later this week, I could try the file you uploaded. But for, try what I’ve recommended and see what happens.

Regards,  
Jerry.

---

<div class="post-metadata">

**Author:** ![george](https://avatars.discourse-cdn.com/v4/letter/g/71e660/32.png) [@george](https://mapwindow.discourse.group/u/george)\
**Post date:** [January 27, 2020, 6:19pm UTC](https://mapwindow.discourse.group/t/shapefile-opening-failure/433/5 "2020-01-27T18:19:26Z")

</div>

Thank you @jerryfaust,

How do you instantiate the “axMap1”?  
`axMap axMap1 = new axMap();`  
If so, then when I add the ‘ogr’ to ‘AddLayer’ I get the following error message:

```auto
Runtime error (COMException): Catastrophic failure (Exception from HRESULT: 0x8000FFFF (E_UNEXPECTED))

```

I tried using the [Utils.OGRLayerToShapefile](https://www.mapwindow.org/documentation/mapwingis4.9/class_utils.html#af835a8ce5493bcd485a92bdd1564f453) method instead.  
It opens the shapefile, reprojects it, reads the fields without issues, but reports that the shape inside of it is of “SHP\_NULL” type. Which means I can not read it.

---

<div class="post-metadata">

**Author:** ![jerryfaust](https://yyz2.discourse-cdn.com/free1/user_avatar/mapwindow.discourse.group/jerryfaust/32/378_2.png) [@jerryfaust](https://mapwindow.discourse.group/u/jerryfaust)\
**Post date:** [January 27, 2020, 6:51pm UTC](https://mapwindow.discourse.group/t/shapefile-opening-failure/433/6 "2020-01-27T18:51:26Z")

</div>

Hello @george

2 things:

1. I assumed you were loading the OCX onto a Form, at which point Visual Studio will generally name it `axMap1`. That’s where the variable would come from. But that’s ok, you don’t have to have the control loaded in order to be able to open a layer/shapefile.

2. Regarding SHP\_NULLSHAPE, I’ve seen this with OGR layers, and I’m not sure why it happens, but here’s what I do whenever I open an OGR layer (in [VB.NET](http://VB.NET)):

See if that helps.

Jerry.

**Addendum** : Regarding the NULL shape, it may be that the shape type is NULL because it is no longer a valid Shapefile, since GDAL says it converts it to a TIN. Again, this is new territory for me, so I don’t know the answer. I will try to step through the process later this week, using your file, to see what is happening.

---

<div class="post-metadata">

**Author:** ![george](https://avatars.discourse-cdn.com/v4/letter/g/71e660/32.png) [@george](https://mapwindow.discourse.group/u/george)\
**Post date:** [February 1, 2020, 11:19pm UTC](https://mapwindow.discourse.group/t/shapefile-opening-failure/433/7 "2020-02-01T23:19:23Z")

</div>

Hi @jerryfaust,

Thank you once again for the help.  
`pOgrLayer.ActiveShapeType` returns 0, and `pOgrLayer.AvailableShapeTypes` returns an array with only 0.

If there is something more that you discovered, I would be quite grateful to hear it.

---

<div class="post-metadata">

**Author:** ![jerryfaust](https://yyz2.discourse-cdn.com/free1/user_avatar/mapwindow.discourse.group/jerryfaust/32/378_2.png) [@jerryfaust](https://mapwindow.discourse.group/u/jerryfaust)\
**Post date:** [February 4, 2020, 8:18pm UTC](https://mapwindow.discourse.group/t/shapefile-opening-failure/433/8 "2020-02-04T20:18:25Z")

</div>

Hello @george

I would like to try loading your shapefile and see what is happening.

If you don’t mind, could you upload the shapefile to this website. It may well be ok, but Norton is giving me severe warnings about the GoFile website.

Thank you.  
Jerry.

---

<div class="post-metadata">

**Author:** ![george](https://avatars.discourse-cdn.com/v4/letter/g/71e660/32.png) [@george](https://mapwindow.discourse.group/u/george)\
**Post date:** [February 4, 2020, 8:42pm UTC](https://mapwindow.discourse.group/t/shapefile-opening-failure/433/9 "2020-02-04T20:42:33Z")

</div>

Hi @jerryfaust,

Here it is. Thank you.  
[multi\_patch\_shapefile.zip](https://mapwindow.discourse.group/uploads/short-url/gZqQaCnVFATRarCXPKUfkwv1UyI.zip) (1.2 KB)

---

<div class="post-metadata">

**Author:** ![jerryfaust](https://yyz2.discourse-cdn.com/free1/user_avatar/mapwindow.discourse.group/jerryfaust/32/378_2.png) [@jerryfaust](https://mapwindow.discourse.group/u/jerryfaust)\
**Post date:** [February 5, 2020, 5:54am UTC](https://mapwindow.discourse.group/t/shapefile-opening-failure/433/10 "2020-02-05T05:54:19Z")

</div>

Hello @george

So far, no success.

I can open the file through GDAL, as an OGR Layer. And according to [GDAL documentation](https://gdal.org/drivers/vector/shapefile.html), it is converted to a TIN file. But I don’t know what to do with it after that, at least from a MapWinGIS standpoint. Although it loads into the map, it is at that point interpreted as a Shapefile having a NULL shape type, so nothing appears.

I tried various methods of converting it or interpreting it as a MapWInGIS TIN, but to no avail.  
I will have to do more research regarding how others use GDAL to read MultiPatch files.

I’ll let you know if I learn anything.

Regards,  
Jerry.

---

<div class="post-metadata">

**Author:** ![george](https://avatars.discourse-cdn.com/v4/letter/g/71e660/32.png) [@george](https://mapwindow.discourse.group/u/george)\
**Post date:** [February 5, 2020, 6:02am UTC](https://mapwindow.discourse.group/t/shapefile-opening-failure/433/11 "2020-02-05T06:02:56Z")

</div>

Thanks for the effort @jerryfaust.

---

<div class="post-metadata">

**Author:** ![jerryfaust](https://yyz2.discourse-cdn.com/free1/user_avatar/mapwindow.discourse.group/jerryfaust/32/378_2.png) [@jerryfaust](https://mapwindow.discourse.group/u/jerryfaust)\
**Post date:** [February 5, 2020, 6:22am UTC](https://mapwindow.discourse.group/t/shapefile-opening-failure/433/12 "2020-02-05T06:22:49Z")

</div>

Interestingly, I can unpack the file using the OGRINFO application that comes with the GDAL distribution, and I can get the WKT version of your shapefile, as follows:

GEOMETRYCOLLECTION Z (TIN Z (((11.343041518345 44.4938875871233 11.2417631149292,11.3430336701609 44.4936916889913 11.2417631149292,11.3431344482769 44.4938562115227 11.2417631149292,11.343041518345 44.4938875871233 11.2417631149292))),TIN Z (((11.3428507126776 44.4936954440913 7.48024463653564,11.3430336701609 44.4936916889913 11.2417631149292,11.343041518345 44.4938875871233 11.2417631149292,11.3428507126776 44.4936954440913 7.48024463653564))),TIN Z (((11.3431277794306 44.4936897573368 5.29770469665527,11.3428507126776 44.4936954440913 7.48024463653564,11.3428507126776 44.4936954440913 5.29770469665527,11.3431277794306 44.4936897573368 5.29770469665527))),TIN Z (((11.3431277794306 44.4936897573368 11.2417631149292,11.3430336701609 44.4936916889913 11.2417631149292,11.3431277794306 44.4936897573368 5.29770469665527,11.3431277794306 44.4936897573368 11.2417631149292))),TIN Z (((11.3428507126776 44.4936954440913 7.48024463653564,11.3431277794306 44.4936897573368 5.29770469665527,11.3430336701609 44.4936916889913 11.2417631149292,11.3428507126776 44.4936954440913 7.48024463653564))),TIN Z (((11.3431344482769 44.4938562115227 11.2417631149292,11.3431277794306 44.4936897573368 11.2417631149292,11.3431277794306 44.4936897573368 5.29770469665527,11.3431344482769 44.4938562115227 11.2417631149292))),TIN Z (((11.3431344482769 44.4938562115227 11.2417631149292,11.3431319466443 44.4937937710244 7.7715611723761e-16,11.3431344482769 44.4938562115227 2.75583836985302e-16,11.3431344482769 44.4938562115227 11.2417631149292))),TIN Z (((11.3431277794306 44.4936897573368 5.29770469665527,11.3431319466443 44.4937937710244 7.7715611723761e-16,11.3431344482769 44.4938562115227 11.2417631149292,11.3431277794306 44.4936897573368 5.29770469665527))),TIN Z (((11.3428548793996 44.4937994577993 0,11.3428608533427 44.4939485841042 7.48024463653564,11.3428608533427 44.4939485841042 0,11.3428548793996 44.4937994577993 0))),TIN Z (((11.3428608533427 44.4939485841042 7.48024463653564,11.3428507126776 44.4936954440913 5.29770469665527,11.3428507126776 44.4936954440913 7.48024463653564,11.3428608533427 44.4939485841042 7.48024463653564))),TIN Z (((11.3428548793996 44.4937994577993 0,11.3428507126776 44.4936954440913 5.29770469665527,11.3428608533427 44.4939485841042 7.48024463653564,11.3428548793996 44.4937994577993 0))),TIN Z (((11.3428507126776 44.4936954440913 5.29770469665527,11.3428548793996 44.4937994577993 0,11.3431319466443 44.4937937710244 7.7715611723761e-16,11.3428507126776 44.4936954440913 5.29770469665527))),TIN Z (((11.3428608533427 44.4939485841042 7.48024463653564,11.3431344482769 44.4938562115227 2.75583836985302e-16,11.3428608533427 44.4939485841042 0,11.3428608533427 44.4939485841042 7.48024463653564))),TIN Z (((11.3428608533427 44.4939485841042 7.48024463653564,11.343041518345 44.4938875871233 11.2417631149292,11.3431344482769 44.4938562115227 2.75583836985302e-16,11.3428608533427 44.4939485841042 7.48024463653564))),TIN Z (((11.3431344482769 44.4938562115227 11.2417631149292,11.3431344482769 44.4938562115227 2.75583836985302e-16,11.343041518345 44.4938875871233 11.2417631149292,11.3431344482769 44.4938562115227 11.2417631149292))),TIN Z (((11.3431344482769 44.4938562115227 2.75583836985302e-16,11.3428548793996 44.4937994577993 0,11.3428608533427 44.4939485841042 0,11.3431344482769 44.4938562115227 2.75583836985302e-16))),TIN Z (((11.3428548793996 44.4937994577993 0,11.3431344482769 44.4938562115227 2.75583836985302e-16,11.3431319466443 44.4937937710244 7.7715611723761e-16,11.3428548793996 44.4937994577993 0))),TIN Z (((11.3430336701609 44.4936916889913 11.2417631149292,11.3431277794306 44.4936897573368 11.2417631149292,11.3431344482769 44.4938562115227 11.2417631149292,11.3430336701609 44.4936916889913 11.2417631149292))),TIN Z (((11.3428507126776 44.4936954440913 7.48024463653564,11.343041518345 44.4938875871233 11.2417631149292,11.3428608533427 44.4939485841042 7.48024463653564,11.342850712677644.4936954440913 7.48024463653564))),TIN Z (((11.3428507126776 44.4936954440913 5.29770469665527,11.3431319466443 44.4937937710244 7.7715611723761e-16,11.3431277794306 44.4936897573368 5.29770469665527,11.3428507126776 44.4936954440913 5.29770469665527))))

Unfortunately, being a GEOMETRYCOLLECTION, this is also a Shape type that is not supported by MapWinGIS. Perhaps the next step would be to figure out how to unpack the points from this, and import them into a TIN class. The MapWinGIS library has a TIN class that has a method called [CreateTinFromPoints](https://www.mapwindow.org/documentation/mapwingis4.9/class_tin.html#a55f8402e567f56cd723e67476c2a7cf1). If that works, the TIN could theoretically be loaded by MapWinGIS.

Jerry.

---

<div class="post-metadata">

**Author:** ![pmeems](https://yyz2.discourse-cdn.com/free1/user_avatar/mapwindow.discourse.group/pmeems/32/9_2.png) [@pmeems](https://mapwindow.discourse.group/u/pmeems)\
**Post date:** [January 5, 2022, 3:08pm UTC](https://mapwindow.discourse.group/t/shapefile-opening-failure/433/13 "2022-01-05T15:08:58Z")

</div>


