Point Z Values in Shapefiles

Sep 18, 2006 at 10:16 AM
Hi,

I am busy developing a GIS application that has a base map rendered, and users out in the field capturing GPS points in ArcPad into another shapefile. This shapefile gets merged on our server and is then rendered onto the map. There are PointZ values in the shapefile (height points), but does SharpMap support height points, or is there a workaround for this (Maybe a helper class) that somebody has written? This is the following error I get when trying to render the map:

Server Error in '/GPSAJAX' Application.
--------------------------------------------------------------------------------

Shapefile type PointZ not supported
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.ApplicationException: Shapefile type PointZ not supported

Source Error:


Line 93: private void CreateMap()
Line 94: {
Line 95: System.Drawing.Image img = myMap.GetMap();
Line 96: string imgID = SharpMap.Web.Caching.InsertIntoCache(1, img);
Line 97: imgMap.ImageUrl = "getmap.aspx?ID=" + HttpUtility.UrlEncode(imgID);


Source File: c:\Inetpub\wwwroot\GPSAJAX\Default.aspx.cs Line: 95

Stack Trace:


ApplicationException: Shapefile type PointZ not supported
SharpMap.Providers.ShapeFile.GetFeaturesInView(BoundingBox bbox) +1813
SharpMap.Layers.VectorLayer.Render(Graphics g, Map map) +92
SharpMap.Map.GetMap() +225
Default.CreateMap() in c:\Inetpub\wwwroot\GPSAJAX\Default.aspx.cs:95
Default.Page_Load(Object sender, EventArgs e) in c:\Inetpub\wwwroot\GPSAJAX\Default.aspx.cs:35
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +15
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +34
System.Web.UI.Control.OnLoad(EventArgs e) +99
System.Web.UI.Control.LoadRecursive() +47
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1061




--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.42; ASP.NET Version:2.0.50727.42

Any help would be appreciated. I could strip the PointZ fields out of the shapefile with an extension in Arc, but this is laborious.

Thanks,


Dewald Troskie
GIS Developer (C#, ASP.NET, PostGreSQL, MySQL)
Pretoria, South Africa
Coordinator
Sep 18, 2006 at 3:43 PM
Hi GISDeveloper -

Sharpmap doesn't currently support Z values (or M values, for that matter).

It shouldn't be hard to add 3d functionality, but some of the base classes need to be augmented.

It would be good to consider it for a 2.0 feature.
Developer
Sep 19, 2006 at 8:21 PM
SharpMap does support PointZ datatypes. It just doesn't read the Z value from the file (Z support has been left out because of performance/memory optimizations).

Are you using a very old version, because this has been supported for "ages". See the method:
SharpMap.Data.Providers.ShapeFile.ReadGeometry()
There's a line saying:
if (_ShapeType == ShapeType.Point || _ShapeType==ShapeType.PointM || _ShapeType==ShapeType.PointZ)
...read point
Coordinator
Sep 19, 2006 at 9:19 PM
I do see that, but he was trying to read them from a shapefile.
Coordinator
Sep 19, 2006 at 9:32 PM
Ah, I see.... yea, I said that some base classes would need augmenting. I was wrong: I forgot about Point3d. The shapefile provider would still need to parse (and in 2.0 write out) the PointZ structures.
Sep 20, 2006 at 11:50 AM
SharpGIS,

Do you have some reference code for reading the points, there's about 500 points in the file). I am using version 0.9 release of SharpMap. I'm going to test this now in PostGIS to see if I have similar problems.
Secondly, I have stripped the Z values out of the shapefile with ArcView (and an extension) and defined the layer and added it (like all my other layers), but now .NET complains that I am not instantiating a reference to the object (see below). Is this due to the point not being read:

Server Error in '/GPSAJAX' Application.
--------------------------------------------------------------------------------

Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Source Error:


Line 91: private void CreateMap()
Line 92: {
Line 93: System.Drawing.Image img = myMap.GetMap();
Line 94: string imgID = SharpMap.Web.Caching.InsertIntoCache(1, img);
Line 95: imgMap.ImageUrl = "getmap.aspx?ID=" + HttpUtility.UrlEncode(imgID);


Source File: c:\Inetpub\wwwroot\GPSAJAX\Default.aspx.cs Line: 93

Stack Trace:


NullReferenceException: Object reference not set to an instance of an object.
SharpMap.Rendering.VectorRenderer.DrawPoint(Graphics g, Point point, Bitmap symbol, Map map) +53
SharpMap.Layers.VectorLayer.Render(Graphics g, Map map) +884
SharpMap.Map.GetMap() +225
Default.CreateMap() in c:\Inetpub\wwwroot\GPSAJAX\Default.aspx.cs:93
Default.Page_Load(Object sender, EventArgs e) in c:\Inetpub\wwwroot\GPSAJAX\Default.aspx.cs:35
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +15
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +34
System.Web.UI.Control.OnLoad(EventArgs e) +99
System.Web.UI.Control.LoadRecursive() +47
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1061


Thanks,

GISDeveloper.

Developer
Sep 20, 2006 at 1:40 PM
There are no difference in reading Point, PointZ or PointZM ShapeFiles in SharpMap. They are all handled the same way.

What version are you using?
Sep 21, 2006 at 7:04 AM
I'm using version 0.9 release.....

Thanks,

GISDeveloper