Skip to content

GeoJSON classification

The geotax document classification resources can be used in a standard way, composing the endpoint as indicated in the article in the reference section. In this case, the output of the resource is also standard.

It is also possible to obtain an output containing standard GeoJSON data, which is useful for locating identified countries in GIS systems.

To achieve this you need to add a query string parameter to the resource endpoint.
The parameter is called features and must be set to extradata. For example, this is the resource endpoint for English with the addition of the parameter:

https://nlapi.expert.ai/v2/categories/geotax/en?features=extradata

The resulting output has this format:

{
    "success": Boolean success flag,
    "data": {
        "content": analyzed text,
        "language": language code,
        "version": technology version info,
        "categories": as in the standard classification output,
        "extraData": {
            "geojson": GeoJSON data
        }
    }
}

It is the standard classification output with the addition of the extraData object which in turn contains the geojson object.

The GeoJSON data contains identification data for the countries and the coordinates of their geographic center, for example:

...
"content": "Last year I moved from San Francisco to New York.",
"extraData": {
    "geojson": {
        "features": [
            {
                "geometry": {
                    "coordinates": [
                        -98.57,
                        39.82
                    ],
                    "type": "Point"
                },
                "properties": {
                    "geonameId": "6252001",
                    "id": "/185.",
                    "name": "/United States of America"
                },
                "type": "Feature"
            },
            {
                "geometry": {
                    "coordinates": [
                        -120,
                        37
                    ],
                    "type": "Point"
                },
                "properties": {
                    "geonameId": "5332921",
                    "id": "/185./18505.",
                    "name": "/United States of America/California"
                },
                "type": "Feature"
            },
            {
                "geometry": {
                    "coordinates": [
                        -75,
                        43
                    ],
                    "type": "Point"
                },
                "properties": {
                    "geonameId": "5128638",
                    "id": "/185./18533.",
                    "name": "/United States of America/New York State"
                },
                "type": "Feature"
            }
        ],
        "type": "FeatureCollection"
    }
}
...