The hardware and bandwidth for this mirror is donated by METANET, the Webhosting and Full Service-Cloud Provider.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]metanet.ch.
Convert polygons to points for labeling and/or distance calculations:
Create buffer zones around administrative units (distances in km):
Compute distances between units:
# Distance matrix between provinces (centroid to centroid)
provinces <- get_provinces()
dist_matrix <- pk_distance(provinces, provinces)
# Distance from each province to Karachi
karachi <- get_districts(province = "Sindh") |>
filter(district_name == "Karachi")
distances <- pk_distance(provinces, karachi)Assign GPS points to administrative units:
# Example: health facility locations
facilities <- data.frame(
name = c("Hospital A", "Clinic B"),
lon = c(74.3, 74.5),
lat = c(31.5, 31.6)
) |>
sf::st_as_sf(coords = c("lon", "lat"), crs = 4326)
# Assign to districts
facilities_with_district <- pk_points_in(facilities, districts)
# View result
facilities_with_district |>
sf::st_drop_geometry() |>
select(name, district_name)Aggregate finer units to coarser levels:
WGS84 (default) measures in degrees, for measurements using projected CRS:
These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.