1

So I am trying to take a GeoJSON file that I have generated from an Esri shapefile in ArcGIS Pro, but it is not rendering on the map for some reason...

The GeoJSON that was created from ArcGIS Pro is here. I have included my current JavaScript below as well. I feel like there might be something wrong with the way the data is formatted or something, I don't really know, as I am unfamiliar with all of this. I left in some commented code that didn't seem to do anything differently, but maybe it can work if a small change is made.

$(document).ready(function () {
    let map = L.map("map").setView([19.042805, -70.581183], 7.2);

    L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
        attribution: '&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
    }).addTo(map);

    $.ajax({
        dataType: "json",
        url: "/static/yaque_del_norte_viewer/GeoJSON/yaque_del_norte.geojson",
        success: function (data) {
            console.log(data);

            let myStyle = {
                "color": "#2427ff",
                "weight": 5,
                "opacity": 0.65
            };

            L.geoJSON(data, {style: myStyle}).addTo(map);

            // let yaqueDelNorteLayer = new L.GeoJSON();
            //
            // $(data.features).each(function (key, data) {
            //
            //     console.log(data);
            //     yaqueDelNorteLayer.addData(data);
            // });

            // console.log(yaqueDelNorteLayer);
            //

            // yaqueDelNorteLayer.setStyle(myStyle);
            //
            // yaqueDelNorteLayer.addTo(map);
        }
    });
});
  • 2
    That GeoJSON says that it is defined in EPSG:4236 but the coordinates are clearly from a projected coordinate system. How did you save it? The coordinates should appear as latitude and longitude values. – wfgeo Feb 18 at 20:36
  • @wfgeo I'm not 100% sure how I saved it, I thought I input the parameter to output to WGS 1984, and that is probably the issue, huh? – Wade Feb 18 at 20:41
  • 2
    A coordinate string like [[237865.08519999962,1954470.2309000008],[240225.97360000014,1956308.3763999995]] is clearly indicative of a projected coordinate system because the numbers are so large. A geographic CRS like WGS84 should have numbers within -180 to 180 and -360 to 360. Try saving it again but be very careful to go through every option to make sure everything is set to EPSG:4326. – wfgeo Feb 18 at 20:43
1

I checked a bit what projected CRS might be used in geojson file. Since Yaque del Norte is a river in Dominican Republic, I asumed that CRS is EPSG:32619 which covers Dominican Republic.

Using Proj4Leaflet plugin I unprojected coordinates in geojson object. Resultant features (rivers) exctly cover Dominican Republic.

Code can be something like:

var epsg32619 = new L.Proj.CRS('EPSG:32619',
  '+proj=utm +zone=19 +datum=WGS84 +units=m +no_defs',                        
  {
   origin: [166021.44, 9329005.18],
   resolutions: [1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1, 0.5],
  }
);

L.geoJSON(data, {
  style: myStyle,
  coordsToLatLng: function (coords) {
    return epsg32619.unproject(L.point(coords));
  }
).addTo(map);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.