ThinkGeo.com    |     Blog    |     Wiki    |     Support

To display .png or jpeg image

Hi,
I want to plot points on map having image of type .png or .jpg or .tif as background.
as given in web edition i tried but at a time i am able to view only image or points…
i want both points and image to display on map at a time.
Please help
Thanks in advance

Hi Mouni,

I think that’s the order reason.

If you put the image layer and point layer into the same overlay, you should want to add the image layer first, then add the point layer.

If you put them into different overlay, you can set the image over IsBaseOverlay equal true.

Please let me know whether it works.

Regards,

Ethan

Hi Ethan,
Thank you for your reply.I made image as a BaseOverlay,but my output loooks like this.Here i have attached output file
And also I want to know how to convert Latitude and longitude into Easting and Northing.
I used following formulae to convert latitude n longitudein to easting and northing.
longitude = DecimalDegreesHelper.GetDecimalDegreeFromDegreesMinutesSeconds(int.Parse(strLong1), int.Parse(strLong2), double.Parse(strLong3));
latitude = DecimalDegreesHelper.GetDecimalDegreeFromDegreesMinutesSeconds(int.Parse(strLat1), int.Parse(strLat2), double.Parse(strLat3));
And my points are: 1)182738.23,734806.11 2)182736.25,734806.38 3)182736.28,734805.37


Any help will be appreciated.

Thank you
Regards,
Mouni

Hi Mouni,

It looks your questions have a little confused.

Please let me know if I misunderstand it:

  1. You already known how to convert from DMS to DecimalDegree, now you want to know how to convert DecimalDegree to UTM (Universal Transverse Mercator) coordinate system (??), it looks the Easting and Northing is based on simple Cartesian coordinate system, and for DecimalDegree, easting is longitude and northing is latitude. In fact I think you should talked about reproject, because the map unit of your coordinates looks equal meter. If so please let me know what’s the new projection, and we have Proj4Projection class for convert it.

  2. What’s the screen shot means? It looks your point is out of your background image, so I think maybe the coordinates of it is incorrect? Have you tried the suggestion about added order in my previous reply?

Regards,

Ethan

Hi Ethan
Actually,i set order also.And i cross checked points with cad.I set projection also.though my points and image are not at proper position.Here i am attaching my code.
please help me out

Map1.MapBackground.BackgroundBrush = new GeoSolidBrush(GeoColor.StandardColors.White);
Map1.CurrentExtent = new RectangleShape(-125, 72, 50, -46);
GdiPlusRasterLayer gdiPlusImageLayer = new GdiPlusRasterLayer(MapPath(@"~\Images\47F_14_001_1.tif"), new RectangleShape(-80.5, 68.9, 80, -60.43));
gdiPlusImageLayer.UpperThreshold = double.MaxValue;
gdiPlusImageLayer.LowerThreshold = 0;
Map1.StaticOverlay.Layers.Add(gdiPlusImageLayer);

            LayerOverlay ImageOverlay = new LayerOverlay();
            ImageOverlay.TileType = TileType.SingleTile;
            ImageOverlay.IsBaseOverlay = true;
            ImageOverlay.Layers.Add("ImageLayer", gdiPlusImageLayer);
            Map1.CustomOverlays.Add(ImageOverlay);

            InMemoryFeatureLayer mapShapeLayer = new InMemoryFeatureLayer();
            mapShapeLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle = PointStyles.City2;
            mapShapeLayer.ZoomLevelSet.ZoomLevel01.DefaultLineStyle = LineStyles.CreateSimpleLineStyle(GeoColor.StandardColors.BlueViolet, 3, true);
            TextStyle pttext = new TextStyle("DescOfPillars", new GeoFont("Arial", 8, DrawingFontStyles.Bold), new GeoSolidBrush(GeoColor.FromArgb(255, 0, 0, 0)));
            pttext.XOffsetInPixel = 10;
            pttext.DuplicateRule = LabelDuplicateRule.NoDuplicateLabels;
            pttext.BestPlacement = true;
            mapShapeLayer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle = pttext;

            mapShapeLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
            mapShapeLayer.InternalFeatures.Add("NDA", new Feature(NDA));
            mapShapeLayer.InternalFeatures.Add("LOHAGAON", new Feature(Lohagaon));
            /*mapShapeLayer.InternalFeatures.Add("P1", new Feature(new PointShape(18.46061944, 73.80166667)));
            mapShapeLayer.InternalFeatures.Add("P2", new Feature(new PointShape(18.46037778, 73.80166667)));
            mapShapeLayer.InternalFeatures.Add("P3", new Feature(new PointShape(18.46032500, 73.80222222)));
            mapShapeLayer.InternalFeatures.Add("P4", new Feature(new PointShape(18.46203889, 73.80222222)));*/
            mapShapeLayer.InternalFeatures.Add("P5", new Feature(new PointShape(379715.4327, 2049005.4615)));
            Proj4Projection proj4 = new Proj4Projection();
            proj4.InternalProjectionParametersString = Proj4Projection.GetEpsgParametersString(32643);
            proj4.ExternalProjectionParametersString = Proj4Projection.GetGoogleMapParametersString();
            mapShapeLayer.FeatureSource.Projection = proj4;
            LayerOverlay dynamicOverlay = new LayerOverlay();
            dynamicOverlay.TileType = TileType.SingleTile;
            dynamicOverlay.IsBaseOverlay = false;
            dynamicOverlay.Layers.Add("InMemoryFeatureLayer", mapShapeLayer);
            Map1.CustomOverlays.Add(dynamicOverlay);

