Analyzing Indonesia’s Income Inequality in Cities through Spatial Clustering Approaches

Note: The datasets are scraped and cleaned from 2017’s report made by the Indonesia’s Central Agency on Statistics and can be downloaded in CSV format here.


Most income inequality studies are done on a global level, where different countries are compared to each other, and a ranking based on GDP per capita (or other metrics such as the Big Mac Index) is then established. Nonetheless, recent studies have begun to localize the problems, zooming in to regional, city, and even on district settings. Exploring income inequality in granular level not only demonstrates the growing availability of such datasets, but also reflects our growing desire to tackle this problem at its root.

In this article, we are going to explore and understand the income inequality problem that has plagued Indonesia especially acorss its cities. This exploratory work will use GDP per capita as a variable of interest that represents an individual annual income level. With the ground rules and outlines setup, let us begin!

The Datasets

First, we are going to ensure that the required datasets are placed in the appropriate directory. Let us name the directory as dataset for demonstration purposes.

mkdir dataset && cd dataset
  • GDP Per Capita CSV

The GDP per capita CSV contains information about the 521 cities in Indonesia and its corresponding GDP per capita as reported by Indonesia’ Central Agency on Statistics. The numbers are in thousands of Rupiah (1 USD is approximately 14,700 Rupiah as of this writing in August 2020,).

  • Indonesia Administration Shapefile

Download from this link and unzip the file inside your dataset directory. This will be the geographical layer that demarcates all city regions in Indonesia.

Initializing the Project

Next, we are going to import the necessary dependencies. Ensure you have the following packages:

  • Geopandas
  • Seaborn
  • Descartes
  • PySAL
  • Mapclassify
import geopandas as gpd
import matplotlib.pyplot as plt
import seaborn as sns
import numpy as np
import pandas as pd
import descartes
from sklearn import cluster
import pysal as ps
import mapclassify
%matplotlib inline

Load and Pre-process the Datasets

## Load the Shapefile
gdf = gpd.read_file('./dataset/idn_admbnda_adm2_bps_20200401.shp')

### Removing the prefix 'Kota' ('City' in English)
gdf['ADM2_EN'] = gdf['ADM2_EN'].str.replace('Kota ', '')

## Load the GDP_per_capita CSV and fill the NA value with 0
city_df = pd.read_csv('./dataset/city_gdp.csv', index_col=0)
city_df = city_df.fillna(0)
city_df = city_df.drop(['ADM1_EN'], axis=1)
city_df

Spatial Table Join

After loading and processing both of the datasets, we are going to perform a spatial table join to combine the raw city information (containing attributes such as area size, city name, _e_tc) with the GDP per capita data, using the city name as the key.

## Table join using ADM2_EN as key
joined_df = gdf.join(city_df.set_index('ADM2_EN'), on='ADM2_EN')
joined_df['gdp_capita'] = joined_df['gdp_capita'].fillna(0)

Exploratory Spatial Data Analysis (ESDA)

Visualizing GDP per Capita by Quantiles

At this point, we are going to take a quick peek into the spatial distribution of GDP per capita across the Indonesian cities. We are going to use geopandas’ plot function to do this, and aggregate the target values based on quantiles.

## Plot based on quantiles

joined_df.plot(column='gdp_capita',
               cmap='RdYlBu',
               legend=True,
               scheme='quantiles',
               figsize=(15, 10)
)
ax.set_axis_off()

Image for post

Image for post

Spatial Distribution of GDP per capita across Indonesia’s Cities based on 5-class Quantiles

Nice! The map looks pretty. Let’s continue.

#visualization #indonesia #income-inequality #machine-learning #data-science

What is GEEK

Buddha Community

Analyzing Indonesia’s Income Inequality in Cities through Spatial Clustering Approaches

Analyzing Indonesia’s Income Inequality in Cities through Spatial Clustering Approaches

Note: The datasets are scraped and cleaned from 2017’s report made by the Indonesia’s Central Agency on Statistics and can be downloaded in CSV format here.


