Skip to content

Instantly share code, notes, and snippets.

@typebrook
Last active February 4, 2023 02:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save typebrook/3cdc4cf351669a8400aca06229f891a6 to your computer and use it in GitHub Desktop.
Save typebrook/3cdc4cf351669a8400aca06229f891a6 to your computer and use it in GitHub Desktop.
Extract fields from county raw data #gis #gov #taiwan
kaohsiung.csv:
curl -Lo $@ https://data.kcg.gov.tw/dataset/7b142b2b-4d92-4a22-ac63-339c95bb0dfc/resource/d6e12411-8655-40ff-a2b2-ea3791c7c586/download/firehydrantonground.csv
taipei.csv:
curl -L https://data.taipei/api/getDatasetInfo/downloadResource\?id\=c106a00b-5a21-4393-b213-475a0ece9f2b\&rid\=b9f8154d-c627-48a8-b3ef-512ed9cde9e7 \
| iconv -f BIG-5 -t UTF-8 >$@
taoyuan_97.csv:
curl -Lo raw.json https://data.tycg.gov.tw/opendata/datalist/datasetMeta/download\?id\=3fd4a492-bcae-45be-8184-aa6fad506701\&rid\=ea487112-ef5b-481a-b49a-26f52dc04b93
echo 'FID,類別碼,識別碼,高程,x,y' >$@
jq '.[] | .properties.geometry=.geometry.coordinates | .properties|"\(.FID),\(.["類別碼"]),\(.["識別碼"]),\(.geometry[2]),\(.geometry[0]),\(.geometry[1])"' raw.json -r >>$@
taoyuan.csv: taoyuan_97.csv
ogr2ogr $@ $< \
-oo X_POSSIBLE_NAMES=x \
-oo Y_POSSIBLE_NAMES=y \
-lco GEOMETRY=AS_XY \
-oo KEEP_GEOM_COLUMNS=NO \
-s_srs "EPSG:3826" \
-t_srs "EPSG:4326"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment