> ## Documentation Index
> Fetch the complete documentation index at: https://docs.wherobots.com/llms.txt
> Use this file to discover all available pages before exploring further.

# RS_FromNetCDF

Returns a raster geometry representing the given record variable short name from a NetCDF file.
This API reads the array data of the record variable *in memory* along with all its dimensions
Since the netCDF format has many variants, the reader might not work for your test case, if that is so, please report this using the public forums.

This API has been tested for netCDF classic (NetCDF 1, 2, 5) and netCDF4/HDF5 files.

This API requires the name of the record variable. It is assumed that a variable of the given name exists, and its last 2 dimensions are 'lat' and 'lon' dimensions *respectively*.

If this assumption does not hold true for your case, you can choose to pass the lonDimensionName and latDimensionName explicitly.

You can use [RS\_NetCDFInfo](/reference/wherobots-db/raster-data/constructors/RS_NetCDFInfo) to get the details of the passed netCDF file (variables and its dimensions).

## Signatures

```sql theme={"system"}
RS_FromNetCDF(netCDF: ARRAY[Byte], recordVariableName: String)
```

```sql theme={"system"}
RS_FromNetCDF(netCDF: ARRAY[Byte], recordVariableName: String, lonDimensionName: String, latDimensionName: String)
```

## Parameters

<ParamField body="netCDF" type="ARRAY[Byte]" required>
  The NetCDF file content as a byte array.
</ParamField>

<ParamField body="recordVariableName" type="String" required>
  The name of the record variable to extract from the NetCDF file.
</ParamField>

<ParamField body="lonDimensionName" type="String">
  The name of the longitude dimension. Pass this if the last 2 dimensions are not `lat` and `lon` respectively.
</ParamField>

<ParamField body="latDimensionName" type="String">
  The name of the latitude dimension. Pass this if the last 2 dimensions are not `lat` and `lon` respectively.
</ParamField>

## Return type

<ResponseField type="Raster">
  The resulting raster.
</ResponseField>

## Examples

```scala theme={"system"}
val df = sedona.read.format("binaryFile").load("/some/path/test.nc")
df = df.withColumn("raster", f.expr("RS_FromNetCDF(content, 'O3')"))
```

```scala theme={"system"}
val df = sedona.read.format("binaryFile").load("/some/path/test.nc")
df = df.withColumn("raster", f.expr("RS_FromNetCDF(content, 'O3', 'lon', 'lat')"))
```
