1. What is the issue? Please be detailed.
I just started playing around with Automatically create geographical itemset.csv for external cascading select which was quite helpful for making an ordinary select_one_from_file using the autocomplete appearance, the using some calculate fields for reverse cascade as shown below:
Now I’m wondering if it could be taken a step further to produce two questions that I think would also be helpful to others. They are getting at the same underlying data, but essentially, instead of choosing from a large dropdown list, users could either select from map or select from image using an SVG. Having a script that could convert all this data from tables/.shp files to an SVG and geoJSON of a countries sub-regions I think would be extremely helpful to the community. Has this been done before?
For my purposes currently, I’m trying to do this for Enketo/Public Webform, not Collect.
-
Selects via SVG would show the .svg image with different regions/prefectures/sub-prefectures as selectable with their names? Similar to how this map is displayed. Can this type of SVG be referenced by multilingual image columns?
I remember seeing a good example using the 50 US States, but cannot seem to find this reference.
-
Select One from Map. It seems like there are a couple different routes one could go. I tried automating the creation of geojson files from the .shp files that were originally retrieved with the Rscript linked above, but this is the first time I’ve ever used R and have no idea what I’m doing.
Similar to this R Script, ideally these could be done in R or python without needing to download a large GIS package. I’m just trying to think about automating this workflow in a way that the most amount of people could use it.
2. What steps can we take to reproduce this issue?
3. What have you tried to fix the issue?
I tried running this script made via chatGPT, but it looks like it’s creating the same item over and over again in a single .geojson.
library(sf)
setwd("/Users/tyler/Documents/myexamplepath")
shp_files <- list.files(pattern = "\\.shp$", full.names = TRUE)
for (shp in shp_files) {
shp_data <- st_read(shp, quiet = TRUE)
# Explode MultiPolygons into Polygons
shp_data <- st_cast(shp_data, "POLYGON")
geojson_file <- sub("\\.shp$", ".geojson", shp)
st_write(shp_data, geojson_file, driver = "GeoJSON", delete_dsn = TRUE)
cat("Converted:", shp, "->", geojson_file, "\n")
}
I saw this reference for converting SHP to SVG, but it requires arcGIS and manually relabeling IDs for each .SVG section.
Having a good example .SVG for say the 50 US States would be helpful to look at the formatting to see what code could automate this entire process.
4. Upload any forms or screenshots you can share publicly below.
GIN_adm.zip (936.0 KB) Here is the original .zip file for all the country data downloaded with the R Script from the showcase that could be used to make .







