Layers

Uploading a file or URL

Check our Upload Anything docs to see what URLs are supported.

The /upload endpoint can be used for both URL and file uploads:

  • For URL uploads, simply making a single POST request to the upload endpoint is enough

  • For file uploads, the response of the initial POST request will include a target URL and some pre-signed attributes, which will be used to upload the new file to Amazon S3.

This endpoint is used to create a layer, and obtain a pre-signed url to upload the layer files to S3.

Uploading the file to Amazon S3

Uploading a file is a single function call using the felt-python library.

Layer files aren’t uploaded directly to the Felt API. Instead, they are uploaded by your client directly to an S3 bucket.

You will receive a single set of URL and pre-signed params to upload the file. Only a single file may be uploaded — if you wish to upload several files at once, consider wrapping them in a zip file.

To upload the file using the pre-signed params, you must perform a multipart upload, and include the file contents in the file field:

# Requires requests library to be installed with: pip install requests
import requests

# Your API token should look like this:
# api_token = "felt_pat_ABCDEFUDQPAGGNBmX40YNhkCRvvLI3f8/BCwD/g8"
api_token = "<YOUR_API_TOKEN>"
map_id = "<YOUR_MAP_ID>"
path_to_file = "<YOUR_FILE_WITH_EXTENSION>" # Example: features.geojson

# Request  a pre-signed URL from Felt
layer_response = requests.post(
    f"https://felt.com/api/v2/maps/{map_id}/upload",
    headers={
        "authorization": f"Bearer {api_token}",
        "content-type": "application/json",
    },
    json={"name": "My new layer"},
)
presigned_upload = layer_response.json()
url = presigned_upload["data"]["attributes"]["url"]
presigned_attributes = presigned_upload["data"]["attributes"]["presigned_attributes"]
# A 204 response indicates that the upload was successful
with open(path_to_file, "rb") as file_obj:
    output = requests.post(
        url,
        # Order is important, file should come at the end
        files={**presigned_attributes, "file": file_obj},
    )

Refreshing a layer

Refreshing a file is a single function call using the felt-python library.

After uploading a file or URL, you may want to update the resulting layer with some new data. The process is quite similar to the above:

  • For URL uploads, simply making a single POST request to the refresh endpoint is enough

  • For file uploads, the response of the initial POST request will include a URL and some presigned attributes, which will be used to upload the new file to Amazon S3. See Uploading the file to Amazon S3 for more details.

Deleting a layer

Styling layers

Update a layer's style

A layer's style may be updated by providing a new Felt Style Language object. Learn more in the guide:

Managing layers

Get all the layers on a map

Get the details of all the layer on the map that are not within a layer group.

Get a single layer

Get the details of a single layer on the map. These details include:

  • Name of the layer

  • Upload status and progress

  • Style, expressed in the Felt Style Language

  • Other metadata, such as the geometry type, visibility state in the legend, etc

Updating a layer's details

Update a layer's name or move it into or out of a layer group.

To move a layer into a group, set the layer_group_id to the id of the layer group you want to move the layer into. To move a layer out of a group, set the layer_group_id to null.

Layer groups

Get details of a layer group

Delete a layer group

Create or update layer groups

Provide an array of layer group objects to create new groups or update existing ones.

For each layer group object, including an existing ID will result in the group's details (name, subtitle and legend order) being updated. If no layer group ID is provided (or a non-existent one is provided), a new layer group will be created.

Layer library

Listing layers

List all layers in your workspace's Library

Publishing a layer

Publish a layer to your workspace's library

Publishing a layer group

Publish a layer group to your workspace's library

Downloading layers

Get a link to export a layer as a GeoPackage (vector layers) or GeoTIFF (raster layers)

Duplicating layers

Duplicate an array of layers or layer groups to a map

Last updated