GIS

How To Develop GIS Project in .Net Using NetTopolgySuite ?

What is GIS (Geographic Information Systems)

Geographic information system (GIS) is a system designed for capturing, storing, manipulating, analyzing, managing, and visualizing all types of spatial or geographic data. GIS connects data to a map, integrating location data with all types of descriptive information. Data formats used in GIS supports both spatial and informative data sets. 

GIS technology allows for the integration of multiple forms of information, including maps, numerical data, and text, in order to better understand relationships, patterns, and trends in the data. This technology is used in a wide range of fields, including geography, urban planning, environmental science, and many others

Common Usages In Real Life

  • Weather Forecast
  • GPS Based Tracking Systems
  • Discovering Patterns in Global Wildfires
  • Services Provides GIS solutions (Google Directions)
  • Transportation Planning Systems
  • Navigation
  • Disaster Overview Tools
  • Network Services
  • Region Based Surveys

NetTopologySuite Introduction

We mentioned earlier that a geographic information system (GIS) is a system that storing, manipulating, and analyzing spatial data.

Spatial data represents the physical location and the shape of objects. Many databases provide support for this type of data so it can be indexed and queried alongside other data.  Beside the nature of spatial data can be reflected into a program with ease. Entities represents a spatial shape or location can be imitate with objects in a program. Common scenarios include querying for objects within a given distance from a location, or selecting the object whose border contains a given location. EF Core supports mapping to spatial data types using the NetTopologySuite spatial library. Spatial analysis can be made by using the objects provided by NetTopologySuite

NetTopologySuite: Database Connection

NetTopologySuite supports following databases; SQL Server, PostgreSQL, MySQL, Oracle. Implementation can be done in basic steps. Below example demonstrates how we can use NetTopologySuite with SQL Server

Integrate NetTopologySuite With SQL Server

NetTopologySuite: Designing Domain

When we are working on a project provides GIS solutions, we are obligated to store, process, analyze spatial data. We mentioned earlier nature of spatial entities can be reflected to a program using objects. Thanks to NetTopologySuite, we will have all these objects that represents spatial entity.

There are several objects provided by NetTopologySuite listed below

Geometry
– Point
– LineString
– Polygon
GeometryCollection
– MultiPoint
– MultiLineString
– MultiPolygon

Let assume we are using EntityFramework and following code first approach to designing our database, we need start with designing our domain and create our entities. Lets create an example entity contains spatial data using spatial objects provided by NetTopologySuite

In the above example we create a LastLocation entity. Which we may encounter in a GPS based tracking systems. 

GPS tools sends X and Y coordinates of a spatial location which we can reflect with Point object provided by NetTopologySuite.

When Entity Framework start to read our entities and map into our database system, it will understand the Point data type and how he can map and operate since we told when we add UseNetTopologySuite options in the startup.

Required information will be provided by NetTopologySuite to EntityFramework

NetTopologySuite: Resource Management

NetTopologySuite supports data formats what modern Web API’s use. Such as XML and JSON. In GIS there are known data formats accepted by the community as a standard. NetTopologySuite supports following spatial data formats listed below. 

  • KML format when we are structuring spatial data when communicate with the services relies on XML data format. KML is a very popular spatial data format in the industry owned by google to use on google earth. Communication with the google earth services happens through KML.
  • GeoJSON also another known format used by the community. When the modern API’s used JSON data format got popular, GeoJSON start to become very popular. In 2016 The IETF (Internet Engineering Task Force) standardized the GeoJSON format with RFC 7946 Specification.

In the above stage we discuss about what data formats NetTopologySuite can support and produce. 

There are most common two format in the industry; KML and GeoJSON. Since using JSON data become into a standard. I will demonstrate how you can easily convert your geometry object into the standardized GeoJSON type.

Convert geometry to GeoJSON using NetTopologySuite

In the above example we can convert our geometry objects in the entity to GeoJSON using NetTopologySuite. It can be easily integrated our REST services and we can return JSON response contains our spatial data in GeoJSON format. Like the JsonSerializer, NetTopologySuite provides another helper class called GeoJsonSerializer which can help us to seralize or deserialize our GeoJSON and geometry objects to each other.

Above example demonstrates how we can deserialize GeoJSON into geometry objects using GeoJsonSerializer

In the article I tried to explain basic steps to work with the NetTopologySuite. Of course it is not everything there are so many things we can discuss about NetTopologySuite but I believe the post got long and I don’t want to make you bored 😀

If you want to get to know more about the GIS and NetTopologySuite. Stay tuned! We just started! I’m planning to share more about it in my following posts 🙂 Until then, take care 🙂 May the GeoJSON be with you!

teoman.me

Recent Posts

Angular 17 ile Bizi Neler Bekliyor ?

Herkese Merhabalar. Bildiğiniz üzere bu ay Angular 17 yepyeni bir imaj çalışması ile birlikte yayına…

12 months ago

OpenLayers Nasıl Kullanılır ?

Herkese merhaba arkadaşlar. Önceki yazımızda openlayers nedir ve neden kullanmalıyız sorunu yanıtlamıştık. Popüler harita kütüphanelerinden…

12 months ago

Openlayers Nedir ? Neden Tercih Etmeliyiz ?

Merhaba arkadaşlar. Eğer CBS (Coğrafi Bilgi Sistemleri) dünyasına yeni yeni adımlar atıyorsanız adını sık sık…

12 months ago

Angular NGXS – 5 Dakikada State Management! Part I

Herkese merhabalar. Bugün angular ekosisteminde NGXS kullanarak nasıl state management yapacağımızı inceleyeceğiz. Angular state management…

1 year ago

Angular vs React! Hangisini Tercih Etmeliyiz ?

Herkese Merhaba. Bu yazımızda frontend camiasında faaliyet gösteren herkesin aklındaki o soruya bir açıklık getireceğiz.…

1 year ago

Angular Template Driven Form Nedir ? Nasıl Kullanılır ?

Uzun bir aradan sonra herkese merhaba :) Angular Template Driven Form Nedir, Ne işe yarar…

1 year ago