
Build a full stack mvc web app with the Bortnikov framework to monitor monthly water consumption by Cape Town neighborhoods, using a quadruples map and a bar chart.
Download and install PostgreSQL 13 on Windows, install Stack Builder add-ons including PGA agent, ODBC driver, and PostGIS, then create a sample spatial database to verify PostGIS works.
Create a spatial database with pgAdmin by creating a database, configuring a login role, granting privileges, and enabling postgis extensions and postgis topology extension for spatial data.
Install osgeo4w on Windows to access geospatial tools and libraries. Download the network installer, configure security settings, run express install, set environment variables, and restart to apply.
Install the .NET SDK version 6, download the latest long-term support release, and verify the installation with the dotnet version command to enable web GIS development.
Download and install the Visual Studio Code IDE, create a projects folder with a what to watch subfolder, then install C# extensions and set the default theme to begin developing.
Create a starter ASP.NET MVC 6 project with dotnet, open it in code, run the app to verify the template, then prepare to build your own application.
Install entity framework core packages to map tables to C# objects and enable read and write operations, using dotnet add package commands and verify in the project.
Create a C# model class named water consumption with fields Eid, neighborhood, suburb group, average monthly kilolitre (int), and coordinates (string), including getters and setters, mapping to a Postgres table.
Create a data context interface to connect to the database, enable reading and writing to the consumptions table in Postgres, and provide a save changes function.
Create and implement the data context class, add using directives, wire the data context interface with a constructor, and register the data context in the program file under services.
Configure and save a new connection string for the Postgres database in app settings, then add the configuration in program.cs and save the changes.
Create and apply database migrations, then update the database. Verify in pgAdmin that a Postgres table is created and its fields match the model.
Create a data repository interface in C# to define map-ready queries, including get all and get top 10 consumers by average monthly kilolitre for displaying on the map.
Implement the repository class by injecting the data context, define data queries including top 10 consumers by average monthly kilolitre using LINQ, and register the repository in program.cs.
Download the dataset from the water watch repository, locate the 2021 water consumption json file, and save it as json, then transform the data into the required bound table format.
Learn to extract, transform, and load JSON data into a spatial table in a c# asp.net core mvc app using NewtonSoft.Json, reading from a feature collection and populating the repository.
Create a rest api controller to expose endpoints for getting all data and the top 10 water consumers, backed by a repository and json responses for map data.
Download and extract the front-end static files from the repository, then copy the app folder into your project root and verify the assets are ready for use.
Modify the layout using the Admiralty template with a green skin, adding a wrapper and side bar, and place content in the main section to reuse the layout across pages.
Create the index page by adding the Leaflet library and jQuery references, inserting custom styles, and preparing scripts to build maps using Leaflet on the page.
Create your first Leaflet map by configuring a div container, loading the base map, and initializing the default view and zoom. Test by running the application to confirm success.
Learn to create and switch between multiple base maps by initializing base layers, labeling each map, and adding a layer control in a Leaflet-based web GIS app.
Fetch neighborhood data via a url endpoint using jQuery's getJson, convert coordinates to arrays, and render multi polygon neighborhoods on a Leaflet map, then style by average monthly kilolitre.
Style the map by applying a color gradient to polygons based on average monthly kilolitre value, highlighting neighborhoods with higher water use in darker greens.
Add interactivity to a static map by implementing hover-driven pop up that shows neighborhood details, including sub group, name, and water usage, with mouseover and mouseout styling for polygons.
Create a legend for the map with a Leaflet control in the bottom-right, mapping color grades to water consumption in kilolitres and displaying their values.
Create a bar chart legend as a Leaflet control placed in the top right corner, using a canvas to draw bars and the title 'top 10 consumers in kilolitres'.
Create a horizontal bar chart displaying the top 10 water-consuming neighborhoods by using Ajax to fetch average monthly kilolitre values from a top 10 endpoint and render with chalkboard.js.
Welcome to the Building Web GIS Apps with C# ASP.NET CORE MVC and Leaflet course. We'll be building a Full-stack MVC style Web Application using the .NET Core Framework. The purpose of this course and many more to follow, is to learn to create geospatial analytics and convert it into a functional application.
In our use case we will be working with suburban water consumption data and we will be applying data processing techniques to extract transform and load the data into our spatial database. Once we have processed and cleaned the data, we will use it as a data source for building our .NET Core Web Map Application.
We will be powering our application with a PostgreSQL and PostGIS database. In the Front-End we'll use Bootstrap, JavaScript, Leaflet and Ajax. On the server side we'll be using C#, ASP.NET CORE MVC, combined with use of libraries like Entity Framework Core, Newtonsoft.Json and Npgsql for our data transformation and conversion operations. The operating system that we will be working on is Windows 10 and Server 2016.
Some skills that you can expect to derive after completing the course are the following:
You will learn how to build a Spatial Database using Postgresql and PostGIS.
You will learn how to create charts with Chart.js.
You will learn to build Web Maps with Leaflet.js.
You will learn how to build REST API Endpoints with C# and LINQ
You will learn some C# programming.
You will learn some JavaScript programming.
You will learn how to build Web Applications using the C# and ASP.NET Core MVC Framework.