Most income inequality studies are done on a global level, where different countries are compared to each other, and a ranking based on GDP per capita (or other metrics such as the Big Mac Index) is then established. Nonetheless, recent studies have begun to localize the problems, zooming in to regional, city, and even on district settings. Exploring income inequality in granular level not only demonstrates the growing availability of such datasets, but also reflects our growing desire to tackle this problem at its root.

In this article, we are going to explore and understand the income inequality problem that has plagued Indonesia especially acorss its cities. This exploratory work will use GDP per capita as a variable of interest that represents an individual annual income level. With the ground rules and outlines setup, let us begin!

The Datasets

First, we are going to ensure that the required datasets are placed in the appropriate directory. Let us name the directory as dataset for demonstration purposes.

mkdir dataset && cd dataset
  • GDP Per Capita CSV

The GDP per capita CSV contains information about the 521 cities in Indonesia and its corresponding GDP per capita as reported by Indonesia’ Central Agency on Statistics. The numbers are in thousands of Rupiah (1 USD is approximately 14,700 Rupiah as of this writing in August 2020,).

  • Indonesia Administration Shapefile

Download from this link and unzip the file inside your dataset directory. This will be the geographical layer that demarcates all city regions in Indonesia.

Initializing the Project

Next, we are going to import the necessary dependencies. Ensure you have the following packages:

  • Geopandas
  • Seaborn
  • Descartes
  • PySAL
  • Mapclassify
import geopandas as gpd
import matplotlib.pyplot as plt
import seaborn as sns
import numpy as np
import pandas as pd
import descartes
from sklearn import cluster
import pysal as ps
import mapclassify
%matplotlib inline

Load and Pre-process the Datasets

## Load the Shapefile
gdf = gpd.read_file('./dataset/idn_admbnda_adm2_bps_20200401.shp')

### Removing the prefix 'Kota' ('City' in English)
gdf['ADM2_EN'] = gdf['ADM2_EN'].str.replace('Kota ', '')

## Load the GDP_per_capita CSV and fill the NA value with 0
city_df = pd.read_csv('./dataset/city_gdp.csv', index_col=0)
city_df = city_df.fillna(0)
city_df = city_df.drop(['ADM1_EN'], axis=1)
city_df

Spatial Table Join

After loading and processing both of the datasets, we are going to perform a spatial table join to combine the raw city information (containing attributes such as area size, city name, _e_tc) with the GDP per capita data, using the city name as the key.

## Table join using ADM2_EN as key
joined_df = gdf.join(city_df.set_index('ADM2_EN'), on='ADM2_EN')
joined_df['gdp_capita'] = joined_df['gdp_capita'].fillna(0)

Exploratory Spatial Data Analysis (ESDA)

Visualizing GDP per Capita by Quantiles

At this point, we are going to take a quick peek into the spatial distribution of GDP per capita across the Indonesian cities. We are going to use geopandas’ plot function to do this, and aggregate the target values based on quantiles.

## Plot based on quantiles

joined_df.plot(column='gdp_capita',
               cmap='RdYlBu',
               legend=True,
               scheme='quantiles',
               figsize=(15, 10)
)
ax.set_axis_off()

Image for post

Image for post

Spatial Distribution of GDP per capita across Indonesia’s Cities based on 5-class Quantiles

Nice! The map looks pretty. Let’s continue.

#visualization #indonesia #income-inequality #machine-learning #data-science

Mike  Kozey

Mike Kozey

1656151740

Test_cov_console: Flutter Console Coverage Test

Flutter Console Coverage Test

This small dart tools is used to generate Flutter Coverage Test report to console

How to install

Add a line like this to your package's pubspec.yaml (and run an implicit flutter pub get):

dev_dependencies:
  test_cov_console: ^0.2.2

How to run

run the following command to make sure all flutter library is up-to-date

flutter pub get
Running "flutter pub get" in coverage...                            0.5s

run the following command to generate lcov.info on coverage directory

flutter test --coverage
00:02 +1: All tests passed!

run the tool to generate report from lcov.info

flutter pub run test_cov_console
---------------------------------------------|---------|---------|---------|-------------------|
File                                         |% Branch | % Funcs | % Lines | Uncovered Line #s |
---------------------------------------------|---------|---------|---------|-------------------|
lib/src/                                     |         |         |         |                   |
 print_cov.dart                              |  100.00 |  100.00 |   88.37 |...,149,205,206,207|
 print_cov_constants.dart                    |    0.00 |    0.00 |    0.00 |    no unit testing|
