# Useful geospatial data functions for Spotfire

Data functions extend Spotfire in ways that users understand but without them having to write any code. On this page you will find some geospatial data functions usable in Spotfire to extend its capabilities. For an overall overview of GeoAnalytics or Location Analytics capabilities of Spotfire please also review this page (click on link).

## Calculate areas of polygons

A data function that calculates the areas of polygons. The polygons must be specified in longitude/latitude coordinates. Requires the R packages "sp", "geosphere", "wkb", and "rgdal".

> Download: Area of Polygons for Longitude-Latitude Coordinates.sfd

## Convert polygon coordinates to polygon geometries

A data function that inputs a table of coordinates representing polygons, and outputs a table with the polygons in the format native to Spotfire, for rendering in a Feature Layer on a Map Chart. Enables tables representing polygons to be rendered on maps in Spotfire.

> Download : Convert Polygon Coordinates to Polygon Geometries.sfd

## Draw circle with fixed radius on geographic coordinates

A data function to draw circles with fixed radius on a Spotfire map. The centers of the circles are specified by columns of geographic coordinates. The radius of the circles is given as a single value. The circle must be added as a Feature Layer using the coordinate reference system EPSG:4326 - WGS84.

> Download : Draw Circles with Fixed Radius on Geographic Coordinates.sfd

## Draw rectangles with fixed size on geographic coordinates

A data function to draw rectangles with fixed width and height on a Spotfire map. The centers of the rectangles are specified by columns of geographic coordinates. The width and height of the rectangles are given as a single pair of fixed values. The rectangles must be added as a Feature Layer using the coordinate reference system EPSG:4326 - WGS84.

> Download : Draw Rectangles with Fixed Size on Geographic Coordinates.sfd

## Find which marker(s) are located in a polygon

A data function that inputs a set of polygons and a set of points, and outputs which polygon each point is in. Requires the R packages `sp` and `wkb`.

For cartesian coordinate: > Download : Points In Polygons (Geofencing) for Cartesian Coordinates.sfd

For longitude/latitude coordinates: > Download : Points In Polygons (Geofencing) for Longitude-Latitude Coordinates.sfd

## Transform Coordinate Reference System

Data functions that convert an imported Shapefile (.shp) or columns of geographic coordinates from one coordinate reference system to another.

### Transform CRS for imported shapefile (.shp) by EPSG code

A data function that converts an imported shapefile from one coordinate reference system to another, using EPSG codes to specify the reference systems. Requires the R packages `sp`, `rgdal`, and `wkb`. Note that the environment variable GDAL_DATA must be set to the location of the gdal folder in the rgdal folder in the library folder where TERR is installed. EPSG codes can be looked up from the .prj files in shapefiles at http://prj2epsg.org/.

> Download : Transform CRS for Imported Shapefile by EPSG Code.sfd

### Transform CRS for imported shapefile (.shp) by PROJ.4 string

A data function that converts an imported shapefile from one coordinate reference system to another, using PROJ.4 strings to specify the reference systems. Requires the R packages `sp`, `rgdal`, and `wkb`. For some PROJ.4 strings, requires the environment variable PROJ_LIB to be set to the location of the proj folder in the rgdal folder in the library folder where TERR is installed. PROJ.4 strings can be looked up at http://spatialreference.org/.

> Download : Transform CRS for Imported Shapefile by PROJ.4 String.sfd

### Transform CRS for markers by EPSG code

A data function that converts columns of geographic coordinates from one reference system to another, using EPSG codes to specify the reference systems. Requires the R packages `sp` and `rgdal`. Note that the environment variable GDAL_DATA must be set to the location of the gdal folder in the rgdal folder in the library folder where TERR is installed. EPSG codes can be looked up from the .prj files in shapefiles at http://prj2epsg.org/.

> Download : Transform CRS for Points by EPSG Code.sfd

### Transform CRS for markers by PROJ.4 string

A data function that converts columns of geographic coordinates from one reference system to another, using PROJ.4 strings to specify the reference systems. Requires the R packages `sp` and `rgdal`. For some PROJ.4 strings, requires the environment variable PROJ_LIB to be set to the location of the proj folder in the rgdal folder in the library folder where TERR is installed. PROJ.4 strings can be looked up at http://spatialreference.org/.

## Feedback (2)

There is so many useful assets in this community. On this page alone I used two data functions to create a solution for marking points in a scatterplot and comparing other points as inside or outside of the resulting polygon. And not even a GIS use case. Thanks!

1.

2.

Thanks Arnaud for providing these geo-spatial data functions in one place. It makes it easy to leverage a required data function and insert into my project.