0

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.

BR75
  • 447
  • 4
  • 14
  • 4
    Welcome to GIS.SE. Some more information would be helpful, e.g. the software you're working with, and what you tried so far. – Erik Jan 17 '19 at 14:25
  • Shapefile always makes me think ESRI software, but I concur we need to know more, especially the software. Also what part of the polygon are you looking to identify the coordinates of, the centroid, each vertex, it's min/max binding coordinates. – Pete Jan 17 '19 at 14:31
  • I'd like to clarify that there really is no such thing as GPS coordinates, it may seem trite but I hear this all the time. GPS is Global Positioning System, it's a network of satellites, control stations monitoring attitude of the satellites and the GPS receiver. At it's core the GPS will report geographic coordinates in angular measurement of Latitude and Longitude, but it can transform those on-the-fly to any number of projected coordinate systems. Its a very complex system that measures location, and those locations can be calculated a number of ways. – Pete Jan 17 '19 at 14:36
  • extract polygon centroids andd export lon, lat – RutgerH Jan 17 '19 at 14:42
  • 3
    See for example: https://gis.stackexchange.com/questions/32414/is-it-possible-to-extract-coordinates-of-polygon-centroid-in-qgis – cokrzys Jan 17 '19 at 14:57
  • ESRI Shapefiles, yes. I want the coordinates from the centroid of the polygon which I selected in my picture (the red one). I just imported the Shapefile in "google earth pro" and it automatically zoomed in to the right location on the map, so there are GPS coordinates somewhere but I can't find where are they stored. – BR75 Jan 17 '19 at 15:05
  • If you have access to QGIS, check out this related post, it could be helpful, it shows how to calculate the centroid of polygons and add the coordinates as attributes. Use WGS84 crs for the calculation to get longitudes and latitudes. – FSimardGIS Jan 17 '19 at 15:21
  • 1
    While it is possible to extract the lat/long of the vertices of the polygons in Google Earth Pro, extacting the centroids is not a straight-forward option. If you have access to ArcGIS Desktop/Pro (requires a license) or QGIS (open source), these tasks can be completed fairly quickly. See @RutgerH's comment above. – SMiller Jan 17 '19 at 15:21
  • lat/long of the vertices would be enough. I opened my shapefile in qgis and peeked into the attribute table but there are no coordinates or even that looked like similar. But most important to clarify, we are talking about lat/long I can copy and paste into google maps right? – BR75 Jan 17 '19 at 15:41
  • 1
    Coordinates do not generally exist in the dBase attribute table. Slightly more often with points, but exceedingly rare with polygons. Computing a centroid which is within the figure is more difficult than a center of mass point. – Vince Jan 17 '19 at 16:29
  • Here's another question which explains how to create centroids of polygons in QGIS: https://gis.stackexchange.com/questions/45243/how-to-determine-the-centroid-of-polygons. Note you may need to reproject your data, for instance into WGS84, if the data is a projected coordinate system. – SMiller Jan 17 '19 at 16:52
  • I think we talk past one another. Even if I have the centroid of every polygon, how I know where this polygon is outside of the shapefile?

    In the end I would like to find the shortest path to that polygon, like TomTom or Garmin does. So I need GPS coordinates of every polygon. How google earth pro does this?

    – BR75 Jan 17 '19 at 18:22
  • Yes I have QGIS – BR75 Jan 18 '19 at 15:06
  • Since you commented above that you looked at the file in QGIS, first identify what coordinate system the file is using. It may be projected, in which case the coordinates (xy values) are in meters or feet, for example. If it's in a geographic coordinate system such as WGS84, then the values should be in lat/long. You can save this back out to a CSV to directly view the coordinates, as described in this post: http://www.toddvachon.com/2013/01/stuff-ive-learned-using-qgis-to-find-latitude-and-longitude-from-x-and-y-coordinates/328 – SMiller Jan 18 '19 at 15:08
  • This article talks about viewing CRS in QGIS: https://opensourceforu.com/2015/03/assigning-map-projections-in-qgis/ – SMiller Jan 18 '19 at 15:17

1 Answers1

0

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.

SMiller
  • 3,706
  • 9
  • 22
  • Thank you very much, that's exactly what I asked for. Now I have a Centroid with lat/long in every polygon in my Shapefile. – BR75 Jan 21 '19 at 12:02