# response.SDAResponse { #soildb.response.SDAResponse }

```python
response.SDAResponse(raw_data)
```

Represents a response from the Soil Data Access web service.

## Attributes

| Name | Description |
| --- | --- |
| [columns](#soildb.response.SDAResponse.columns) | Get column names. |
| [data](#soildb.response.SDAResponse.data) | Get raw data rows. |
| [metadata](#soildb.response.SDAResponse.metadata) | Get column metadata. |

## Methods

| Name | Description |
| --- | --- |
| [from_json](#soildb.response.SDAResponse.from_json) | Create response from JSON string. |
| [get_column_types](#soildb.response.SDAResponse.get_column_types) | Extract column data types from metadata. |
| [get_python_types](#soildb.response.SDAResponse.get_python_types) | Get Python-compatible type mapping. |
| [is_empty](#soildb.response.SDAResponse.is_empty) | Check if the response contains no data. |
| [to_dataframe](#soildb.response.SDAResponse.to_dataframe) | Convert to pandas or polars DataFrame with proper type conversion. |
| [to_dict](#soildb.response.SDAResponse.to_dict) | Convert to list of dictionaries with basic type conversion. |
| [to_geodataframe](#soildb.response.SDAResponse.to_geodataframe) | Convert to GeoPandas GeoDataFrame if geometry column exists. |
| [to_pandas](#soildb.response.SDAResponse.to_pandas) | Convert to pandas DataFrame with proper type conversion. |
| [to_polars](#soildb.response.SDAResponse.to_polars) | Convert to polars DataFrame with proper type conversion. |
| [to_records](#soildb.response.SDAResponse.to_records) | Alias for to_dict() for compatibility. |
| [to_soilprofilecollection](#soildb.response.SDAResponse.to_soilprofilecollection) | Converts the response data to a soilprofilecollection.SoilProfileCollection object. |

### from_json { #soildb.response.SDAResponse.from_json }

```python
response.SDAResponse.from_json(json_str)
```

Create response from JSON string.

### get_column_types { #soildb.response.SDAResponse.get_column_types }

```python
response.SDAResponse.get_column_types()
```

Extract column data types from metadata.

### get_python_types { #soildb.response.SDAResponse.get_python_types }

```python
response.SDAResponse.get_python_types()
```

Get Python-compatible type mapping.

### is_empty { #soildb.response.SDAResponse.is_empty }

```python
response.SDAResponse.is_empty()
```

Check if the response contains no data.

Returns:
    True if the response contains no rows, False otherwise.

### to_dataframe { #soildb.response.SDAResponse.to_dataframe }

```python
response.SDAResponse.to_dataframe(library='pandas', convert_types=True)
```

Convert to pandas or polars DataFrame with proper type conversion.

### to_dict { #soildb.response.SDAResponse.to_dict }

```python
response.SDAResponse.to_dict()
```

Convert to list of dictionaries with basic type conversion.

Returns:
    List of dictionaries where each dictionary represents a row with
    column names as keys and converted values as values.

### to_geodataframe { #soildb.response.SDAResponse.to_geodataframe }

```python
response.SDAResponse.to_geodataframe(convert_types=True)
```

Convert to GeoPandas GeoDataFrame if geometry column exists.

### to_pandas { #soildb.response.SDAResponse.to_pandas }

```python
response.SDAResponse.to_pandas(convert_types=True)
```

Convert to pandas DataFrame with proper type conversion.

### to_polars { #soildb.response.SDAResponse.to_polars }

```python
response.SDAResponse.to_polars(convert_types=True)
```

Convert to polars DataFrame with proper type conversion.

### to_records { #soildb.response.SDAResponse.to_records }

```python
response.SDAResponse.to_records()
```

Alias for to_dict() for compatibility.

### to_soilprofilecollection { #soildb.response.SDAResponse.to_soilprofilecollection }

```python
response.SDAResponse.to_soilprofilecollection(
    site_data=None,
    site_id_col='cokey',
    hz_id_col='chkey',
    hz_top_col='hzdept_r',
    hz_bot_col='hzdepb_r',
)
```

Converts the response data to a soilprofilecollection.SoilProfileCollection object.

This method is intended for horizon-level data, which can be joined with
site-level data (e.g., from the component table) to form a complete
soil profile collection.

Args:
    site_data: Optional pandas DataFrame containing site-level data.
        This will be joined with the horizon data.
    site_id_col: The name of the site ID column, used to link site and
        horizon data (default: "cokey").
    hz_id_col: The name of the unique horizon ID column (default: "chkey").
    hz_top_col: The name of the horizon top depth column (default: "hzdept_r").
    hz_bot_col: The name of the horizon bottom depth column (default: "hzdepb_r").

Returns:
    A SoilProfileCollection object.

Raises:
    ImportError: If the 'soilprofilecollection' package is not installed.
    ValueError: If required columns for creating the SoilProfileCollection
        are missing from the data.