Register  |  Login
ThinkGeo - GPS Tracking and Mapping Solutions  |  Visit the Wiki  |  Find us on: Twitter Facebook Google+ LinkedIn

Discussion Forums

The online community for users of Map Suite GIS components

Read Dbf Record of Shapfile and Get Lat/Long
Last Post 03-15-2012 09:18 AM by Val. 3 Replies.
Printer Friendly
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
DennisUser is Offline
Level 3
Level 3
Posts:74
Avatar

--
03-13-2012 10:10 PM

I am wanting to read each record of a streets centerline dbf file and for each record get its corresponding Lat/Long.

Are there any MapSuite API's that would help me in this endeavor?

Thanks,

Dennis

 

ValUser is Offline
MVP
MVP
Posts:1634
Avatar

--
03-14-2012 04:25 PM

Dennis,

 You are not giving us a lot of information on your shapefile so let me assume that you have a line based shapefile representing streets. You want to get the Lat/Long of the mid point of each street. We have the API for doing that and basically you would have to follow those steps:

-Loop thru all the street records.

-Get the Geometry of each street (MultilineShape)

-Get the mid point of the MultilineShape

-Do the necessary projection conversion if your shapefile is in a projection other than WGS84 (decimal degrees)

 Is that indeed what you are looking for to do?

Thank you.

DennisUser is Offline
Level 3
Level 3
Posts:74
Avatar

--
03-14-2012 07:01 PM
Val,

Thanks for responding.

Yes, the shapefile is line based representing streets.

I would actually like to retrieve the Lat/Long of the endpoints of each shape.

The API you mention, it is suitable for this? Is it part of the development toolkit? What is the name?

Thanks,
Dennis
ValUser is Offline
MVP
MVP
Posts:1634
Avatar

--
03-15-2012 09:18 AM

Dennis,

 Assuming that your street shapefile is already in Decimal Degrees, to get the longitude and latitude of the first and last end point of each line, you could use the code as below. Here, I get a string of the Lat/Long value formated to degrees minutes and seconds but you are free to get it as you want. If your shapefile is in a projection other than decimal degrees, you will have to do some projection conversion in addition.

 


  lineShapefileFeatureLayer.Open();
    Collection<Feature> features = lineShapefileFeatureLayer.FeatureSource.GetAllFeatures(ReturningColumnsType.NoColumns);

    foreach (Feature feature in features)
    {
        MultilineShape multilineShape = (MultilineShape)feature.GetShape();
        string startLong = DecimalDegreesHelper.GetDegreesMinutesSecondsStringFromDecimalDegree(multilineShape.Lines[0].Vertices[0].X);
        string startLat = DecimalDegreesHelper.GetDegreesMinutesSecondsStringFromDecimalDegree(multilineShape.Lines[0].Vertices[0].Y);

        Vertex endVertex = multilineShape.Lines[multilineShape.Lines.Count -1].Vertices[multilineShape.Lines[multilineShape.Lines.Count -1].Vertices.Count -1];
        string endLong = DecimalDegreesHelper.GetDegreesMinutesSecondsStringFromDecimalDegree(endVertex.X);
        string endLat = DecimalDegreesHelper.GetDegreesMinutesSecondsStringFromDecimalDegree(endVertex.Y);
    }

    lineShapefileFeatureLayer.Close();
You are not authorized to post a reply.

Active Forums 4.2