Shapefile Coordinates – Extracting Longitude and Latitude from Object

coordinateslatitude longitudeshapefile

I'm new to GIS and (ESRI) shapefile. I would like to extract GPS-Coordinates or longitude and latitude from every object in a shapefile, mainly from polygons.

Here is a picture with one of these objects:
enter image description here

My plan is to create a GPS-System App where the user can search for that object and my app leading them to the desired object. Is this even possible?

There are somewhere GPS-Coordinates in the Shapefile, because Google Maps can find my shapefile on the map, see here:

enter image description here

So now I would like to know GPS-Coordinates from every Object in that Shapefile, so every colorful object you can see in that picture above.

Best Answer

To my knowledge, Google Earth Pro does not directly have a way to provide you with the lat/long of the centroids of the polygons in your shapefile. It is possible to export out the coordinates (may not be lat/long) of the vertices of the polygons, as described in this video: https://www.youtube.com/watch?v=dlWhGSIXm1U. However, this will be a cleaner process if you work directly with the shapefile in a GIS application such as QGIS.

The following assumes you want one lat/long pair for each polygon centroid as a CSV file.

First, you want to be sure of what coordinate system the shapefile is using. Per https://opensourceforu.com/2015/03/assigning-map-projections-in-qgis :

Right click on the layer under the Layers window on the left side of the QGIS window. Next, under the Properties window, click on the Metadata tab. The CRS assigned to the layer can be seen under the label Layer Spatial Reference System

If you do not have a geographic coordinate system assigned such as WGS84, your data will be in meters or feet rather than degrees. Coordinate systems are a deeper topic that you can explore elsewhere on the site or in tutorials. Todd Vachon's article gives a brief overview.

Basically, there’s a whole slew of methods of translating spherical map data (the earth) onto a flat surface (a paper map or your screen). The different methods are called coordinate reference systems (CRS). To translate x and y coordinate data you may have into latitude and longitude data, you’ll need to figure out what CRS you’re starting from and ‘project’ it to another one.

Once you have the data in WGS84, which has degrees as its unit and the coordinates are in lat/long, you can extract and export the centroids of each polgyon. The post linked by @FSimardGIS can help. You can create a centroid layer and add the coordinates directly to that layer as described by @Curlew, or you can simply create the centroids and save the layer to CSV format as described in Vachon's article:

Once your data is in the WGS 84 / World Mercator projection it will have latitude and longitude data. Here’s how to get it back out of QGIS (v1.8): Right-click on your data layer and choose ‘Save As…’ [...] Click the Browse button and choose a name and location to save the file to. The CRS field should show ‘WGS 84′(ESPG: 4326). In the’Layers’ text box, type ‘GEOMETRY=AS_XY’**. You should now have a file that contains your original data and the new latitude and longitude coordinates.