Table of contents

From Shapefile to TopoJSON

a transformation process from the Shapefile format to the TopoJSON format, both of which are file formats used in geographic information systems (GIS).


Shapefile

Download the latest SHP file of administrative divisions
Shapefiles are a popular file format used in geographic information systems (GIS) for storing the geometric location and attribute information of spatial features.
Shapefiles store the geometry of spatial features using vector coordinates. This geometry can represent various types of features like points, lines, and polygons (areas).
[ESRI Shapefile Technical Description]


Shapefile to GeoJSON

  • GeoJSON
    GeoJSON is a format for encoding a variety of geographic data structures.
    {
      "type": "Feature",
      "geometry": {
          "type": "Point",
          "coordinates": [125.6, 10.1]
      },
      "properties": {
          "name": "Dinagat Islands"
      }
    }
    
  • ์†์„ฑํ…Œ์ด๋ธ” ํ™•์ธํ•˜๊ธฐ (QGIS)
    ๋ ˆ์ด์–ด ํŒจ๋„์—์„œ [sig] layer์— ๋งˆ์šฐ์Šค ์˜ค๋ฅธ์ชฝ ํด๋ฆญ > โ€˜์†์„ฑ ํ…Œ์ด๋ธ” ์—ด๊ธฐ(A)โ€™ ํด๋ฆญ

  • ๋‹ค๋ฅธ ํŒŒ์ผ๊ณผ ๊ฒฐํ•ฉํ•˜์ง€ ์•Š์„ ๋•Œ
    1. [ํŒŒ์ผ๋ช…].shp ํŒŒ์ผ ์ถ”๊ฐ€(๋ ˆ์ด์–ด ํŒจ๋„์— ํŒŒ์ผ ๋“œ๋ž˜๊ทธ)
    2. ๋ ˆ์ด์–ด ํŒจ๋„์—์„œ [sig] layer์— ๋งˆ์šฐ์Šค ์˜ค๋ฅธ์ชฝ ํด๋ฆญ > โ€˜Exportโ€™ > โ€˜๊ฐ์ฒด๋ฅผ ๋‹ค๋ฅธ ์ด๋ฆ„์œผ๋กœ ์ €์žฅโ€™ > ์•„๋ž˜์˜ ๋‚ด์šฉ ์ž‘์„ฑ ๋’ค โ€˜ํ™•์ธโ€™ ๋ฒ„ํŠผ ํด๋ฆญ
      ํฌ๋งท: GeoJSON / ํŒŒ์ผ ์ด๋ฆ„: ํŒŒ์ผ ์œ„์น˜โ‚ฉ[filename].geojson / ์ขŒํ‘œ๊ณ„: ํ”„๋กœ์ ํŠธ ์ขŒํ‘œ๊ณ„: EPSG:4326 - WGS 84 / ์ธ์ฝ”๋”ฉ: UTF-8
    3. geoJSON ํŒŒ์ผ์ด ์ƒ์„ฑ๋จ.
  • ์†์„ฑํ…Œ์ด๋ธ”์˜ ์ถ”๊ฐ€ ์ •๋ณด๋ฅผ csv์—์„œ ๊ฐ€์ ธ์™€ ์กฐ์ธํ•˜๊ธฐ
    1. [ํŒŒ์ผ๋ช…].shp ํŒŒ์ผ ์ถ”๊ฐ€(๋ ˆ์ด์–ด ํŒจ๋„์— ํŒŒ์ผ ๋“œ๋ž˜๊ทธ)
    2. csv ํŒŒ์ผ ๋ถˆ๋Ÿฌ์˜ค๊ธฐ
      ๋ ˆ์ด์–ด > ๋ฐ์ดํ„ฐ ์›๋ณธ ๊ด€๋ฆฌ์ž ํด๋ฆญ
      ๊ตฌ๋ถ„์ž๋กœ ๋ถ„๋ฆฌ๋œ ํ…์ŠคํŠธ ํด๋ฆญ > ํŒŒ์ผ ์„ ํƒ > ์ธ์ฝ”๋”ฉ ํ™•์ธ(UTF-8) > ๋„ํ˜•์—†์Œ(์†์„ฑ๋งŒ ์žˆ๋Š” ํ…Œ์ด๋ธ”) ํด๋ฆญ > ์ถ”๊ฐ€ ํด๋ฆญ
      ๋ ˆ์ด์–ด์— ์ถ”๊ฐ€๋œ ๊ฒƒ์„ ๋ณผ ์ˆ˜ ์žˆ์Œ
    3. ์†์„ฑ ๊ฒฐํ•ฉํ•˜๊ธฐ
      ๋ ˆ์ด์–ด์†์„ฑ> ๊ฒฐํ•ฉ > + ๋ฒ„ํŠผ ํด๋ฆญ
      ๋ฒกํ„ฐ ๊ฒฐํ•ฉ ์ถ”๊ฐ€ํ•˜๊ธฐ
      ๊ฒฐํ•ฉ ๋ ˆ์ด์–ด: csv ํŒŒ์ผ๋ช… / ๋Œ€์ƒ ํ•„๋“œ๋ฅผ ๊ธฐ์ค€์œผ๋กœ ๋‚˜๋จธ์ง€ ์ •๋ณด ์ถ”๊ฐ€ ์ ์šฉ > ํ™•์ธ ์†์„ฑ ํ…Œ์ด๋ธ” ํ™•์ธ
    4. ๋ ˆ์ด์–ด ํŒจ๋„์—์„œ sig layer์— ๋งˆ์šฐ์Šค ์˜ค๋ฅธ์ชฝ ํด๋ฆญ > Export > ๊ฐ์ฒด๋ฅผ ๋‹ค๋ฅธ ์ด๋ฆ„์œผ๋กœ ์ €์žฅ
    5. geoJSON ํŒŒ์ผ์ด ์ƒ์„ฑ๋จ

GeoJSON to TopoJSON

  • TopoJSON topojson specification
    TopoJSON is an extension of GeoJSON that encodes topology. Rather than representing geometries discretely, geometries in TopoJSON files are stitched together from shared line segments called arcs
    {
      "type": "Topology",
      "objects": {
          "dinagatIslands": {
              "type": "GeometryCollection",
              "geometries": [
                  {
                      "type": "Point",
                      "properties": {
                          "name": "Dinagat Islands"
                      },
                      "coordinates": [125.6, 10.1]
                  }
              ]
          }
      }
    }
    

    mapshaper

    1. geoJSON ํŒŒ์ผ ๋“œ๋ž˜๊ทธ ์ธ
    2. โ€œdetect line intersectionsโ€ ์ฒดํฌ > import ํด๋ฆญ
    3. simplify ํด๋ฆญ > Settings ์กฐ์ ˆ(์ž‘์„์ˆ˜๋ก ๊ฒฝ๊ณ„๊ฐ€ ๋‹จ์ˆœํ•ด์ง) > โ€œVisvalingam/weighted areaโ€ ์„ ํƒ > apply
    4. Export ํด๋ฆญ > TopoJSON ํด๋ฆญ > Export ํด๋ฆญ
    5. topoJSON ํŒŒ์ผ์ด ์ƒ์„ฑ๋จ