Coder Social home page Coder Social logo

yasserius / bangladesh_geojson_shapefile Goto Github PK

View Code? Open in Web Editor NEW
16.0 2.0 8.0 119 KB

GeoJSON Shapefiles of Bangladesh - Division, District/Zilla, Upozilla, Thana/Union

bangladesh shapefiles geojson shp-file division thana union districts zila upazila

bangladesh_geojson_shapefile's Introduction

Bangladesh GeoJSON Shapefiles - Division, District/Zilla, Upozilla, Thana/Union

GeoJSON or SHP shapefile - Boundary / Outline shapes of Bangladesh Divisions (বিভাগ), Districts / Zila / Jela (জেলা), Upazila / Upojela (উপজেলা), Unions / Thanas (থানা)

Download

Shapefiles in SHP format: [humdata.org] (Original Source)

Shapefiles in GeoJSON format: [Google Drive] (Converted)

Contents

Note:

  • adm = Administration Regions
  • adm0 = Entire Bangladesh
  • adm1 = 8 Divisions
  • adm2 = 64 Districts/Zilas
  • adm3 = 492 Upazilas
  • adm4 = 5160 Thanas/Unions

GeoJSON files:

  • bangladesh_geojson_adm0_whole_bangladesh_outline.json
  • bangladesh_geojson_adm1_8_divisions_bibhags.json
  • bangladesh_geojson_adm2_64_districts_zillas.json
  • bangladesh_geojson_adm3_492_upozila.json
  • bangladesh_geojson_adm4_5160_unions_thanas.json
  • bangladesh_geojson_admALL_2_entire_bd_division_district_unions.json
  • bangladesh_geojson_admALL_entire_bd_division_district_unions.json

Inside small folder (smaller file size):

  • small_bangladesh_geojson_adm0_whole_bangladesh_outline.json
  • small_bangladesh_geojson_adm1_8_divisions_bibhags.json
  • small_bangladesh_geojson_adm2_64_districts_zillas.json
  • small_bangladesh_geojson_adm3_492_upozila.json
  • small_bangladesh_geojson_adm4_5160_unions_thanas.json

How to open GeoJSON / SHP files with Python

How to reduce GeoJSON file size

How to convert from SHP to GeoJSON (using ogr)

Source of converter function: medium.com
Link to OGR: link

# Python >= 3.7
import ogr
import json

def shp2json(shp_path):
  """
  Convert SHP files to GeoJSON with OGR.
  Outputs JSON file to same directory as the SHP files.
  
  Input:
    - shp_path (str):
        e.g. "D:/somewhere/bangladesh.shp"
  """
  driver = ogr.GetDriverByName('ESRI Shapefile')
  data_source = driver.Open(shp_path, 0)

  fc = {
      'type': 'FeatureCollection',
      'features': []
      }

  lyr = data_source.GetLayer(0)
  for feature in lyr:    
      fc['features'].append(feature.ExportToJson(as_object=True))

  output_name = shp_path.split(".")[0] + ".json"

  with open(output_name, 'w') as f:
      json.dump(fc, f)
      print("GeoJSON file created: {}".format(output_name))

You can also do it with libraries like geopandas.

bangladesh_geojson_shapefile's People

Contributors

yasserius avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.