lib/                                         |         |         |         |                   |
 test_cov_console.dart                       |    0.00 |    0.00 |    0.00 |    no unit testing|
---------------------------------------------|---------|---------|---------|-------------------|
 All files with unit testing                 |  100.00 |  100.00 |   88.37 |                   |
---------------------------------------------|---------|---------|---------|-------------------|

Optional parameter

If not given a FILE, "coverage/lcov.info" will be used.
-f, --file=<FILE>                      The target lcov.info file to be reported
-e, --exclude=<STRING1,STRING2,...>    A list of contains string for files without unit testing
                                       to be excluded from report
-l, --line                             It will print Lines & Uncovered Lines only
                                       Branch & Functions coverage percentage will not be printed
-i, --ignore                           It will not print any file without unit testing
-m, --multi                            Report from multiple lcov.info files
-c, --csv                              Output to CSV file
-o, --output=<CSV-FILE>                Full path of output CSV file
                                       If not given, "coverage/test_cov_console.csv" will be used
-t, --total                            Print only the total coverage
                                       Note: it will ignore all other option (if any), except -m
-p, --pass=<MINIMUM>                   Print only the whether total coverage is passed MINIMUM value or not
                                       If the value >= MINIMUM, it will print PASSED, otherwise FAILED
                                       Note: it will ignore all other option (if any), except -m
-h, --help                             Show this help

example run the tool with parameters

flutter pub run test_cov_console --file=coverage/lcov.info --exclude=_constants,_mock
---------------------------------------------|---------|---------|---------|-------------------|
File                                         |% Branch | % Funcs | % Lines | Uncovered Line #s |
---------------------------------------------|---------|---------|---------|-------------------|
lib/src/                                     |         |         |         |                   |
 print_cov.dart                              |  100.00 |  100.00 |   88.37 |...,149,205,206,207|
lib/                                         |         |         |         |                   |
 test_cov_console.dart                       |    0.00 |    0.00 |    0.00 |    no unit testing|
---------------------------------------------|---------|---------|---------|-------------------|
 All files with unit testing                 |  100.00 |  100.00 |   88.37 |                   |
---------------------------------------------|---------|---------|---------|-------------------|

report for multiple lcov.info files (-m, --multi)

It support to run for multiple lcov.info files with the followings directory structures:
1. No root module
<root>/<module_a>
<root>/<module_a>/coverage/lcov.info
<root>/<module_a>/lib/src
<root>/<module_b>
<root>/<module_b>/coverage/lcov.info
<root>/<module_b>/lib/src
...
2. With root module
<root>/coverage/lcov.info
<root>/lib/src
<root>/<module_a>
<root>/<module_a>/coverage/lcov.info
<root>/<module_a>/lib/src
<root>/<module_b>
<root>/<module_b>/coverage/lcov.info
<root>/<module_b>/lib/src
...
You must run test_cov_console on <root> dir, and the report would be grouped by module, here is
the sample output for directory structure 'with root module':
flutter pub run test_cov_console --file=coverage/lcov.info --exclude=_constants,_mock --multi
---------------------------------------------|---------|---------|---------|-------------------|
File                                         |% Branch | % Funcs | % Lines | Uncovered Line #s |
---------------------------------------------|---------|---------|---------|-------------------|
lib/src/                                     |         |         |         |                   |
 print_cov.dart                              |  100.00 |  100.00 |   88.37 |...,149,205,206,207|
lib/                                         |         |         |         |                   |
 test_cov_console.dart                       |    0.00 |    0.00 |    0.00 |    no unit testing|
---------------------------------------------|---------|---------|---------|-------------------|
 All files with unit testing                 |  100.00 |  100.00 |   88.37 |                   |
---------------------------------------------|---------|---------|---------|-------------------|
---------------------------------------------|---------|---------|---------|-------------------|
File - module_a -                            |% Branch | % Funcs | % Lines | Uncovered Line #s |
---------------------------------------------|---------|---------|---------|-------------------|
lib/src/                                     |         |         |         |                   |
 print_cov.dart                              |  100.00 |  100.00 |   88.37 |...,149,205,206,207|
