[GIS] Coordinates offset when using Mapshaper to convert shapefile to GeoJSON

convertgeojsonmapshapershapefile

I'm a newbie to the GIS world and I'm trying to convert a shapefile to GeoJSON for use in Mapbox.

When I view the resulting layer in Mapbox, most of the features appear southeast by 20-30 feet of where they should be to match up properly with the underlying Mapbox map. (View at http://blueroomdesign.net/stlv/)

How do I adjust the Mapshaper command to fix this offset issue?

Here's the command line I'm currently using to convert it:

mapshaper -i prcl.shp -proj latlon -o prcl_out.geojson precision=0.000001

Some of the information from running the Mapshaper Info command on the shp file (below) looks relevant but I'm not quite sure how to interpret it or correct for it in the conversion process.

Layer name: prcl
Records: 127,748
Geometry
Type: polygon
Bounds: 551318.459568 982946.566771 592589.572865 1070913.306444
Proj.4: +proj=tmerc +x_0=152400.3048006096 +lon_0=-90.5 +k_0=0.9999333333333333 +lat_0=35.83333333333334 +to_meter=0.3048006096012192 +ellps=clrk66

Here's a link to the original shapefile zip: St Louis Parcel Data

Best Answer

When I inspect that shapefile using ogrinfo I see that it's a state plane projection that uses a NAD27 datum:

$ ogrinfo -al -so /vsizip/prcl_shape.zip

INFO: Open of `/vsizip/prcl_shape.zip'
  using driver `ESRI Shapefile' successful.

Layer name: prcl
Metadata:
  DBF_DATE_LAST_UPDATE=2018-12-31
Geometry: Polygon
Feature Count: 127748
Extent: (551318.459568, 982946.566771) - (592589.293649, 1070913.306444)
Layer SRS WKT:
PROJCS["NAD27 / Missouri East",
    GEOGCS["NAD27",
        DATUM["North_American_Datum_1927",
            SPHEROID["Clarke 1866",6378206.4,294.9786982138982,
                AUTHORITY["EPSG","7008"]],
            AUTHORITY["EPSG","6267"]],
        PRIMEM["Greenwich",0,
            AUTHORITY["EPSG","8901"]],
        UNIT["degree",0.0174532925199433,
            AUTHORITY["EPSG","9122"]],
        AUTHORITY["EPSG","4267"]],
    PROJECTION["Transverse_Mercator"],
    PARAMETER["latitude_of_origin",35.83333333333334],
    PARAMETER["central_meridian",-90.5],
    PARAMETER["scale_factor",0.999933333],
    PARAMETER["false_easting",500000],
    PARAMETER["false_northing",0],
    UNIT["US survey foot",0.3048006096012192,
        AUTHORITY["EPSG","9003"]],
    AXIS["X",EAST],
    AXIS["Y",NORTH],
    AUTHORITY["EPSG","26796"]]
HANDLE: String (16.0)

It's likely you're experiencing problems with Mapshaper when projecting the data from the NAD27 to WGS84 datum as it's not accounting for the datum shift. This will cause your data to become misaligned when projected from the Missouri East state plane to WGS84.

I'm not able to find how to specify the input file's CRS in Mapshaper's documentation, but using ogr2ogr (another CLI tool for processing geospatial data), you can:

$ ogr2ogr -s_srs EPSG:26796 -t_srs EPSG:4326 -f GeoJSON prcl_shape_4326.geojson /vsizip/prcl_shape.zip

The resulting GeoJSON file is 49MB so I took a sample of it and uploaded it as a Github Gist which you may view here: https://gist.github.com/clhenrick/7f90a863d153f9ae2871012a1d624e0d

Related Question