---
title: "How to obtain a GeoJSON from an ArcGIS Server FeatureServer?"
canonical: "https://onesaitplatform.refined.site/space/DOCT/2220800176/How%20to%20obtain%20a%20GeoJSON%20from%20an%20ArcGIS%20Server%20FeatureServer%3F"
format: markdown
---
=You may need to generate an ontology from a spatial layer contained in an ArcGIS Server. To do this, you must transform the FeatureServer (the layer) inta GeoJSON format, which will be ingested in the ontology.

# <u>ArcGIS REST Services Directory</u>

Each ArcGIS Server comes with a Services Directory that allows you to browse the list of services, folders and operations on a server. This directory not only contains the vector data layers (FeatureServer), but also map services (MapServices), geoprocessing (GPServer), raster data (ImageServer) and address geocoding (GeocodeServer). Of all of them, the service that will interest you for this tutorial will be **FeatureServer.**

To obtain the information of one of these FeatureServer, you must know the structure of an ArcGIS Server services directory. Its endpoint follows the following structure: **https://<host>/<site>/rest/services/<folder>/<serviceName>/<serviceType>**, where:

- <span style="color: #595959">**https://<host>**</span><span style="color: #595959">: is the name of the ArcGIS Server host.</span>
- <span style="color: #595959">**/<site>**</span><span style="color: #595959">: is the name of the website. By default the value is </span><span style="color: #595959">*/arcgis/*</span><span style="color: #595959">.</span>
- <span style="color: #595959">**/rest/services**</span><span style="color: #595959">: indicates the endpoint of the REST service.</span>
- <span style="color: #595959">**/folder**</span><span style="color: #595959">: is the folder where the information of a specific service is located.</span>
- <span style="color: #595959">**/<serviceName>/<serviceType>**</span><span style="color: #595959">: represents the name of the service being invoked and its type. For example: </span><span style="color: #595959">*JapaneseRestaurants/FeatureServer.*</span>