lib/                                         |         |         |         |                   |
 test_cov_console.dart                       |    0.00 |    0.00 |    0.00 |    no unit testing|
---------------------------------------------|---------|---------|---------|-------------------|
 All files with unit testing                 |  100.00 |  100.00 |   88.37 |                   |
---------------------------------------------|---------|---------|---------|-------------------|
---------------------------------------------|---------|---------|---------|-------------------|
File - module_b -                            |% Branch | % Funcs | % Lines | Uncovered Line #s |
---------------------------------------------|---------|---------|---------|-------------------|
lib/src/                                     |         |         |         |                   |
 print_cov.dart                              |  100.00 |  100.00 |   88.37 |...,149,205,206,207|
lib/                                         |         |         |         |                   |
 test_cov_console.dart                       |    0.00 |    0.00 |    0.00 |    no unit testing|
---------------------------------------------|---------|---------|---------|-------------------|
 All files with unit testing                 |  100.00 |  100.00 |   88.37 |                   |
---------------------------------------------|---------|---------|---------|-------------------|

Output to CSV file (-c, --csv, -o, --output)

flutter pub run test_cov_console -c --output=coverage/test_coverage.csv

#### sample CSV output file:
File,% Branch,% Funcs,% Lines,Uncovered Line #s
lib/,,,,
test_cov_console.dart,0.00,0.00,0.00,no unit testing
lib/src/,,,,
parser.dart,100.00,100.00,97.22,"97"
parser_constants.dart,100.00,100.00,100.00,""
print_cov.dart,100.00,100.00,82.91,"29,49,51,52,171,174,177,180,183,184,185,186,187,188,279,324,325,387,388,389,390,391,392,393,394,395,398"
print_cov_constants.dart,0.00,0.00,0.00,no unit testing
All files with unit testing,100.00,100.00,86.07,""

Installing

Use this package as an executable

Install it

You can install the package from the command line:

dart pub global activate test_cov_console

Use it

The package has the following executables:

$ test_cov_console

Use this package as a library

Depend on it

Run this command:

With Dart:

 $ dart pub add test_cov_console

With Flutter:

 $ flutter pub add test_cov_console

This will add a line like this to your package's pubspec.yaml (and run an implicit dart pub get):

dependencies:
  test_cov_console: ^0.2.2

Alternatively, your editor might support dart pub get or flutter pub get. Check the docs for your editor to learn more.

Import it

Now in your Dart code, you can use:

import 'package:test_cov_console/test_cov_console.dart';

example/lib/main.dart

