# \donttest{
# Set cache path. Default is a temporal directory
options(mregions2.download_path = tempdir())
getOption("mregions2.download_path")
#> [1] "/tmp/RtmpARLgoE"
# See the list of all data products
mrp_list
# We want the Exclusive Economic Zones of Portugal. Let's first visualize the product:
mrp_view("eez")
# See all the columns on this data product
mrp_colnames("eez")
# We should query on sovereign
# See all the possible values of sovereign1, sovereign2 and sovereign3
sov1 = mrp_col_unique("eez", "sovereign1")
sov2 = mrp_col_unique("eez", "sovereign2")
sov3 = mrp_col_unique("eez", "sovereign3")
# Is Portugal a value in the sovereign1, 2 and 3?
"Portugal" %in% sov1
#> [1] TRUE
"Portugal" %in% sov2
#> [1] FALSE
"Portugal" %in% sov3
#> [1] FALSE
# Portugal is only in sovereign1. Let's write a CQL filter to get only
# the EEZs of Portugal, or those where Portugal is a party of a dispute or a joint regime
portugal_eez <- mrp_get("eez", cql_filter = "sovereign1 = 'Portugal'")
# If you perform this request again, it will be read from the cache instead
portugal_eez <- mrp_get("eez", cql_filter = "sovereign1 = 'Portugal'")
#> Cache is fresh. Reading: /tmp/RtmpARLgoE/eez-1951c8b7/eez.shp
#> (Last Modified: 2023-04-24 17:45:16)
# You can also limit the number of features to be requested
mrp_get("eez", count = 5)
# }
Run the code above in your browser using DataLab