2

I am using DotSpatial 1.7 in my win form app. I have an image (original image) downloaded from Universal Map Downloder and then loaded this file with a shapefile in QGIS and then georeferencing the image in QGIS using shapefile to produce an image that matches with shapefile (modified image).

Now: I used code below to load two files in my app (shapefile and original image) and it works well and I can select the shapefile:

private void Form1_Load(object sender, EventArgs e)
{
    map1.AddLayer(@"C:\originalimage.png");
    map1.AddLayer(@"C:\shapefile.shp");

    MapPolygonLayer polygonLayer = default(MapPolygonLayer);
    polygonLayer = (MapPolygonLayer)map1.Layers[1];

    polygonLayer.Symbolizer = new PolygonSymbolizer(Color.FromArgb(0, Color.White), Color.DeepSkyBlue);

    map1.FunctionMode = FunctionMode.Select;
}

But, the code below:

private void Form1_Load(object sender, EventArgs e)
{
    //map1.AddLayer(@"C:\originalimage.png");
    map1.AddLayer(@"C:\modifiedimage.tiff");
    map1.AddLayer(@"C:\shapefile.shp");

    MapPolygonLayer polygonLayer = default(MapPolygonLayer);
    polygonLayer = (MapPolygonLayer)map1.Layers[1];

    polygonLayer.Symbolizer = new PolygonSymbolizer(Color.FromArgb(0, Color.White), Color.DeepSkyBlue);

    map1.FunctionMode = FunctionMode.Select;
}

I can not select the shapefile (modified image is on the shapefile ). I also convert the .tiff to .png, but it is on the shapefile.

Any idea/solution?

1 Answer 1

2

The problem is for projection. Shapefile is shown as a very very little layer in the bottom left corner of the image. I have no problem with these files in QGIS.

Also see the DotSpatial Documentation or https://stackoverflow.com/questions/29122130/raster-data-loading-from-filepath-in-dotspatial.

Add code below:

 IRaster r = Raster.Open(@"C:\modifiedimage.tiff");
        DotSpatial.Projections.ProjectionInfo dest = default(DotSpatial.Projections.ProjectionInfo);
        dest = DotSpatial.Projections.ProjectionInfo.FromEpsgCode(4326); 
        r.Projection = dest;
        IMapRasterLayer myLayer = map1.Layers.Add(r);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.