import 'package:flutter/material.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        // This is the theme of your application.
        //
        // Try running your application with "flutter run". You'll see the
        // application has a blue toolbar. Then, without quitting the app, try
        // changing the primarySwatch below to Colors.green and then invoke
        // "hot reload" (press "r" in the console where you ran "flutter run",
        // or simply save your changes to "hot reload" in a Flutter IDE).
        // Notice that the counter didn't reset back to zero; the application
        // is not restarted.
        primarySwatch: Colors.blue,
        // This makes the visual density adapt to the platform that you run
        // the app on. For desktop platforms, the controls will be smaller and
        // closer together (more dense) than on mobile platforms.
        visualDensity: VisualDensity.adaptivePlatformDensity,
      ),
      home: MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key? key, required this.title}) : super(key: key);

  // This widget is the home page of your application. It is stateful, meaning
  // that it has a State object (defined below) that contains fields that affect
  // how it looks.

  // This class is the configuration for the state. It holds the values (in this
  // case the title) provided by the parent (in this case the App widget) and
  // used by the build method of the State. Fields in a Widget subclass are
  // always marked "final".

  final String title;

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  int _counter = 0;

  void _incrementCounter() {
    setState(() {
      // This call to setState tells the Flutter framework that something has
      // changed in this State, which causes it to rerun the build method below
      // so that the display can reflect the updated values. If we changed
      // _counter without calling setState(), then the build method would not be
      // called again, and so nothing would appear to happen.
      _counter++;
    });
  }

  @override
  Widget build(BuildContext context) {
    // This method is rerun every time setState is called, for instance as done
    // by the _incrementCounter method above.
    //
    // The Flutter framework has been optimized to make rerunning build methods
    // fast, so that you can just rebuild anything that needs updating rather
    // than having to individually change instances of widgets.
    return Scaffold(
      appBar: AppBar(
        // Here we take the value from the MyHomePage object that was created by
        // the App.build method, and use it to set our appbar title.
        title: Text(widget.title),
      ),
      body: Center(
        // Center is a layout widget. It takes a single child and positions it
        // in the middle of the parent.
        child: Column(
          // Column is also a layout widget. It takes a list of children and
          // arranges them vertically. By default, it sizes itself to fit its
          // children horizontally, and tries to be as tall as its parent.
          //
          // Invoke "debug painting" (press "p" in the console, choose the
          // "Toggle Debug Paint" action from the Flutter Inspector in Android
          // Studio, or the "Toggle Debug Paint" command in Visual Studio Code)
          // to see the wireframe for each widget.
          //
          // Column has various properties to control how it sizes itself and
          // how it positions its children. Here we use mainAxisAlignment to
          // center the children vertically; the main axis here is the vertical
          // axis because Columns are vertical (the cross axis would be
          // horizontal).
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            Text(
              'You have pushed the button this many times:',
            ),
            Text(
              '$_counter',
              style: Theme.of(context).textTheme.headline4,
            ),
          ],
        ),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: _incrementCounter,
        tooltip: 'Increment',
        child: Icon(Icons.add),
      ), // This trailing comma makes auto-formatting nicer for build methods.
    );
  }
}

Author: DigitalKatalis
Source Code: https://github.com/DigitalKatalis/test_cov_console 
License: BSD-3-Clause license

#flutter #dart #test 

I am Developer

1597487472

Country State City Dropdown list in PHP MySQL PHP

Here, i will show you how to populate country state city in dropdown list in php mysql using ajax.

Country State City Dropdown List in PHP using Ajax

You can use the below given steps to retrieve and display country, state and city in dropdown list in PHP MySQL database using jQuery ajax onchange:

  • Step 1: Create Country State City Table
  • Step 2: Insert Data Into Country State City Table
  • Step 3: Create DB Connection PHP File
  • Step 4: Create Html Form For Display Country, State and City Dropdown
  • Step 5: Get States by Selected Country from MySQL Database in Dropdown List using PHP script
  • Step 6: Get Cities by Selected State from MySQL Database in DropDown List using PHP script

https://www.tutsmake.com/country-state-city-database-in-mysql-php-ajax/

#country state city drop down list in php mysql #country state city database in mysql php #country state city drop down list using ajax in php #country state city drop down list using ajax in php demo #country state city drop down list using ajax php example #country state city drop down list in php mysql ajax

Top 10+ iPhone App Development Companies in New York City 2020 – TopDevelopers.co

Profusely examined top iPhone App Development Companies in New York City with ratings & reviews to help find the best iPhone App Developers to build your solution.

#iphone app development service providers in new york city #top iphone app development companies in new york city #new york city based top iphone app development firms #best iphone app developers at new york city #new york city #top iphone app developers

I am Developer

1597487833

Country State City Drop Down List using Ajax in Laravel

Here, i will show you how to create dynamic depedent country state city dropdown list using ajax in laravel.

Country State City Dropdown List using Ajax in php Laravel

Follow Below given steps to create dynamic dependent country state city dropdown list with jQuery ajax in laravel:

  • Step 1: Install Laravel App
  • Step 2: Add Database Details
  • Step 3: Create Country State City Migration and Model File
  • Step 4: Add Routes For Country State City
  • Step 5: Create Controller For Fetch Country State City
  • Step 6: Create Blade File For Show Dependent Country State City in Dropdown
  • Step 7: Run Development Server

https://www.tutsmake.com/ajax-country-state-city-dropdown-in-laravel/

#how to create dynamic dropdown list using laravel dynamic select box in laravel #laravel-country state city package #laravel country state city drop down #dynamic dropdown country city state list in laravel using ajax #country state city dropdown list using ajax in php laravel #country state city dropdown list using ajax in laravel demo