Geoprocessing Parameter Types
Functions for converting R objects to and from ArcGIS geoprocessing parametertypes. These functions handle the serialization and parsing of various datatypes used in ArcGIS geoprocessing services.
Usage
parse_gp_feature_record_set(json)as_gp_feature_record_set(x)parse_gp_record_set(json)as_record_set(x)as_gp_raster_layer(x)gp_linear_unit(distance=integer(0), units=character(0))as_gp_linear_unit(x)parse_gp_linear_unit(json)gp_areal_unit(area=integer(0), units=character(0))as_gp_areal_unit(x)parse_gp_areal_unit(json)as_gp_date(x)parse_gp_date(json)as_spatial_reference(x)parse_spatial_reference(json)Arguments
- json
raw json to parse
- x
the object to convert into json
- distance
a scalar number of the distance.
- units
the unit of the measurement. Must be one of "esriUnknownAreaUnits", "esriSquareInches", "esriSquareFeet", "esriSquareYards", "esriAcres", "esriSquareMiles", "esriSquareMillimeters", "esriSquareCentimeters", "esriSquareDecimeters", "esriSquareMeters", "esriAres", "esriHectares", "esriSquareKilometers", "esriSquareInchesUS", "esriSquareFeetUS", "esriSquareYardsUS", "esriAcresUS", "esriSquareMilesUS".
- area
a scalar number of the measurement.
Details
This package provides support for the following geoprocessing parameter types:
Implemented Types
GPFeatureRecordSetLayer: Feature collections with geometry and attributes
GPRecordSet: Tabular data without geometry
GPRasterDataLayer: Raster datasets from Portal items, Image Servers, or URLs
GPLinearUnit: Linear distance measurements with units
GPArealUnit: Area measurements with units
GPDate: Date/time values in milliseconds since epoch
GPSpatialReference: Coordinate reference systems
Not Yet Implemented
The following types are planned for future implementation:
GPField: Field definitions with name, type, and properties
GPMultiValue: Arrays of values for a single data type
GPValueTable: Flexible table-like objects with rows and columns
GPComposite: Parameters that accept multiple data types
GPEnvelope: Bounding box extents (use
as_extent()for GPExtent)
Usage Patterns
Most functions follow a consistent pattern:
as_gp_*(): Convert R objects to geoprocessing parameter JSONparse_gp_*(): Parse geoprocessing response JSON to R objectsConstructor functions (e.g.,
gp_linear_unit(),gp_areal_unit()) create typed S7 objects
Examples
# Create a linear unitdistance<-gp_linear_unit(distance=100, units="esriMeters")# Convert spatial data to feature record setas_gp_feature_record_set(my_sf_data)# Parse a geoprocessing responseparse_gp_feature_record_set(response_json)See also
Other geoprocessing:arc_form_params(),arc_gp_job,arc_job_status()
Examples
# create a feature record setfset<-as_gp_feature_record_set(iris[1,])fset#> [1] "{\"spatialReference\":{},\"features\":[{\"attributes\":{\"Petal.Length\":1.4,\"Petal.Width\":0.2,\"Sepal.Length\":5.1,\"Sepal.Width\":3.5,\"Species\":\"setosa\"}}]}"# create fake gp feature record set to parsefset_list<-list(list( dataType="GPFeatureRecordSetLayer", paramName="example", value=as_featureset(iris[1,])))# create the jsonjson<-yyjsonr::write_json_str(fset_list, auto_unbox=TRUE)# parse the record set jsonparse_gp_feature_record_set(json)#> $param_name#> [1] "example"#>#> $data_type#> [1] "GPFeatureRecordSetLayer"#>#> $geometry#> Petal.Length Petal.Width Sepal.Length Sepal.Width Species#> 1 1.4 0.2 5.1 3.5 setosa#># linear unitslu<-gp_linear_unit(10,"esriMeters")lu#> <arcgisutils::GPLinearUnit>#> @ distance: num 10#> @ units : chr "esriMeters"as_gp_linear_unit(lu)#> [1] "{\"distance\":10.0,\"units\":\"esriMeters\"}"# areal unitsau<-gp_areal_unit(10,"esriSquareMeters")au#> <arcgisutils::GPArealUnit>#> @ area : num 10#> @ units: chr "esriSquareMeters"as_gp_areal_unit(au)#> [1] "{\"area\":10.0,\"units\":\"esriSquareMeters\"}"# datesjson<-r"({ "paramName": "Output_Date", "dataType": "GPDate", "value": 1199145600000})"parse_gp_date(json)#> $paramName#> [1] "Output_Date"#>#> $dataType#> [1] "GPDate"#>#> $value#> [1] "2008-01-01 UTC"#>