[GIS] GeoJSON data and XYZ (meter) coordinates

geojsongoogle-maps-apitiles

I'm relatively new to mapping. I have some data which I would like to save using the GeoJson format and display on Google Maps (Javascript API v3). This works for my shapes which are in [Lng,Lat] format. I also have some features (Line String) which are in [X,Y] format, where the units of X,Y are meters. I have an origin point which is in [Lng,Lat] format.

I've read a little bit about using Tiles for X,Y coordinates, but if I understand correctly, my X,Y units are pixels, not meters.

Currently I have been saving my X,Y data twice; once as X,Y and once as Lng,Lat (I use google maps geometry tools to translate the X,Y points to Lng,Lat). Is this my only option, or can I save the data in X,Y [meters] with an origin and have it display properly on the map?

Also, the points are 'relatively' close for geo data. The highest X,Y values would be around 3000m.


Edit: Adding (truncated) Sample Data

XY(Z) data with origin. (data is LineString, origin is Point)

{
  "type": "FeatureCollection",
  "features": [
    {
      "geometry": {
        "type": "LineString",
        "coordinates": [
            [
              717,
              1246.3812,
              0
            ],
            [
              703.1146,
              1227.8316,
              0
            ],
            [
              688.9295,
              1209.5377,
              0
            ],
            [
              838.4507,
              1426.9744,
              0
            ]
        ]
      },
      "type": "Feature"
    },
    {
      "geometry": {
        "type": "Point",
        "coordinates": [
          -121.76410900803,
          36.575784480854
        ]
      },
      "type": "Feature"
    }
  ]
}

Same data as above converted to Lng,Lat GeoJson:

    {
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "geometry": {
        "type": "LineString",
        "coordinates": [
          [
            -121.7560874662,
            36.58698064498
          ],
          [
            -121.75624282811,
            36.586814021396
          ],
          [
            -121.75640154205,
            36.586649694817
          ],
          [
            -121.7560874662,
            36.58698064498
          ]
        ]
      }
    }
  ]
}

Clarification, I need the XYZ data for processing server-side (and I want to save those XYZ coordinates for future use), but I want to display the data back on the Google Map, do I need to convert it back to Lng,Lat (2nd data set shown) or can I display the XY(Z) data w/ Lng,Lat origin directly by referencing some specific CRS?

Best Answer

I didn't quite understand where you where going. But I did sense a lack of understanding when it comes to coordinates. I'l try and give a basic overview, hopefully that can point you in the right direction.

  1. You need to tell Google maps what coordinate reference system (CRS) the data you are feeding it with are in. Without this, the XY(Z) values are meaningless. They have to be in relation to something

  2. All XY(Z) values in the Geojson need to be in the same CRS, that is a "limitation" of the file format.

But what CRS do you use? There are thousands!

In most cases it's easiest to stick with the geographic coordinate system WGS84. EPSG: 4326

Note that Latitude, Longitude are not necessarily in WGS84. And two set's of Lat, Longs with identical coordinate values. Might not represent the same place on earth. (Though the difference is usually small)

I do not know what coordinate system your XY(Z) values are in. I hope you do, but I doubt it. :p

You need to figure out that, so that you can convert them to latitudes and longitudes in WGS84. And then dump them to GeoJson and into google maps.

If your XY's are in pixels, you need to georefference your image to a CRS. You don't have to go through a projection to do that, but it helps, as it will minimize distortion and make it more accurate.

Reading up on projections in general is a good place to start. It is fundamental to working with geographic data.