Search code examples
google-mapsgeometrykmlgeojsonogr

Convert GeoJson with CRS "name": "urn:ogc:def:crs:OGC:1.3:CRS84" to Google Map lat/long


Currently I am looking a solution to convert geojson file to correct lat-long on google map as below:

well.geojson:

{
    "type": "FeatureCollection",
    "crs": {
        "type": "name",
        "properties": {
            "name": "urn:ogc:def:crs:OGC:1.3:CRS84"
        }
    },
    "features": [{
            "type": "Feature",
            "properties": {
                "WDB_ID": 1,
                "SRC_DATA": "RDI DWQI Database",
                "STD_WELL_I": "RDI_DWQI_1",
                "OTH_WELL_I": null,
                "PROVINCE": "Kampong Cham",
                "DISTRICT": "Batheay",
                "COMMUNE": "Batheay",
                "VILLAGE": "Batheay",
                "VILLAGE_ID": 3010102,
                "CONDITION": null,
                "CONT_NAME": null,
                "CONT_PHONE": null,
                "CONT_QUAL": null,
                "CONT_SECT": null,
                "FACILITY": "School",
                "FACILITY_N": "Unknown",
                "OWNER_NAME": null,
                "OWNER_PHON": null,
                "WGS_E": 494022,
                "WGS_N": 1326178,
                "MSL_APPROX": 9,
                "WELL_TYPE": "Drilled Well",
                "DRI_END_DA": "01-Jan-06",
                "DRI_TOT_DE": 36.0,
                "PUMP_INSTA": "Unknown",
                "PUMP_TYPE": null,
                "PUMP_MODEL": null,
                "PUMP_INST_": null,
                "PUMP_DEP_M": null,
                "PUMP_YIEL_": null,
                "PUMP_RIS_M": null,
                "COORD_SRC": "DATABASE",
                "water qual": "RDI DWQI Database",
                "water qu_1": "RDI_DWQI_1",
                "water qu_2": "27-Feb-08",
                "water qu_3": null,
                "water qu_4": null,
                "water qu_5": null,
                "water qu_6": 7.36,
                "water qu_7": null,
                "water qu_8": null,
                "water qu_9": 0.0,
                "water qu10": 355.0,
                "water qu11": 0.015,
                "water qu12": 3.87,
                "water qu13": 0.0,
                "water qu14": 3.23,
                "water qu15": 342.0,
                "water qu16": null,
                "water qu17": null,
                "water qu18": null,
                "water qu19": null,
                "water qu20": 0.85,
                "water qu21": 0.3,
                "water qu22": 0,
                "water qu23": 2020
            },
            "geometry": {
                "type": "Point",
                "coordinates": [494022.0, 1326178.0]
            }
        },
        {
            "type": "Feature",
            "properties": {
                "WDB_ID": 2,
                "SRC_DATA": "RDI DWQI Database",
                "STD_WELL_I": "RDI_DWQI_2",
                "OTH_WELL_I": null,
                "PROVINCE": "Kampong Cham",
                "DISTRICT": "Batheay",
                "COMMUNE": "Batheay",
                "VILLAGE": "Batheay",
                "VILLAGE_ID": 3010102,
                "CONDITION": null,
                "CONT_NAME": null,
                "CONT_PHONE": null,
                "CONT_QUAL": null,
                "CONT_SECT": null,
                "FACILITY": "Unknown",
                "FACILITY_N": "Unknown",
                "OWNER_NAME": null,
                "OWNER_PHON": null,
                "WGS_E": 494090,
                "WGS_N": 1326303,
                "MSL_APPROX": 7,
                "WELL_TYPE": "Drilled Well",
                "DRI_END_DA": "01-Jan-08",
                "DRI_TOT_DE": 5.0,
                "PUMP_INSTA": "Unknown",
                "PUMP_TYPE": null,
                "PUMP_MODEL": null,
                "PUMP_INST_": null,
                "PUMP_DEP_M": null,
                "PUMP_YIEL_": null,
                "PUMP_RIS_M": null,
                "COORD_SRC": "DATABASE",
                "water qual": "RDI DWQI Database",
                "water qu_1": "RDI_DWQI_2",
                "water qu_2": "27-Feb-08",
                "water qu_3": null,
                "water qu_4": null,
                "water qu_5": null,
                "water qu_6": 6.11,
                "water qu_7": null,
                "water qu_8": null,
                "water qu_9": 0.0,
                "water qu10": 240.0,
                "water qu11": 0.075,
                "water qu12": 1.45,
                "water qu13": 0.18,
                "water qu14": 2.77,
                "water qu15": 128.0,
                "water qu16": null,
                "water qu17": null,
                "water qu18": null,
                "water qu19": null,
                "water qu20": 0.4,
                "water qu21": 0.1,
                "water qu22": 160,
                "water qu23": 36000
            },
            "geometry": {
                "type": "Point",
                "coordinates": [494090.0, 1326303.0]
            }
        }
    ]
}

I try may tool like ogr2ogr and any other online tool. and i get the same error :

using ogr2ogr:

ogr2ogr -f "KML" -overwrite "well.kml" "well2.GeoJSON" -T_SRS EPSG:4326

Error:

ERROR 1: Latitude 1326178.000000 is invalid. Valid range is [-90,90]. This warning will not be issued any more Warning 1: Longitude 494022.000000 has been modified to fit into range [-180,180]. This warning will not be issued any more


Solution

  • Finally, I have found solutions to solve my problem. There are many way for Coordinate system transformation depend on different coordinate system or cartographic projection.

    1- Use https://mygeodata.cloud/cs2cs

    This on-line tool allows you to insert value pairs of geographic coordinates and transform them to different coordinate system or cartographic projection. You can insert value pairs to the text area labeled as "Input coordinate pairs" - also by using copy/paste even from MS Excell or similar programs. This tool accepts various input formats of value pairs - only what you need is to have one pair by a row. Please see examples in the input text area window.

    enter image description here

    2- Use cs2cs command line (Note: I am using Ubuntu)

    cs2cs performs transformation between the source and destination cartographic coordinate system on a set of input points. The coordinate system transformation can include translation between projected and geographic coordinates as well as the application of datum shifts.

    cs2cs +proj=utm +zone=48 +a=6377276.345 +b=6356075.41314024 +towgs84=198,881,317,0,0,0,0 +units=m +no_defs +to +proj=longlat +datum=WGS84 +no_defs  source.geojson > target.geojson
    

    Example : converting-coordinates-with-cs2cs

    3- Use Proj4js

    Proj4js is a JavaScript library to transform point coordinates from one coordinate system to another, including datum transformations. Originally a port of PROJ.4 and GCTCP C it is a part of the MetaCRS group of projects.

    var firstProjection = '+proj=utm +zone=48 +datum=WGS84 +units=m +no_defs';
    var secondProjection = "+proj=longlat +datum=WGS84 +no_defs";
    proj4(firstProjection,secondProjection,[494022.0, 1326178.0]);
    

    Result:

    [104.94123506418815, 11.999521158195288]
    

    I Hope this could help other develop who faced the same problem as me.