Processing math: 100%

1 votos

ogr2ogr - Convertir geojson a shapefile crear offset en coordenadas

Quiero convertir este archivo geojson de abajo en un shapefile usando el comando ogr2ogr ogr2ogr output.shp input.geojson .

Sin embargo, aparece un desplazamiento en las coordenadas de salida que hace que el shapefile no esté correctamente alineado con el de entrada.

input.geojson:

{
   "type":"FeatureCollection",
   "features":[
      {
         "type":"Feature",
         "geometry":{
            "type":"LineString",
            "coordinates":[[-7551132, 6293816],[-7560916, 6260489]],
         },
         "properties":{
            "id":36
         }
      }
   ],
   "crs":{
      "type":"name",
      "properties":{
         "name":"urn:ogc:def:crs:EPSG:3857"
      }
   }
}

¿Hay algún problema con mi geojson? ¿Cuál podría ser la causa del desplazamiento?

1voto

Joe Puntos 16

Hice un shapefile de su linestring

ogrinfo line.shp -al
INFO: Open of `line.shp'
      using driver `ESRI Shapefile' successful.

Layer name: line
Geometry: Line String
Feature Count: 1
Extent: (-7560916.000000, 6260489.000000) - (-7551132.000000, 6293816.000000)
Layer SRS WKT:
(unknown)
OGRFeature(line):0
  LINESTRING (-7551132 6293816,-7560916 6260489)

A continuación lo convertí en GeoJSON

ogr2ogr -f GeoJSON -a_srs epsg:3857 line.json line.shp

No encuentro ninguna diferencia con ogrinfo

ogrinfo -ro -al line.json
INFO: Open of `line.json'
      using driver `GeoJSON' successful.

Layer name: OGRGeoJSON
Geometry: Line String
Feature Count: 1
Extent: (-7560916.000000, 6260489.000000) - (-7551132.000000, 6293816.000000)
Layer SRS WKT:
PROJCS["WGS 84 / Pseudo-Mercator",
    GEOGCS["WGS 84",
        DATUM["WGS_1984",
            SPHEROID["WGS 84",6378137,298.257223563,
                AUTHORITY["EPSG","7030"]],
            AUTHORITY["EPSG","6326"]],
        PRIMEM["Greenwich",0,
            AUTHORITY["EPSG","8901"]],
        UNIT["degree",0.0174532925199433,
            AUTHORITY["EPSG","9122"]],
        AUTHORITY["EPSG","4326"]],
    PROJECTION["Mercator_1SP"],
    PARAMETER["central_meridian",0],
    PARAMETER["scale_factor",1],
    PARAMETER["false_easting",0],
    PARAMETER["false_northing",0],
    UNIT["metre",1,
        AUTHORITY["EPSG","9001"]],
    AXIS["X",EAST],
    AXIS["Y",NORTH],
    EXTENSION["PROJ4","+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +
x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext  +no_defs"],
    AUTHORITY["EPSG","3857"]]
OGRFeature(OGRGeoJSON):0
  LINESTRING (-7551132 6293816,-7560916 6260489)

Para la verificación, convierta de nuevo el GeoJSON a shape:

ogr2ogr -f "ESRI Shapefile" roundtrip.shp line.json

Lo que tenemos:

ogrinfo -al roundtrip.shp
INFO: Open of `roundtrip.shp'
      using driver `ESRI Shapefile' successful.

Layer name: roundtrip
Geometry: Line String
Feature Count: 1
Extent: (-7560916.000000, 6260489.000000) - (-7551132.000000, 6293816.000000)
Layer SRS WKT:
PROJCS["WGS_84_Pseudo_Mercator",
    GEOGCS["GCS_WGS_1984",
        DATUM["WGS_1984",
            SPHEROID["WGS_84",6378137,298.257223563]],
        PRIMEM["Greenwich",0],
        UNIT["Degree",0.017453292519943295]],
    PROJECTION["Mercator_1SP"],
    PARAMETER["central_meridian",0],
    PARAMETER["false_easting",0],
    PARAMETER["false_northing",0],
    UNIT["Meter",1],
    PARAMETER["latitude_of_origin",0.0]]
FID: Integer64 (11.0)
OGRFeature(roundtrip):0
  FID (Integer64) = 0
  LINESTRING (-7551132 6293816,-7560916 6260489)

Las coordenadas parecen ser idénticas a las originales.

Conclusión: Utilizar herramientas de bajo nivel para la depuración. Nunca se puede saber lo que un gran programa como QGIS está haciendo en segundo plano.

i-Ciencias.com

I-Ciencias es una comunidad de estudiantes y amantes de la ciencia en la que puedes resolver tus problemas y dudas.
Puedes consultar las preguntas de otros usuarios, hacer tus propias preguntas o resolver las de los demás.

Powered by:

X