Exception when using shape files

2 posts, 0 answers
  1. Clifford
    Clifford avatar
    2 posts
    Member since:
    Oct 2011

    Posted 28 Oct 2011 Link to this post

    I am attempting to use shape files from the following source:

    Shape File Source
    • Select - States (and equivalent)
    • Select - Georgia (tested files)

    The exact files I tested were the files for Georgia (both 2010 and 2000)

    I currently have an information layer defined by the name infoLayer and I am initializing the reader in the code behind (I also get the same error when setting up the information layer in the xaml):

    this.infoLayer.Reader = new MapShapeReader()
               {
                   Source = new Uri(Environment.CurrentDirectory + "/tl_2010_13_state00.shp", UriKind.RelativeOrAbsolute),
                   DataSource = new Uri(Environment.CurrentDirectory + "/tl_2010_13_state00.dbf", UriKind.RelativeOrAbsolute),
     
               };

    When starting up the program I get the following error:

    System.OverflowException was unhandled
      Message=Value was either too large or too small for an Int32.
      Source=mscorlib
      StackTrace:
           at System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info)
           at System.Int32.Parse(String s, NumberStyles style, IFormatProvider provider)
           at System.Convert.ToInt32(String value, IFormatProvider provider)
           at System.String.System.IConvertible.ToInt32(IFormatProvider provider)
           at System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider)
           at Telerik.Windows.Controls.Map.DbfReader.GetNextRecord() in c:\TB\117\WPF_Scrum\Release_WPF_40\Sources\Development\Controls\DataVisualization\Map\ShapeReaders\ShapeFile\DbfReader\DbfReader.cs:line 123
           at Telerik.Windows.Controls.Map.DbfReader.MoveNext() in c:\TB\117\WPF_Scrum\Release_WPF_40\Sources\Development\Controls\DataVisualization\Map\ShapeReaders\ShapeFile\DbfReader\DbfReader.cs:line 133
           at Telerik.Windows.Controls.Map.ShapeFileReader.GetExtendedData(DbfReader dbfReader) in c:\TB\117\WPF_Scrum\Release_WPF_40\Sources\Development\Controls\DataVisualization\Map\ShapeReaders\ShapeFile\ShapeFileReader.cs:line 223
           at Telerik.Windows.Controls.Map.ShapeFileReader.GetShape(EndianBinaryReader reader, DbfReader dbfReader, List`1 list, ShapeFileReaderParameters parameters) in c:\TB\117\WPF_Scrum\Release_WPF_40\Sources\Development\Controls\DataVisualization\Map\ShapeReaders\ShapeFile\ShapeFileReader.cs:line 173
           at Telerik.Windows.Controls.Map.ShapeFileReader.GetShapes(EndianBinaryReader reader, ShapeFileHeader header, DbfReader dbfReader, ShapeFileReaderParameters parameters) in c:\TB\117\WPF_Scrum\Release_WPF_40\Sources\Development\Controls\DataVisualization\Map\ShapeReaders\ShapeFile\ShapeFileReader.cs:line 151
           at Telerik.Windows.Controls.Map.ShapeFileReader.Read(ShapeFileReaderParameters parameters) in c:\TB\117\WPF_Scrum\Release_WPF_40\Sources\Development\Controls\DataVisualization\Map\ShapeReaders\ShapeFile\ShapeFileReader.cs:line 128
           at Telerik.Windows.Controls.Map.MapShapeReader.ReadShapeFileByType(ShapeReaderStatus status) in c:\TB\117\WPF_Scrum\Release_WPF_40\Sources\Development\Controls\DataVisualization\Map\ShapeReaders\MapShapeReader.cs:line 496
           at Telerik.Windows.Controls.Map.MapShapeReader.CompleteReading(ShapeReaderStatus status, Exception error) in c:\TB\117\WPF_Scrum\Release_WPF_40\Sources\Development\Controls\DataVisualization\Map\ShapeReaders\MapShapeReader.cs:line 455
           at Telerik.Windows.Controls.Map.MapShapeReader.CheckComplete(Exception serviceError, Object userState, Stream stream, Boolean data) in c:\TB\117\WPF_Scrum\Release_WPF_40\Sources\Development\Controls\DataVisualization\Map\ShapeReaders\MapShapeReader.cs:line 412
           at Telerik.Windows.Controls.Map.MapShapeReader.ReadShapesCompleted(Object sender, OpenReadCompletedEventArgs e) in c:\TB\117\WPF_Scrum\Release_WPF_40\Sources\Development\Controls\DataVisualization\Map\ShapeReaders\MapShapeReader.cs:line 359
           at System.Net.WebClient.OnOpenReadCompleted(OpenReadCompletedEventArgs e)
           at System.Net.WebClient.OpenReadOperationCompleted(Object arg)
           at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
           at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
           at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
           at System.Windows.Threading.Dispatcher.WrappedInvoke(Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
           at System.Windows.Threading.Dispatcher.WrappedInvoke(Delegate callback, Object args, Int32 numArgs)
           at System.Windows.Threading.DispatcherOperation.InvokeImpl()
           at System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(Object state)
           at System.Threading.ExecutionContext.runTryCode(Object userData)
           at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
           at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
           at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
           at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
           at System.Windows.Threading.DispatcherOperation.Invoke()
           at System.Windows.Threading.Dispatcher.ProcessQueue()
           at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
           at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
           at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
           at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
           at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
           at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
           at System.Windows.Threading.Dispatcher.WrappedInvoke(Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
           at System.Windows.Threading.Dispatcher.WrappedInvoke(Delegate callback, Object args, Int32 numArgs)
           at System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
           at System.Windows.Threading.Dispatcher.Invoke(DispatcherPriority priority, Delegate method, Object arg)
           at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
           at MS.Win32.UnsafeNativeMethods.MessageBox(HandleRef hWnd, String text, String caption, Int32 type)
           at System.Windows.MessageBox.ShowCore(IntPtr owner, String messageBoxText, String caption, MessageBoxButton button, MessageBoxImage icon, MessageBoxResult defaultResult, MessageBoxOptions options)
           at System.Windows.MessageBox.Show(String messageBoxText, String caption, MessageBoxButton button)
           at Telerik.Windows.Controls.TelerikLicense.DisplayTrialMessage() in c:\TB\117\WPF_Scrum\Release_WPF_40\Sources\Development\Core\Controls\Licensing\TelerikLicense.cs:line 67
           at Telerik.Windows.Controls.TelerikLicense.TargetControl_Loaded(Object sender, RoutedEventArgs e) in c:\TB\117\WPF_Scrum\Release_WPF_40\Sources\Development\Core\Controls\Licensing\TelerikLicense.cs:line 55
           at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
           at System.Windows.RouteItem.InvokeHandler(RoutedEventArgs routedEventArgs)
           at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
           at System.Windows.EventRoute.InvokeHandlers(Object source, RoutedEventArgs args)
           at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
           at System.Windows.UIElement.RaiseEvent(RoutedEventArgs e)
           at System.Windows.FrameworkElement.OnLoaded(RoutedEventArgs args)
           at MS.Internal.FrameworkObject.OnLoaded(RoutedEventArgs args)
           at System.Windows.BroadcastEventHelper.BroadcastEvent(DependencyObject root, RoutedEvent routedEvent)
           at System.Windows.BroadcastEventHelper.BroadcastLoadedSynchronously(DependencyObject rootDO, Boolean isLoaded)
           at System.Windows.BroadcastEventHelper.BroadcastLoadedEvent(Object root)
           at MS.Internal.LoadedOrUnloadedOperation.DoWork()
           at System.Windows.Media.MediaContext.FireLoadedPendingCallbacks()
           at System.Windows.Media.MediaContext.FireInvokeOnRenderCallbacks()
           at System.Windows.Media.MediaContext.RenderMessageHandlerCore(Object resizedCompositionTarget)
           at System.Windows.Media.MediaContext.RenderMessageHandler(Object resizedCompositionTarget)
           at System.Windows.Media.MediaContext.Resize(ICompositionTarget resizedCompositionTarget)
           at System.Windows.Interop.HwndTarget.OnResize()
           at System.Windows.Interop.HwndTarget.HandleMessage(WindowMessage msg, IntPtr wparam, IntPtr lparam)
           at System.Windows.Interop.HwndSource.HwndTargetFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
           at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
           at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
           at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
           at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
           at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
           at System.Windows.Threading.Dispatcher.WrappedInvoke(Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
           at System.Windows.Threading.Dispatcher.WrappedInvoke(Delegate callback, Object args, Int32 numArgs)
           at System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
           at System.Windows.Threading.Dispatcher.Invoke(DispatcherPriority priority, Delegate method, Object arg)
           at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
           at MS.Win32.UnsafeNativeMethods.ShowWindow(HandleRef hWnd, Int32 nCmdShow)
           at System.Windows.Window.ShowHelper(Object booleanBox)
           at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
           at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
           at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
           at System.Windows.Threading.Dispatcher.WrappedInvoke(Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
           at System.Windows.Threading.Dispatcher.WrappedInvoke(Delegate callback, Object args, Int32 numArgs)
           at System.Windows.Threading.DispatcherOperation.InvokeImpl()
           at System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(Object state)
           at System.Threading.ExecutionContext.runTryCode(Object userData)
           at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
           at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
           at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
           at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
           at System.Windows.Threading.DispatcherOperation.Invoke()
           at System.Windows.Threading.Dispatcher.ProcessQueue()
           at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
           at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
           at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
           at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
           at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
           at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
           at System.Windows.Threading.Dispatcher.WrappedInvoke(Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
           at System.Windows.Threading.Dispatcher.WrappedInvoke(Delegate callback, Object args, Int32 numArgs)
           at System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
           at System.Windows.Threading.Dispatcher.Invoke(DispatcherPriority priority, Delegate method, Object arg)
           at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
           at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
           at System.Windows.Threading.Dispatcher.TranslateAndDispatchMessage(MSG& msg)
           at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
           at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
           at System.Windows.Threading.Dispatcher.Run()
           at System.Windows.Application.RunDispatcher(Object ignore)
           at System.Windows.Application.RunInternal(Window window)
           at System.Windows.Application.Run(Window window)
           at System.Windows.Application.Run()
           at RadControlsWpfApp1.App.Main() in C:\Documents and Settings\YUVD3\My Documents\Visual Studio 2010\Projects\RadControlsWpfApp1\RadControlsWpfApp1\obj\x86\Debug\App.g.cs:line 0
           at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
           at System.AppDomain.nExecuteAssembly(RuntimeAssembly assembly, String[] args)
           at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
           at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
           at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
           at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
           at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
           at System.Threading.ThreadHelper.ThreadStart()
      InnerException: 

    The above code works fine using shape files from the DynamicHeatMap example.
  2. Andrey
    Admin
    Andrey avatar
    1681 posts

    Posted 01 Nov 2011 Link to this post

    Hi Clifford,

    Before using a shape file you should be sure that the map control supports its projection.
    Currently the map control allows to display shape files for the following projections:
    - The Mercator projection EPSG:4326 (default) that refers to WGS84 as (latitude, longitude) pair coordinates in degrees
    - The OSGB-1936 projection which also known as EPSG:27700
    - The EPSG:900913 projection which also known as EPSG:3857 and Pseudo-Mercator projection that refers to WGS84 as (latitude, longitude) pair coordinates in meters

    If you have a shape file which uses other projection, then you should convert it to one of the projections above using third party tools (for example gdal) before you will use it with the map control.

    The attached .zip contains the tl_2010_13_state10.prj file which contains the Spatial Reference Information. The shapes are represented using NAD83 datum.
    I have converted the shape file to Mercator (EPSG:4326) using gdal (http://www.gdal.org/) with the following command:

    ogr2ogr -t_srs WGS84 -s_srs GEOGCS["GCS_North_American_1983",DATUM["D_North_American_1983",SPHEROID["GRS_1980",6378137,298.257222101]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]] tl_2010_13_state10_mercator.shp tl_2010_13_state10.shp

    The converted shape file can be read by the map control without problem. I have attached the converted shape file.

    Regards,
    Andrey Murzov
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  3. UI for WPF is Visual Studio 2017 Ready
Back to Top