nationalparkservice / EnvironmentalSetting_Toolkit

Tools supporting the NPS IMD Environmental Setting protocol
Other
3 stars 2 forks source link

Update service used for getAOAFeature() #61

Open llnelson opened 3 years ago

llnelson commented 3 years ago

Change to https://irmaservices.nps.gov/arcgis/rest/services/IMDData/IMD_NPS_ALLPARKS_Generic_30km_Unit_AOAs/MapServer/0

`getAOAFeature <- function(unitCode, aoaExtent="km30") { tempOutput <- "temp.geojson" featureServiceURLs <- list("park" = "https://irmaservices.nps.gov/arcgis/rest/services/IMDData/IMD_NPS_ALLPARKS_Generic_Park_Unit_AOAs/MapServer/0", "km3" = "https://irmaservices.nps.gov/arcgis/rest/services/IMDData/IMD_NPS_ALLPARKS_Generic_3km_Unit_AOAs/MapServer/0", "km30" = "https://irmaservices.nps.gov/arcgis/rest/services/IMDData/IMD_NPS_ALLPARKS_Generic_30km_Unit_AOAs/MapServer/0" ) featureServicePathInfo <- "query?where=UNITCODE+%3D+%27XXXX%27&objectIds=&time=&geometry=&geometryType=esriGeometryEnvelope&inSR=&spatialRel=esriSpatialRelIntersects&distance=&units=esriSRUnit_Meter&relationParam=&outFields=*&returnGeometry=true&maxAllowableOffset=&geometryPrecision=&outSR=4269&gdbVersion=&returnDistinctValues=false&returnIdsOnly=false&returnCountOnly=false&returnExtentOnly=false&orderByFields=&groupByFieldsForStatistics=&outStatistics=&returnZ=false&returnM=false&multipatchOption=&resultOffset=&resultRecordCount=&f=geojson"

featureServiceRequest <- paste(as.character(featureServiceURLs[featureServiceURLs = aoaExtent]), gsub("XXXX", unitCode, featureServicePathInfo), sep = "/" ) print(featureServiceRequest) geoJSONFeature <- fromJSON(featureServiceRequest)

Have to save to temp file

jsonFeature <- download.file(featureServiceRequest, tempOutput, mode = "w")

For rgdal 1.2+, layer (format) does not need to be specified

featurePoly <- readOGR(dsn = tempOutput)

featurePoly <- readOGR(dsn = tempOutput, layer = "OGRGeoJSON")

return(featurePoly) }`