As an example, you will use the following services directory: **[https://services.arcgis.com/hkQNLKNeDVYBjvFE/arcgis/rest/services/](https://services.arcgis.com/hkQNLKNeDVYBjvFE/arcgis/rest/services/)**

> ✅ ### Real endpoint
> ✅ 
> ✅ Try comparing the URL of the example services directory with the previously defined endpoint structure. In this particular case, the <site> would be hkQNLKNeDVYBjvFE/arcgis.

When accessing said endpoint, a window will open with a list of services that corresponding to the SDI (Spatial Data Infrastructure) of La Palma island.

![image](media://530d734c-d303-4b31-b85c-ae74293ec1c8)

Each of the elements of the list corresponds to, say, a vector data layer (since all that exist there are of the FeatureServer type). Say you are interested in hostels in La Palma. You would access by clicking on **Albergues (FeatureServer)**, "albergues" being Spanish for "hostels", which would take you to another window with the specific information of said service:

![image](media://53bb07de-4f04-49f2-a316-20578dcc2700)

This window shows the summary of service information, including its description, the display extension in the map, the spatial reference system where the data is defined (this is very important when exporting the data) and the number of layers present in the service. Although only one layer appears in the example, the shelter layer, there may be more layers in other services, such as in the **[Redlands, California, emergency vehicle service](http://sampleserver6.arcgisonline.com/arcgis/rest/services/RedlandsEmergencyVehicles/FeatureServer)**. Therefore, you must select the layer of the service that interests you. In this case, it is Hostels (the value 0 refers to the identifier of the layer within the service).

![image](media://33c301d6-b601-480c-9272-1dec6d0f1fee)

You can see the layer on a map from ArcGIS Online. To do this, click on the **View In: ArcGIS.com Map** option, which will open a new window in the browser, with a map that will have the layer loaded and with which you can interact (for example, by clicking on the icons of the map).

![image](media://c1c29f2d-0d89-43c4-86c7-099127a52591)

---

# GeoJSON generation

Once you know this is the layer that you are interested in exporting to GeoJSON format, you can proceed and make a query to the service of the layer. This will be done from the Albergues layer window, browsing to the bottom of the whole, and selecting the **Query** option.

![image](media://03b3d092-f0e4-4a26-be19-a824ebb800ce)

This will open a form where you will have to fill in a number of boxes to obtain the service's GeoJSON. Although the query's customization can be as complex as desired, the main parameters to fill in are these:

- **Where**: **1=1** --> to get all the elements of the layer.
- **Output Spatial Reference: 4326** --> the coordinate system we want for the GeoJSON. 4326 refers to EPSG:4326, which is the coordinate system of **WGS84,** which makes use of longitude and latitude.
- **Format: GEOJSON** --> so that the data output is in standard GeoJSON format.

  


> ℹ️ ### On the coordinate systems
> ℹ️ 
> ℹ️ By default, the layer has the 102100 coordinate system, old code for **EPSG:3857,** known a s[WGS84 Pseudo-Mercator -- Spherical Mercator](https://epsg.io/3857). The service has been asked to transform the layer to **EPSG:4326**, known as[WGS84 - World Geodetic System 1984](https://epsg.io/4326). The difference between these coordinate systems is that, while the WGS84(4326) has limits for longitude between -180.0 and 180.0, and for latitude between -90.0 and 90.0 (the entire Earth sphere), Pseudo-Mercator (3857) has the latitude cut between -85.06 and 85.06.

  


Introducidas estas opciones, no hay más que ejecutar la consulta pulsando en Query (GET) para que se genere el GeoJSON de la capa:

##### **Response GeoJSON**

```xml
{
  "type" : "FeatureCollection", 
  "crs" : 
  {
    "type" : "name", 
    "properties" : 
    {
      "name" : "EPSG:4326"
    }
  }, 
  "features" : [
    {
      "type" : "Feature", 
      "geometry" : 
      {
        "type" : "Point", 
        "coordinates" : [
          -17.9381656087823, 28.7018953788704
        ]
      }, 
      "properties" : {
        "Municipio" : "Tijarafe"
      }
    }, 
    {
      "type" : "Feature", 
      "geometry" : 
      {
        "type" : "Point", 
        "coordinates" : [
          -17.8665547061961, 28.5398949716646
        ]
      }, 
      "properties" : {
        "Municipio" : "Fuencaliente"
      }
    }, 
    {
      "type" : "Feature", 
      "geometry" : 
      {
        "type" : "Point", 
        "coordinates" : [
          -17.7445869375271, 28.7421381046795
        ]
      }, 
      "properties" : {
        "Municipio" : "Puntallana"
      }
    }, 
    {
      "type" : "Feature", 
      "geometry" : 
      {
        "type" : "Point", 
        "coordinates" : [
          -17.7846402612961, 28.7917152818693
        ]
      }, 
      "properties" : {
        "Municipio" : "San Andrés y Sauces"
      }
    }, 
    {
      "type" : "Feature", 
      "geometry" : 
      {
        "type" : "Point", 
        "coordinates" : [
          -17.7992146269749, 28.5598092585296
        ]
      }, 
      "properties" : {
        "Municipio" : "Villa de Mazo"
      }
    }, 
    {
      "type" : "Feature", 
      "geometry" : 
      {
        "type" : "Point", 
        "coordinates" : [
          -17.8772632151204, 28.8320525255706
        ]
      }, 
      "properties" : {
        "Municipio" : "Garafía"
      }
    }
  ]
}
```

  


To automate this process, either to ingest it through **FlowEngine** or similar, you may want to take a look at the service query's URL:

##### **Query URL**

```
https://services.arcgis.com/hkQNLKNeDVYBjvFE/ArcGIS/rest/services/Albergues/FeatureServer/0/query?where=1%3D1&objectIds=&time=&geometry=&geometryType=esriGeometryEnvelope&inSR=&spatialRel=esriSpatialRelIntersects&resultType=none&distance=0.0&units=esriSRUnit_Meter&returnGeodetic=false&outFields=&returnGeometry=true&featureEncoding=esriDefault&multipatchOption=xyFootprint&maxAllowableOffset=&geometryPrecision=&outSR=4326&datumTransformation=&applyVCSProjection=false&returnIdsOnly=false&returnUniqueIdsOnly=false&returnCountOnly=false&returnExtentOnly=false&returnQueryGeometry=false&returnDistinctValues=false&cacheHint=false&orderByFields=&groupByFieldsForStatistics=&outStatistics=&having=&resultOffset=&resultRecordCount=&returnZ=false&returnM=false&returnExceededLimitFeatures=true&quantizationParameters=&sqlFormat=none&f=pgeojson&token=
```

  


We could divide this URL into two parts: the first one, containing the FeatureServer service endpoint([https://services.arcgis.com/hkQNLKNeDVYBjvFE/ArcGIS/rest/services/Albergues/FeatureServer/0/](https://services.arcgis.com/hkQNLKNeDVYBjvFE/ArcGIS/rest/services/Albergues/FeatureServer/0/)), and the second one, with the query call, where you can identify the previously inserted properties:

- where=1%3D1
- outSR=4326
- f=pgeojson


Therefore, by reconstructing such a query to a different endpoint, the GeoJSON of several FeatureServers could be automatically obtained, with you needing to know only the desired FeatureServer service's name and the layer's ID.