Using geoknife with a custom webgeom and/or webdata

David Blodgett


Sciencebase WFS is offline at this time and this vignette will not be built.

This vignette shows how to use a custom Web Feature Service with geoknife. In this case, we are using a WFS from ScienceBase. The url used for the WFS can be found in the “Spatial Services” section of the sciencebase item. If the WFS url you have has parameters included, remove them when passing them to geoknife.
e.g. this:
not this:

For advanced users, it may be interesting to see what geoknife is doing behind the scences. Switch verbose=FALSE to verbose=TRUE to see the web service request being made when you execute this vignette.

stencil <- webgeom(url="")

stencil_geoms <- query(stencil, 'geoms')

Now we can select a WFS geometry layer (geom) and query for its attributes.

geom(stencil) <- stencil_geoms[2]

stencil_attributes <- query(stencil, 'attributes')

Now we can select an attribute and query for the values of that attribute. For this demo, we won’t set the values, but rather just move forward using all polygons in this geom

attribute(stencil) <- stencil_attributes[2]

print(query(stencil, 'values'))

Now we’ll set up our webdata with an OPeNDAP service as its url. Note that this can be any OPeNDAP service compatible with geoknife and the Geo Data Portal. What datasets are compatible is beyond the scope of this vignette. The OPeNDAP dataset used here is from the main USGS THREDDS archive and is one included in geoknife but many other OPeNDAP datasets could be used by entering their OPeNDAP service base URL in the same way.

fabric <- webdata(url = '', 
                  variables = c('tmx', 'tmn', 'ppt'),
                  times = as.POSIXct(c('2000-01-01', '2010-01-01')))

Note that if you don’t know the valid variables and times for an OPeNDAP URL, you can use query to find them like this.

fabric_variables <- query(fabric, "variables")
fabric_times <- query(fabric, "times")

print(paste(fabric@url, "has", 
            paste(fabric_variables, collapse = ", "), 
            "variables for the time range", fabric_times[1], 
            "to", fabric_times[2]))

Now we can execute the geoknife job for the specified fabric and stencil. Note that we set wait = TRUE here so we can just wait for the result of the process.

prism_yahara_result <- result(geoknife(stencil, fabric, wait = TRUE))