Create new map from shape file and then maintain data using dotspatial or ArcGIS

595 Views Asked by At

i am creating a custom map from shapefile with the help of ArcGis. After that how i can plot already stored latlng on the custom map? And if the shapefile updated custom map will updated,How i can maintain the already saved latlng on custom map?

1

There are 1 best solutions below

0
On

Firstly, here is how you can use DotSpatial to add a point and attributes to an existing shapefile.

    [TestMethod]
    public void AddPoint()
    {
        Shapefile shp = Shapefile.OpenFile(@"D:\Data\Temp\CatPoints.shp");
        IFeature cat = shp.AddFeature(new Point((new Coordinate(-119, 39))));
        cat.DataRow["Name"] = "Leopard";
        cat.DataRow["Longitude"] = -119.0000;
        cat.DataRow["Latitude"] = 39.0000;
        shp.Save();
    }

It is important to note that Map documents (.mxd files) don't store the data, so updating the shapefile (.shp) will automatically update the content of your map. In case your question is about how to create a shapefile using longitude and latitude values, here is a walkthrough to create a shapefile, and then save it as a map. If you already have an existing shapefile, you can jump to step 5.

Let's assume you have the initial latitude and longitude in an existing data source like an excel file.

enter image description here

1) Add the Data by using the add data button, browsing to the excel file and choosing the excel sheet.

enter image description here

2) Right click on the "Sheet1$" layer in the Table of Contents and choose Display XY Data...

enter image description here

3) The Longitude and Latitude should populate as the X Field and Y Field automatically. You should use the edit button and select Geographic Coordinate Systems -> World -> WGS1984 as the Coordinate System for Latitude Longitude. (Make sure your longitudes are negative if you are in the western hemisphere like the United States.). Click Ok.

4) Right Click on the newly created Sheet1$ Events layer and choose Data->Export Data... in order to export this layer as a shapefile. Leave the "All features" option chosen, and then specify a name that ends with ".shp". This is important. If you save to a Personal Geodatabase or a File Geodatabase, DotSpatial will not be able to update your content later. Click ok. When it asks if you want to add the newly created shapefile to the map, choose yes.

Create Shapefile

5) Then you can add a basemap to the background, using the File->Add Data->Add Basemap feature. Click on the type of basemap you want to add it.

Add BaseData

6) To add any other existing shapefiles, (or if you already had an existing shapefile that you want to use to create the map), use the add data button, which is the circled plus button over an isometric view of a yellow square.

Add Shapefile

7) Save your map. This is the important part. Whatever layers you have can be stored in ArcGIS as a "Map" document. This doesn't store the actual data itself, but rather simply points to the shapefile. So when you make changes to the shapefile in DotSpatial, those changes will appear in your map.

enter image description here

enter image description here

8) I'm not sure if ArcGIS will automatically pick up the changes to the SHP if it is already open in the user interface. You may need to close the map and open it again in ArcGIS to see your new points.