ace_mccloud
ace_mccloud

Reputation: 507

ShapeFile Points to Longitude/Latitude

I have loaded my shapefile with the following columns. [NumberOfParts],[ContentLength],[NumberOfPoints],[Points],[RecordNumber],[ShapeType],[XMax],XMin],[YMax],[YMin],[AU12],[NAME].

I successfully derived geo spatialcolumn from the formula geometry::STGeomFromText(Points,4326). Now the issue is I need to get the Longitude/Latitude from the Shapefile. The Shapefile has details for New Zealand. Please help me to derive Latitude/Longitude. I also have a projection file but I have no idea how to use the file to derive Lat/long.

Upvotes: 0

Views: 739

Answers (1)

user1473461
user1473461

Reputation: 369

First, you would probably want to create a Centroid column and use STCentroid() to populate it.

Next, you can derive the latitude / longitude with STX and STY. For the U.S., I use this to export lat/long coordinates: CAST(centroid.STY AS decimal(8,6)) and CAST(centroid.STX AS decimal(9,6)) because the longitude can be up to 3 places to the left of the decimal and latitudes are only 2. New Zealand would be different.

Upvotes: 1

Related Questions