Regards,
Mouni

Hi Ethan,
can you please provide me formula to convert Latitude and Longitude to easting and northing.
For example:
Latitude: N18° 31’ 41.53"
Longitude: E73° 51’ 37.39"
After conversion my respective easting and northing are:
Easting: 379715.4327
Nothing: 2049005.4615

Regards,
Mouni

Hi Mouni,

I research it and found the Easting and Northing coordinate system need have a zero point. And this system generally is UTM.


Easting and northing coordinates are commonly measured in metres from a horizontal datum. The coordinates are most commonly associated with the Universal Transverse Mercator coordinate system (UTM), which has unique zones that cover the Earth to provide detailed referencing.


And for UTM, it looks each zone have special SRID, for example EPSG:8456 means “UTM zone 54S”.

So if you want to calculate the Easting and Northing values, you need to know which zone it is and found the srid about it. Please check that.

Then you can use our projection class to reproject the LatLon values to your Easting and Northing values.

Regards,

Ethan

Thank you Ethan for your help.
Now i am showing Names to points.

Hi,
I am giving name to point but its not showing.I am not using any point name shape file.Below is my code

InMemoryFeatureLayer mapSubShapeLayer = (InMemoryFeatureLayer)((LayerOverlay)(Map1.CustomOverlays[0])).Layers[“InMemoryFeatureLayer”];
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
int pn=i + 1;
string pointName = “P” + pn;
mapSubShapeLayer.InternalFeatures.Add(“LT” + i, new Feature(new PointShape(latitude, longitude, 0.0000)));
mapSubShapeLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle = new PointStyle(PointSymbolType.Circle, new GeoSolidBrush(GeoColor.StandardColors.Black), 5);
TextStyle pttext = new TextStyle(pointName, new GeoFont(“Arial”, 8, DrawingFontStyles.Bold), new GeoSolidBrush(GeoColor.FromArgb(255, 0, 0, 0)));
pttext.XOffsetInPixel = 10;
pttext.DuplicateRule = LabelDuplicateRule.NoDuplicateLabels;
pttext.BestPlacement = true;
mapSubShapeLayer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle = pttext;
}
((LayerOverlay)Map1.CustomOverlays[0]).Redraw();

Please guide me

Regards,
Mouni

Hi Mouni,

