Skip to content

esrijson to geojson Exception #321

Open

Description

@handsomeCLF

I have an esrijson and when converting it to geojson, I found that the geometry returned by createGeometryByGeoJson is empty. Is there any other way to convert it to geojson?
I can successfully convert using https://github.com/Esri/arcgis-to-geojson-utils arcgisToGeoJSON method.

The code example is as follows:

public String EsriJsonToGeoJson(String esri_json){
    Geometry geometry = createGeometryByJson(esri_json);
    return getGeoJson(geometry);
}

private Geometry createGeometryByGeoJson(String geojson) {
    return GeometryEngine.geoJsonToGeometry(geojson, WktExportFlags.wktExportDefaults, Geometry.Type.Unknown).getGeometry();
}

private String getGeoJson(Geometry geometry) {
    return GeometryEngine.geometryToGeoJson(geometry);
}

The data example is as follows:
GeoJson.json

EsriJson.json

Activity

  1. alocke commented on May 14, 2024

    @alocke
    Member

    GeometryEngine accepts JSON strings that only have the geometry (with an optional spatial reference), not the other properties. Your JSON string should start with {"rings": and end with the closing brace }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions