Shapefiles. How do we create them?

17 posts, 0 answers
  1. Jacques
    Jacques avatar
    135 posts
    Member since:
    Jun 2007

    Posted 16 Feb 2012 Link to this post

    Hi there,

    I have a particular requirement for which the Silverlight Telerik RadMap seems to be the right choice. Our client is going to have a floor layout displayed on a communal screen which shows specific attributes of each of the rooms. This might come in the form of TVs, Sattelite televisions and the like.

    Looking at the RadMap samples they have a hotel layout which is great and almost what we need, but looking at the code I found shapefiles and not really much else.

    So the question is... is Shapefiles the best choice for this and if so, how do we create shapefiles?

    Thanks
    Jacques
  2. Andrey
    Admin
    Andrey avatar
    1681 posts

    Posted 16 Feb 2012 Link to this post

    Hello J.Hoventer,

    The RadMap allows to show shapes from KML-files, ESRI shape-files and from database using a collection of rows which contains the WKT or WKB formatted property.For more information you can take a look at the following documentation topic and online examples:
    http://www.telerik.com/help/silverlight/radmap-features-kml-data-import.html
    http://www.telerik.com/help/silverlight/radmap-features-information-layer-shape-reder.html
    http://www.telerik.com/help/silverlight/radmap-features-sql-geospatial-data.html
    http://demos.telerik.com/silverlight/#Map/USA
    http://demos.telerik.com/silverlight/#Map/Shapefile/World
    http://demos.telerik.com/silverlight/#Map/WktReader

    The original tool to create and edit shape files is ArcGIS. There are several other tools available which you can find in Internet. As I know few of our clients use the MapWindows GIS to create shape files with success. You just need to save files using projection which is supported currently by RadMap. Currently Geospatial data can be represented using the following projections which are supported by the map control:
    - 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

    Kind regards,
    Andrey Murzov
    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
  3. DevCraft banner
  4. Jacques
    Jacques avatar
    135 posts
    Member since:
    Jun 2007

    Posted 21 Feb 2012 Link to this post

    Hi Andrey,

    Are any of those links and the information you provided specific to floor plan type scenarios?

    Regards,
    Jacques
  5. Andrey
    Admin
    Andrey avatar
    1681 posts

    Posted 21 Feb 2012 Link to this post

    Hello Jacques,

    No, they aren't specific to floor plan type scenarios. These links demonstrates different approaches and data sources which can be used to show geometric figures using the RadMap control.

    All the best,
    Andrey Murzov
    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
  6. Jacques
    Jacques avatar
    135 posts
    Member since:
    Jun 2007

    Posted 21 Feb 2012 Link to this post

    Ok, normally with this kind of work there's a heavy penalty in terms of learning curve which we're wanting to manage/reduce as much as possible.

    So the question is... How did you guys do the Hotel example? What software did you use to create the floor plan? Because that's what I need to do.

    Regards,
    Jacques
  7. Jacques
    Jacques avatar
    135 posts
    Member since:
    Jun 2007

    Posted 24 Feb 2012 Link to this post

    Anyone from Telerik know how you created the Hotel floor plan demo for the Silverlight Map control?
  8. Jacques
    Jacques avatar
    135 posts
    Member since:
    Jun 2007

    Posted 24 Feb 2012 Link to this post

    Seems like a simple question to me.... How did you guys create the Hotel or even the Auditorium shapefiles?
  9. Andrey
    Admin
    Andrey avatar
    1681 posts

    Posted 24 Feb 2012 Link to this post

    Hello Jacques,

    Actually the answer on your question exist in my first post. We've used ArcGIS to create and edit several ESRI shape files which represents floor plan. Then we've used RadMap features to show these files.

    Regards,
    Andrey Murzov
    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
  10. Jacques
    Jacques avatar
    135 posts
    Member since:
    Jun 2007

    Posted 24 Feb 2012 Link to this post

    Sorry about that.

    I've tried Quantum and MapWindow, but it seems there's very limited tutorials out there for it.

    Do you know of any resources for a novice to learn how to create Shapefiles?

    I opened up the Hotel_Rooms.shp file in MapWindow, but it complained that there was no dbf data file associated even though it is in the same directory... it doesn't ask to associate the file though. ?

    Again, my apologies for missing that point about ArcGIS.

    Regards,
    Jacques
  11. Andrey
    Admin
    Andrey avatar
    1681 posts

    Posted 27 Feb 2012 Link to this post

    Hello Jacques,

    I suppose that you didn't read the error MapWindow message carefully and it was about the .SHX file, not the .DBF file. The RadMap control displays shp-file or shp / dbf pair without using the shx-file. So, our examples do not contain them.

    You can use a 3-rd party tool called Shape Viewer to create the shx-file from shp-file. It is a free tool, which you can use to view  the ESRI Shape files. You can download it using the following link:

    http://www.qarah.com/shapeviewer/

    When you create the shx-file then you can use tools like ArcGIS or MapWindow to edit the shape file.

    Unfortunately we don't have any information about resources for a novice to learn how to create Shapefiles. But I suppose that you can find some in the Internet.

    Kind regards,
    Andrey Murzov
    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
  12. Jacques
    Jacques avatar
    135 posts
    Member since:
    Jun 2007

    Posted 29 Feb 2012 Link to this post

    Hi Andrey,

    I'm finally able to draw a basic shape and have the RadMap control pull it into the Silverlight application, but when it does pull it in, the shape is vastly different from what I drew in QGIS. I drew a basic rectangle, when it shows in RadMap the shape comes out still as a rectangle, but nowhere near the same dimensions, even the length of the rectangle changes from a vertical to a horizontal.

    Any ideas where I'm going wrong with this?

    Regards,
    Jacques
  13. Andrey
    Admin
    Andrey avatar
    1681 posts

    Posted 29 Feb 2012 Link to this post

    Hello Jacques,

    Mostly it occurs because of the projection which has been used to create the shape file. It is different from the one used to show it. The RadMap control by default uses Mercator projection with latitude and longitude given in degrees. With Mercator projection the same vertical distance in degrees have different size in pixels depending on the latitude. i.e. if you have a rectangle with width and height equal to 1 degree it will look different on the equator and close to the pole.

    Regards,
    Andrey Murzov
    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
  14. Jacques
    Jacques avatar
    135 posts
    Member since:
    Jun 2007

    Posted 29 Feb 2012 Link to this post

    Is projection the same as Coordinate Reference System?

    I'm using EPSG:4326 - WGS 84 as the CRS, which is what you guys mention quite frequently in the forums. The shapes however still don't display correctly.

    I'm retesting now again and the shapefile won't load into RadMap at all anymore. It flashes in the browser for a second before disappearing.

    Regards,
    Jacques
  15. Jacques
    Jacques avatar
    135 posts
    Member since:
    Jun 2007

    Posted 29 Feb 2012 Link to this post

    I have the following XAML:
    <UserControl x:Class="Accentronix.Floorplan.MainPage"
            mc:Ignorable="d" d:DesignWidth="640" d:DesignHeight="480">
        <UserControl.Resources>
            <ImageBrush x:Key="exampleBackground" Stretch="UniformToFill" ImageSource="/Floorplan;component/Images/BaseImage.png"/>
        </UserControl.Resources>
        <Grid x:Name="TopGrid" Background="White" ShowGridLines="True">
            <Grid.RowDefinitions>
                <RowDefinition Height="*" />
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="200"></ColumnDefinition>
                <ColumnDefinition Width="*"></ColumnDefinition>
            </Grid.ColumnDefinitions>
            <StackPanel Grid.Row="0" Grid.Column="0">
                <Button x:Name="LoadShapefile" Click="LoadShapefile_Click" Content="Load Shapefile" ></Button>
                <TextBlock x:Name="MyTextBlock" Text="Test: 11" />
            </StackPanel>
            <Grid x:Name="LayoutRoot" Background="{StaticResource exampleBackground}" Grid.Row="0" Grid.Column="1"
                  HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
                    <telerik:RadMap x:Name="MyMap" HorizontalAlignment="Stretch"
                            Margin="12,12,0,0" VerticalAlignment="Stretch"
                            Background="Transparent"
                            MouseDragMode="None" CommandBarVisibility="Collapsed" IsMouseWheelZoomEnabled="False" IsKeyboardNavigationEnabled="False"
                            NavigationVisibility="Collapsed" ScaleVisibility="Collapsed"
                            FlowDirection="LeftToRight"
                            ZoomBarPresetsVisibility="Collapsed"
                            ZoomBarVisibility="Visible">
                        <telerik:RadMap.Provider>
                            <telerik:EmptyProvider />
                        </telerik:RadMap.Provider>
                        <telerik:InformationLayer x:Name="informationLayer">
                            <telerik:InformationLayer.ShapeFill>
                                <telerik:MapShapeFill Fill="Transparent"  Stroke="Red" StrokeThickness="5" />
                            </telerik:InformationLayer.ShapeFill>
                        </telerik:InformationLayer>
                    </telerik:RadMap>
            </Grid>
        </Grid>
    </UserControl>

    and the following C#:
    public partial class MainPage : UserControl
        {
            private Uri[] _UriList = {
                new Uri("/Floorplan;component/Images/Rooms.shp", UriKind.RelativeOrAbsolute),
                new Uri("/Floorplan;component/Images/Rooms.dbf", UriKind.RelativeOrAbsolute)};
            private List<MapShape> _Rooms = new List<MapShape>();
            private MapShape _CurrentSelectedShape;
            private Dictionary<LocationRect, ExtendedData> locationList = new Dictionary<LocationRect, ExtendedData>();
            #region CONSTRUCTOR - ()
            public MainPage()
            {
                InitializeComponent();
                MyTextBlock.Text += Environment.NewLine;
                _Trace("Constructor Fired...");
            }
            #endregion
            private void MapShapeReader_PreviewReadCompleted(object sender, Telerik.Windows.Controls.Map.PreviewReadShapesCompletedEventArgs eventArgs)
            {
                _Trace("Preview Read Completed...");
            }
            private void MapShapeReader_ReadCompleted(object sender, Telerik.Windows.Controls.Map.ReadShapesCompletedEventArgs eventArgs)
            {
                _Trace("Read Completed...");
            }
     
            private void LoadShapefile_Click(object sender, RoutedEventArgs e)
            {
                try
                {
                    StreamResourceInfo shapeResourceInfo = Application.GetResourceStream(new Uri("/Floorplan;component/Images/Rooms.shp", UriKind.RelativeOrAbsolute));
                    _Trace("************shape resource created*******************");
                    StreamResourceInfo dbfResourceInfo = Application.GetResourceStream(new Uri("/Floorplan;component/Images/Rooms.dbf", UriKind.RelativeOrAbsolute));
                    _Trace("************dbf resource created*******************");
                    List<FrameworkElement> shapes = ShapeFileReader.Read(shapeResourceInfo.Stream, dbfResourceInfo.Stream);
                    _Trace("number of shapes found: " + shapes.Count.ToString());
                    foreach (var shape in shapes)
                    {
                        _Trace("information layer is null: " + (informationLayer == null).ToString());
                        _Trace("information layer items is null: " + (informationLayer.Items == null).ToString());
     
                        //this.informationLayer.Items.Add(shape);
                    }
                  
                }
                catch (Exception ex)
                {
                    _Trace(ex.Message);
                }
            }
            private void _Trace(string message)
            {
                MyTextBlock.Text += message + Environment.NewLine;
            }
        }

    The application loads fine with an image loading into the background which forms the backdrop for our floor pan, but when I click the button to load the shapefile the screen goes blank?

    I tried uploading the shapefiles too, but this forum doesn't allow that.

    Is there something obvious I'm doing wrong?

    Regards,
    Jacques
  16. Andrey
    Admin
    Andrey avatar
    1681 posts

    Posted 01 Mar 2012 Link to this post

    Hello Jacques,

    It is hard to say what is wrong with your application without your shape file. Please, open a formal support (not Forum) ticket and attach your whole solution so we could check what is wrong.

    Regards,
    Andrey Murzov
    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
  17. pam
    pam avatar
    1 posts
    Member since:
    Jun 2012

    Posted 01 Jun 2012 Link to this post

     

    Hello J,

     

    Did you get it working?

    Because we are trying the same thing “ a floor plan app” but in sounds like Chinese to me.

    If you found the solution would you be so kind to share it with me in the way of a example... please please please

  18. Andrey
    Admin
    Andrey avatar
    1681 posts

    Posted 06 Jun 2012 Link to this post

    Hi Peter,

    Unfortunately we don't have such kind of tutorial. The major part of such tutorial would be creation of the shape files using different 3d party tool (ArcGIS, for example) which is outside of the support scope for the RadMap control. There are several commercial and free tools which allow you to create shape files. You have to select a tool and learn how to use it by yourself. Using the shape files in RadMap is quite easy and is described in our demo with source code and documentation.

    Regards,
    Andrey
    the Telerik team

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

Back to Top
DevCraft banner