We need to check that the shapefiles and survey data that is provided by user meets the requirements for us to be able to compute zonal stats into the objects. Please write simple check functions:
check_shp() that checks that:
start by checking if shp_fn is NULL, (is.null(shp_fn))), if shp_fn is not null, we need to make sure that it is a character vector, if not spit out error.
the shp_dt is an sf object,
st_geometry_type is POLYGON or MULTIPOLYGON
get the CRS of the sf object as well (if there is no CRS spit out an error message and exit)
and the geometry is valid
for bonus point, you can spit out warning to say if there are empty geometries
check_survey() for R users this has a sf data.frame style object.
So check the class of the object is sf data.frame.
check that we have a point geometry as well, (spit a warning if it is not a point geometry)
check for empty geometries and make sure it is valid (sf::is.valid())
For STATA users, survey_fn, survey_lon and survey_lat
make sure survey_fn is a .dta file because it is loaded with the haven::read_dta()
make sure that survey_lon and survey_lat are specified if survey_fn is not NULL
check for the CRS
check_shp() and check_survey() should return the crs of the object in both functions
@dasalm20,
We need to check that the shapefiles and survey data that is provided by user meets the requirements for us to be able to compute zonal stats into the objects. Please write simple check functions:
check_shp()
that checks that:shp_dt
is an sf object,check_survey()
for R users this has a sf data.frame style object.check_shp() and check_survey() should return the crs of the object in both functions