I modified your code here, you can view it and see where is the different.

 protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            Map1.MapUnit = GeographyUnit.DecimalDegree;

            InMemoryFeatureLayer mapSubShapeLayer = new InMemoryFeatureLayer();
            mapSubShapeLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle = new PointStyle(PointSymbolType.Circle, new GeoSolidBrush(GeoColor.StandardColors.Black), 5);
            TextStyle pttext = new TextStyle("label", new GeoFont("Arial", 8, DrawingFontStyles.Bold), new GeoSolidBrush(GeoColor.FromArgb(255, 0, 0, 0)));
            pttext.XOffsetInPixel = 10;
            pttext.DuplicateRule = LabelDuplicateRule.NoDuplicateLabels;
            pttext.BestPlacement = true;
            mapSubShapeLayer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle = pttext;
            mapSubShapeLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

            Collection<Vertex> points = new Collection<Vertex>();
            points.Add(new Vertex(10, 10));
            points.Add(new Vertex(20, 5));
            points.Add(new Vertex(-5, -8));
            points.Add(new Vertex(15, -3));
            points.Add(new Vertex(-12, 25));

            for (int i = 0; i < points.Count; i++)
            {
                int pn = i + 1;
                string pointName = "P" + pn;
                Feature f = new Feature(new PointShape(points[i].X, points[i].Y, 0.0000));
                f.ColumnValues.Add("label", pointName);
                mapSubShapeLayer.InternalFeatures.Add("LT" + i, f);
            }

            LayerOverlay overlay = new LayerOverlay();
            overlay.Layers.Add("InMemoryFeatureLayer", mapSubShapeLayer);

            Map1.CustomOverlays.Add(overlay);

            mapSubShapeLayer.Open();
            Map1.CurrentExtent = mapSubShapeLayer.GetBoundingBox();

            //((LayerOverlay)Map1.CustomOverlays[0]).Redraw();                
        }
    }

Wish that’s helpful.

Regards,

Ethan

Hi Ethan,
Thank you for your solution.I made changes accordingly in my code but still i’,m unable to view point names.Also i run your code as it is but its not showing me point names.
Here is an image

please guide me

Regards,
Mouni

Hi Mouni,

That’s strange because the code works well in my machine, could you please try the attached sample and see whether it works? I think maybe that’s not the problem about code.

9538.zip (173.7 KB)

If it works, you can compare the sample and find where is the different.

Regards,

Don

hi Ethan,
Thank you for your help.
Here i’m attaching my solution,please have a look once.I have plotted 3 points.But i’m unable to view point names.Here i have off image layer.And particular code related to that is also commented.
WebApplication1.zip (2.5 MB)

Thank you in advance
Regards,
Mouni

Hi Mouni,

Thanks for your sample, it looks you can make it works by add two lines like this:

          InMemoryFeatureLayer mapShapeLayer = new InMemoryFeatureLayer();
          mapShapeLayer.Open();
          mapShapeLayer.Columns.Add(new FeatureSourceColumn("label"));

Wish that’s helpful.

Regards,

Ethan

Hi Ethan,
Thank you so much.This solution worked.

Regards,
Mouni

Hi Mouni,

I am glad to hear that’s helpful.

Any question please let us know.

Regards,

Ethan

Hi Ethan,
can i crop some portion of a map and only display the cropped one in web edition.Actually i am trying in my solution but the part of map which i want to display is getting cropped.My actual output is Image2
but i am getting Image1 as my output.
Image2:

Image1:

Thank you in advance
Regards,
Mouni

Hi Mouni,

It’s a little confused, do you means you want to get the Image1 but you only can get Image2?

The API of our map can only get images inside target bouding box, if you want to get Image2, I think you can call API to do that, but if you want to get Image1, I think you can get the big image, and then crop it by your custom code, map API cannot handle that.

And I think maybe you can do something like this, it looks you cut the area which contains your points, so you can get the bouding box(rectangle A) of your points, then add a new layer above your image, add the feature(it’s the rectangle A) into it, and set the style as the white, then get the image.

Wish that’s helpful.

Regards,

Ethan