SlideShare a Scribd company logo
Python for Open Source GIS
OSGeo Thailand Meetup 5/2019
Mr. Chaipat Nengcomma
Ayutthaya GIS Consultant.
Part I : Introduction
2
What Can I Do With
Python + Open Source GIS ??
ตัวอยางการนําไปใชของที่ Lab
3
Drone Mapping
4
Drone Mapping
Drone Processing Pipeline
[Python Rastool , GDAL
, OTB, PyODM ]
Dataset
[Image, GCPs]
Geo Mapping
(Ortho rectified Mosaic Image)
DSM/DEM
Point Cloud
{LAZ}
Ayutthaya GIS Consultant Co., Ltd.
Drone Mapping
Drone Mapping
Deep Learning Pipeline
Ortho Rectification
Image
Classification Report
Object Detection
Analysis
AOI Training
DSM
Ayutthaya GIS Consultant Co., Ltd.
Drone Mapping Ayutthaya GIS Consultant Co., Ltd.
Land Cover Classification
9
Land Cover Classification
● Supervised Classification Multi-Sensor Data Integration Using
Deep Learning
● ประมวลผลถายดาวเทียมแบบ Supervised Classification โดยการ
พัฒนา complex model ที่วิเคราะหผลกับขอมูลขนาดใหญ จาก
หลายแหลง แบบ Multi-Sensor มาทําการวิเคราะหรวมกัน เพื่อสราง
ขอมูลผลลัพธการจําแนก ที่แมนยําและมีประสิทธิภาพขึ้น
Mr. Chaipat @Ayutthaya GIS
10
Land Cover Classification
Mr. Chaipat @Ayutthaya GIS
11
Land Cover Classification
Mr. Chaipat @Ayutthaya GIS
12
Land Cover Classification
Mr. Chaipat @Ayutthaya GIS
13
Deep Neural Network
Green Project
Mr. Chaipat @Ayutthaya GIS
14
Green Project
Mr. Chaipat @Ayutthaya GIS
15
Smart Farm
16
Soil Quality
Surface Temperature
Rainfall
Type of Rice
Soil Moisture
Deep Learning
Report
-crop yield estimation
-Anomaly Detection
17
Ayutthaya GIS Consultant Co., Ltd.
Water level
Crop Yield Estimation
Satellite Image
Crop Yield Estimation
Ayutthaya GIS Consultant Co., Ltd.
Soil Moisture
Surface Temperature
Soil PH
Plant
Deep Learning
Report
-Crop health
monitor
-Anomaly Detection
19
Ayutthaya GIS Consultant Co., Ltd.
xx
Crop Health Monitor
Satellite Image
Crop Health Monitor
Ayutthaya GIS Consultant Co., Ltd.
Automatic Plant Watering System
21
APWS
Mr. Chaipat @Ayutthaya GIS
22
System Control
Anemometer
Air Temperature
Air Humidity
Slope
Deep RNN
Report
- Soil Moisture Index
23
Ayutthaya GIS Consultant Co., Ltd.
xxx
xxx
APWS
xxx
xxx
Nearest
distance
Soil Moisture{t+1}
Prediction
Soil Moisture
24
APWS
Pump On
Pump Off
Mr. Chaipat @Ayutthaya GIS
DS (Tn) <= 3 DS (Tn+x) > 8
APWS
- Raspbian
- Python , Tensorflow + Keras , Scikit learn
- Postgresql
- Flask
Introduction
26
Introduction
● Python เปนภาษาโปรแกรมคอมพิวเตอรระดับสูง มากความสามารถ
รองรับการทํางานขามแพลตฟอรมระบบปฏิบัติการ, รองรับการทํางาน
หลากหลายประเภท
● GIS คือระบบสารสนเทศเชิงพื้นที่ +การบริหารจัดการขอมูลตําแหนง
● Open Source GIS software คือ ซอฟตแวร พัฒนาระบบ GIS แบบ
รหัสเปด
Mr. Chaipat @Ayutthaya GIS
27
Introduction
● Open Source Geospatial Foundation (OSGEO) มูลนิธิ
Geospatial Open Source เปนองคกรไมแสวงหาผลกําไร
● ภารกิจคือการสนับสนุนและสงเสริมการพัฒนาความรวมมือของ
เทคโนโลยีและขอมูลภูมิสารสนเทศแบบเปด
28
Mr. Chaipat @Ayutthaya GIS
Open Source GIS
Desktop GIS QGIS, GRASS GIS
Data Management API GDAL , OGR , Proj4
Spatial Database Postgresql+Postgis , Spatial lite
(SQLite),
GIS Server GeoServer , MapServer, Qgis Server
Web Application Framework Openlayers, Leaflet
29
Mr. Chaipat @Ayutthaya GIS
Open Source GIS
30
Mr. Chaipat @Ayutthaya GIS
Python & GIS
● Python เปนภาษาคอมพิวเตอรที่เปน tools สําคัญในงานดานการวิเคราะห
ขอมูลเชิงพื้นที่ โดยเฉพาะลักษณะ กระบวนการทํางานแบบ อัตโนมัติ
● รองรับดานการจัดการขอมูล , การประมวลผล การแสดงผล รวมไปถึงความ
สามารถในการพัฒนา application ตางๆ
● ภาษาผสานใน GIS Software เชน QGIS , ArcGIS, GRASS ชวยเพิ่ม
ประสิทธิภาพในการทํางาน
31
Mr. Chaipat @Ayutthaya GIS
Python & GIS
● Python เปนเหมือนตัวเชื่อมประสาน การทํางานรวมกันระหวางนัก GIS
กับ Developer
● มีการเติบโต และขยายของนักพัฒนา ทําใหมี opensource lib รองรับ
จํานวนมาก สวนหนึ่งตอยอดจาก opensource gis เดิม รวมถึงการ
พัฒนาโมเดลใหมๆในลักษณะ GIS programming stack
32
Mr. Chaipat @Ayutthaya GIS
Python & GIS
● ขยายขีดความสามารถในการเขาถึงและวิเคราะหขอมูล spatail data
ในระบบงานที่ซับซอน
● งานดาน Data science ,
● นําขอมูลเชิงพื้นที่ มาสูกระบวนการพัฒนา AI (Machine Learning ,
Deep Learning)
● ธุรกิจ / บริการ ที่ตอยอดจากขอมูลเชิงพื้นที่
33
Mr. Chaipat @Ayutthaya GIS
Spatial Data science
34
Spatial Data science
● Data science กระบวนการทางวิทยาศาสตรเพื่อวิเคราะห เจาะ
ลึก ทําความเขาใจ เพื่อสกัดนํามูลคาจากขอมูลขนาดใหญ ขอมูล
ที่มีโครงสรางซับซอน
● Spatial Data = ขอมูลเชิงปริภูมิ / ขอมูลภูมิสารสนเทศ / ขอมูล
เชิงพื้นที่
● Key คือ ขอมูลที่อางอิงกับตําแหนงบนผิวโลก
35
Mr. Chaipat @Ayutthaya GIS
Data science
36
Mr. Chaipat @Ayutthaya GIS
Alí Santacruz ,amsantac.co
37
Spatial Data science
Spatial Data Science and Applications
38
Spatial Data science
39
Mr. Chaipat @Ayutthaya GIS
Data science
40
Mr. Chaipat @Ayutthaya GIS
Data science
41
Machine Learning
42
Data science
43
Part II : Development
44
Python Geospatial
Development Stack
45
Python Geospatial Development Stack
Layer Package
Name
Description URL
Spatial Data IO gdal Interface to Geospatial data
abstraction library
https://pypi.python.org/pypi/GDAL/
(link is external)
fiona API to OGR (Vector) layer of
GDAL
http://toblerity.org/fiona/
(link is external)
rasterio Reading and writing geospatial
raster data
https://github.com/mapbox/rasterio
(link is external)
46
Mr. Chaipat @Ayutthaya GIS
Python Geospatial Development Stack
Layer Package
Name
Description URL
Geoprocessing shapely Deterministic spatial analysis http://toblerity.org/shapely
rasterstats Summarizing rasters using
vector geometries https://github.com/perrygeo/python-rasterstats
geopandas Pandas-like spatial operations
on geometric types
http://geopandas.org
pyproj PROJ4 Interface for
cartographic transformations
https://github.com/jswhit/pyproj
47
Mr. Chaipat @Ayutthaya GIS
Python Geospatial Development Stack
Layer Package
Name
Description URL
Geo visualization basemap Plotting 2D data on maps https://github.com/matplotlib/basemap
cartopy Cartographic tools http://scitools.org.uk/cartopy
folium Visualization via interactive
Leaflet maps https://github.com/python-visualization/folium
Bokeh (geo) Interactive visualization library
browsers
https://github.com/bokeh
datashader Big data visualization graphics
pipeline
https://github.com/bokeh/datashader
48
Mr. Chaipat @Ayutthaya GIS
Python Geospatial Development Stack
Layer Package
Name
Description URL
Spatial Statistical
Analysis
PySAL Spatial data analysis http://pysal.org
pykriging Geostatistics http://pykriging.com/
OSMnx +
Networkx
network analysis , OpenStreetMap Data
Analysis
https://osmnx.readthedocs.io/en/stable/
https://networkx.github.io/documentation/
networkx-1.10/overview.html
49
Mr. Chaipat @Ayutthaya GIS
Python Geospatial Development Stack
Layer Package
Name
Description URL
Web & Data Service OWSlib Client programming interface to OGC web
service
https://geopython.github.io/OWSLib
PyWPS OGC WPS Framework for geospatial data https://pywps.org/
MapProxy Open source proxy for geospatial data. , Tile
cache & WMS server
https://mapproxy.org/
50
Mr. Chaipat @Ayutthaya GIS
Python Geospatial Installation
51
Installation
● ติดตั้งผาน pip ไดเกือบทั้งหมด
● บาง lib อาจจะตองมีการ compile source code
● 99% รองรับการทํางานกับ Window OS รองรับ Anapip
● รองรับการทํางานบน Linux / Mac
52
Mr. Chaipat @Ayutthaya GIS
Installation
# Install shapely
conda install -c conda-forge shapely
# Install geopandas
conda install -c conda-forge geopandas
# Install cartopy
conda install -c conda-forge cartopy
# Install networkx
conda install networkx
# Install osmnx
conda install -c conda-forge osmnx
# Install statsmodels
conda install statsmodels
# Install folium
conda install -c conda-forge folium
# Install bokeh
conda install bokeh
# Install shapely
pip install shapely
# Install geopandas
pip install geopandas
# Install cartopy
pip install cartopy
# Install networkx
pip install networkx
# Install osmnx
pip install osmnx
# Install statsmodels
pip install statsmodels
# Install folium
pip install folium
# Install bokeh
pip install bokeh
53
Installation
- สามารถ import ตัว lib ไดแบบไมมี error
- หรือ สามารถรัน print() ดูรายละเอียดของการติดตั้งและ package ได
แปล วาพรอมจะทํางาน
import geopandas
import scipy
import shapely
import matplotlib.pyplot as plt
import pysal
import bokeh
import cartopy
import statsmodels
54
Mr. Chaipat @Ayutthaya GIS
Google Colaboratory
55
Google Colaboratory
- free Jupyter notebook environment
- Support Python 2 , 3
- Linux OS
- execute code, save and share code & result
- access powerful computing resources {CPU/GPU/TPU}
- Data storage : Google Drive
56
Mr. Chaipat @Ayutthaya GIS
Google Colaboratory
57
Mr. Chaipat @Ayutthaya GIS
Google Colaboratory
https://colab.research.google.com/notebooks/basic_features_overview.ipynb
https://colab.research.google.com
58
Google Colaboratory
59
Mr. Chaipat @Ayutthaya GIS
Google Colaboratory
60
Mr. Chaipat @Ayutthaya GIS
Google Colaboratory
61
Ayutthaya GIS Consultant Co., Ltd.
Google Drive
from google.colab import drive
drive.mount('/content/gdrive/')
data_dir = os.path.join('/content/gdrive', 'My Drive','colab_notebooks')
os.listdir(data_dir)
62
Mr. Chaipat @Ayutthaya GIS
Spatial Data Model
63
Spatial Data Model
● การสรางแบบจําลองขอมูลเชิงพื้นที่ในระบบสารสนเทศ
● Spatial Data Model
a. Vector Data model
b. Raster Data Model
64
Mr. Chaipat @Ayutthaya GIS
Spatial Data Model
65
Mr. Chaipat @Ayutthaya GIS
Spatial Data Model
● Vector Data Model คือ geometric objects รหัสเชิงเลข ที่ใชนิยาม
ตัวแทนวัตถุในระบบคอมพิวเตอร
● Geometry Object โดยมีการระบุพิกัดตําแหนงอางอิง และ index เชื่อม
โยงกับขอมูลบรรยายที่เกี่ยวของ
● สามารถแบง Geometry Object พื้นฐาน ไดแก Point , Line และ
Polygon
● ยังสามารถแยกยอยตามระนาบทั้ง 2D และ 3D
66
Mr. Chaipat @Ayutthaya GIS
Spatial Data Model
67
Spatial Data Model & GeoPandas
● Python มี module ในการจัดการขอมูล geometry หลายตัว ใน
workshop นี้จะเรียนรูจักการจัดการดวย Geopandas
● GeoPandas เปน open source package สรางเพื่อการทํางานกับ
ขอมูล geospatial ลักษณะของการผูกรวม
● โดยการประมวลผลดาน data model เบื้องหลังมี shapely ( GEOS
C++ library) ดําเนินการ
●
68
Mr. Chaipat @Ayutthaya GIS
Spatial Data Model & GeoPandas
69
Mr. Chaipat @Ayutthaya GIS
Point
● “จุด” ตัวแทน ประกอบดวยตัวเลขพิกัด 2 มิติ หรือ 3 มิต ิบน space
● ทดลองทําการสราง point จากกลุมขอมูลพิกัด 2 มิติโดยใชคลาส
Geoseries
● จากนั้นทําการสราง geometry object สําหรับ Geodataframe บน
pandas โดยทําการระบุระบบพิกัดอางอิง(CRS) เปน EPSG:4326
70
Mr. Chaipat @Ayutthaya GIS
Point
71
Mr. Chaipat @Ayutthaya GIS
Point
72
Mr. Chaipat @Ayutthaya GIS
Line
● “เสน” ตัวแทนประกอบดวย set ของจุดเชื่อมตอกัน
● ทําการสราง Linestring object จากกลุมขอมูลของ point แบบ 2 มิติ ซึ่ง
point จะเปนตัวแทนของ node ที่อยูบน Line ที่สรางขึ้น
73
Mr. Chaipat @Ayutthaya GIS
Line
74
Mr. Chaipat @Ayutthaya GIS
Line
75
Polygon
● พื้นที่รูปปด ตัวแทนของรูปทรงปด ที่ประกอบดวย จุดอางอิง ตัวแทน
ตําแหนง node และ edge ที่แนนอน
● ตัวอยาง ทําการสราง Polygon object จากกลุมขอมูลของ Point 2 มิติ
ที่เปนตัวแทนของ node ของ polygon
● จากนั้นใช geoseries ในการสราง geometry object ประเภท
polygon ขึ้นมาโดยจะไดรูปปด ที่มีทั้ง node และ edge สุดทายสามารถ
นําไปใชคํานวณคุณสมบัติประกอบอื่นๆไดตอไป
76
Mr. Chaipat @Ayutthaya GIS
Polygon
77
Mr. Chaipat @Ayutthaya GIS
Polygon
78
Mr. Chaipat @Ayutthaya GIS
Polygon
● พื้นที่รูปปดจะมีคุณสมบัติ เชน พื้นที่, เสนรอบรูป และจุดกึ่งกลาง
● ตัวอยาง ทําการคํานวณคุณสมบัติเรขาคณิตของ polygon พื้นฐาน
ไดแก Area, BBOX , Centroid
79
Mr. Chaipat @Ayutthaya GIS
Polygon
80
Mr. Chaipat @Ayutthaya GIS
Spatial Data Management
81
Spatial Data Management
● GeoPandas อาน/เขียน และจัดการไฟล GIS format ผาน Fiona
(OGR + Proj4)
● Plot หรือแสดงผล geometry ดวย descartes(เดการต) (matplotlib)
● Pandas จัดการขอมูล attribute data , table และ sql query
● GeoDataframe
82
Mr. Chaipat @Ayutthaya GIS
Spatial Data format
● GeoPandas รองรับการทํางานกับ GIS Vector File เกือบทุกประเภท
เชนเดียวกับ OGR
● รองรับประเภทหลักเชน Shapefile, GeoJSON, KML และ GPKG
83
Mr. Chaipat @Ayutthaya GIS
Spatial Data Management
● ทําการเปดและอานไฟล province.shp จากโฟเดอร data
● ทดสอบผลการอานไฟลดวยการ แสดงขอมูลบน table
● แสดงขอมูล Geometry object แบบ WKT (polygon) พรอมขอมูลจาก
database(.dbf)
● Plot แผนที่จาก ขอมูล geometry พรอมระบบพิกัด
84
Mr. Chaipat @Ayutthaya GIS
Spatial Data Management
85
Spatial Reference System
86
Spatial Reference System(SRS)
● Aka coordinate reference system (CRS)
● การนิยามระบบพิกัดอางอิงของ Geometry model ในระบบที่ใชเปน
ตัวแทนวัตถุบนพื้นโลก
● Map Projection = โมเดลการฉายผิวโลกทรงโคง 3D ใหกลายเปน
แผนที่(Map) 2 มิติ
87
Mr. Chaipat @Ayutthaya GIS
Spatial Reference System(SRS)
● ระบบพิกัดอางอิง (coordinate system) ของขอมูลเชิงพื้นที่
● การระบุพิกัดตําแหนงอางอิงบนแผนที่
>Geographic coordinate system (latitude, longitude)
>Universal Transverse Mercator (UTM)
88
Mr. Chaipat @Ayutthaya GIS
Geographic coordinate system
● การระบุพิกัดตําแหนงอางอิงบนแผนที่แบบ latitude, longitude
89
Mr. Chaipat @Ayutthaya GIS
Geographic coordinate system
90
Mr. Chaipat @Ayutthaya GIS
Universal Transverse Mercator (UTM)
● การระบุพิกัดตําแหนงอางอิงบนแผนที่แบบ GRID
● เมืองไทยมีพิกัดตกบนกริด UTM โซน 47 และ 48 มีรหัสเลขชวง N, P
และ Q
● ตัวอยาง 47P356482
91
Mr. Chaipat @Ayutthaya GIS
พื้นหลักฐานอางอิง (Datum)
● ระบบหลักฐานที่ใชอางอิงในการกําหนดคาทางแนวดิ่งและแนวราบ
● เพื่อใชเปนจุดบังคับทางความสูงและควบคุมตําแหนงบนแผนที่ สําหรับอางอิงใน
การหาตําแหนงบนพื้นผิวโลก
● Horizontal Datum
> Local Datum : ไทยใช Indian Datum 1975
> Global Datum WGS 84 (World Geodetic System 1984)แ
● Vertical Datum :ไทยใช คาอางอิงจากระดับนํ้าทะเลปานกลาง ณ เกาะหลัก
จังหวัดประจวบ
92
Mr. Chaipat @Ayutthaya GIS
Universal Transverse Mercator (UTM)
● การระบุพิกัดตําแหนงอางอิงบนแผนที่แบบ GRID
● เมืองไทยมีพิกัด SRS ประเภท UTM ที่พบไดแก
● EPSG 32647 ,
● EPSG 24047
● EPSG 32648,
● EPSG 24048
93
Mr. Chaipat @Ayutthaya GIS
EPSG:32647 WGS 84 / UTM zone 47N
94
EPSG:24047 Indian 1975 / UTM zone 47N
95
EPSG:32648 WGS 84 / UTM zone 48N
96
EPSG:900913 Google Maps Global Mercator
97
Geocode
98
Geocode
● การแปลงจากชื่อ ที่อยู (address) ใหกลายเปน ระบบพิกัดบนโลก
● รวมถึงขอมูล IP address
● โดยมีบริการ(service) ในการแปลง ทําหนาที่คนหาที่อยูจากฐานขอมูล
sptial database แลวคํานวณพิกัดตําแหนง สงกลับมายังปลายทาง
● เชน Google Geocoding API , OSM Map API, Bing เปนตน
● Python modules ไดแก Geopy, Geocoder , Geopandas
99
Mr. Chaipat @Ayutthaya GIS
OGC Web Feature Service
100
WFS
- Open Geospatial Consortium (OGC)
- Web feature service โปรโตคอลมาตรฐานของ OGC พัฒนาขึ้นเพื่อ
บริการขอมูล spatial data
- เชื่อมโยงการทํางานระหวางระบบ GIS แบบ interoperability ในการ
เขาถึงขอมูลผาน webservice
- ขาม platform ,ขาม software , ขาม data format
- อางอิงเพิ่มเติม
https://www.opengeospatial.org/standards/wfs
101
Mr. Chaipat @Ayutthaya GIS
WFS
102
Mr. Chaipat @Ayutthaya GIS
WFS
103
Mr. Chaipat @Ayutthaya GIS
WFS
104
Mr. Chaipat @Ayutthaya GIS
WFS
- โปรโตคอลการทํางานเบื้องตนของ OGC WFS
- ประกอบดวย 3 Operation หลักคือ
1.GetCapabilities
2.DescribeFeatureType
3.GetFeature
105
Mr. Chaipat @Ayutthaya GIS
WFS - GetCapabilities
- Operation เพื่อสงคํารองสืบคาไปยัง WFS server เพื่อตรวจสอบ
สถานะและขอมูลที่ใหบริการ
- http://localhost/geoserver/ows?service=WFS
&version=1.0.0&request=GetCapabilities
106
Mr. Chaipat @Ayutthaya GIS
WFS - GetCapabilities
107
WFS - DescribeFeatureType
- Operation เพื่อสงคํารองสืบคาไปยัง WFS server เพื่อเขาถึงขอมูล
รายละเอียดและคําอธิบายของขอมูลแตละ layer
- http://localhost/geoserver/ows?service=WFS
&version=1.0.0
&request=DescribeFeatureType
&typename=geosolutions:Counties
108
Mr. Chaipat @Ayutthaya GIS
WFS - DescribeFeatureType
109
WFS - GetFeature
- Operation เพื่อสงคํารองสืบคาไปยัง WFS server เพื่อเขาถึงขอมูล
Spatial data ที่ตองการ โดยการสืบคน ตองระบุพารามิเตอร สําคัญ เชน
ชื่อชั้นขอมูล และสามารถกําหนด parameter เพิ่มเติมในการกรองเชน
bbox,
- ผลลัพธ ปกติจะเปน GML3 แตมีทางเลือกอื่นๆขึ้นกับ server เชน
geojson , wkb เปนตน
110
Mr. Chaipat @Ayutthaya GIS
WFS - GetFeature
- Operation
- http://localhost/geoserver/ows?service=WFS
- &version=1.0.0
- &request=GetFeature
- &typeName=geosolutions:Counties
- &maxFeatures=50
- &outputFormat=GML3
111
Mr. Chaipat @Ayutthaya GIS
WFS - GetFeature
112
Mr. Chaipat @Ayutthaya GIS
WFS - Server
WFS in thailand (gov)
http://fgds-backend.ngis.go.th/geoserver/geonode/ows?
http://gservices.gistda.or.th/geoserver/wfs
http://mapservices.energy.go.th:80/geoserver/ows?
113
Spatial Data Analysis
114
Spatial Data Analysis
● การวิเคราหขอมูลเชิงพื้นที่ ประกอบดวย
1. Geoprocessing
คือ การประมวลผล เพื่อสรางขอมูล geometry ใหมจากขอมูล geometry ตั้งตน
และสวนการประมวลผล ระหวาง geometry เพื่อสรางผลลัพธใหม
> function การแปลง geometry data และสรางผลลัพธขอมูล attribute ใหม
> Buffer , Merge , Difference, Intersection, Union เปนตน
> ศึกษาเพิ่มเติมจาก http://geopandas.org/reference.html
● 2. Spatial Relation
คือความสัมพันธระหวาง geometry ตัวบงบอกคุณลักษณะ และคุณสมบัติขอมูล สําหรับการ
วิเคราะห
115
Spatial Data Analysis
- การวิเคราะหขอมูลเชิงพื้นที่ ยังรวมไปถึงการวิเคราะหเชิงลึกอื่นๆ
- เชน Spatial temporal analysis, Terrain analysis, Surface Analysis: Spatial
Interpolation หรือ spatial statistic analysis เปนตน
116
Mr. Chaipat @Ayutthaya GIS
Geoprocessing
saylordotorg.github.io
117
Spatial Query
118
Spatial Query
● กระบวนการสืบคนขอมูลเชิงตําแหนง ที่ใชเงื่อนไขเชิงตําแหนงในการวิเคราะห
ขอมูลเพื่อใหไดผลลัพธตามตองการ
● นํา geometry data มารวมในการสรางเงื่อนไขเพื่อทําการวิเคราะห หรือสืบคน
หาขอมูล จากฐานขอมูล
● คนหาดวยเงื่อนไข จาก spatial relation function ไดแก
● contains(), crosses(), .intersects(),overlaps(),touches(), disjoint(),
within()
119
Mr. Chaipat @Ayutthaya GIS
Spatial relation
120
Mr. Chaipat @Ayutthaya GIS
Spatial Query
121
Mr. Chaipat @Ayutthaya GIS
Thematic map
122
Thematic map
● การสรางแผนที่เฉพาะเรื่อง จากการกําหนดเงื่อนไข ในฐานขอมูล GIS
● นําผลลัพธจากการวิเคราะหขอมูล มาสรางเปนแผนที่เฉพาะทาง
● อธิบายเลาเรื่อง โดยกําหนด ลักษณะการแสดงผล สี สัญลักษณ ตามคา(value)
● จากเงื่อนไขบน logical operation และ spatial operation
123
Mr. Chaipat @Ayutthaya GIS
Thematic map
124
Mr. Chaipat @Ayutthaya GIS
Thematic map
125
Web Mapping Application
● การพัฒนาระบบบริการขอมูล GIS แบบออนไลน ผานอินเตอรเน็ต
● รองรับการแสดงผล และการสืบคนขอมูล
● Python มีหลา่ยโมดูลที่สามารถเลือกใชงานได
● ตัวอยางใช Geopandas + Bokeh
● นอกจากนี้ มีการเชื่อมโยงและผสานการแสดงผลขอมูลกับ Map service ทั้ง
WMS, WMST
126
Mr. Chaipat @Ayutthaya GIS
Web Mapping Application
127
Mr. Chaipat @Ayutthaya GIS
Question ???
128

More Related Content

What's hot

Geodesy, Map Projections - Introduction
Geodesy, Map Projections - IntroductionGeodesy, Map Projections - Introduction
Geodesy, Map Projections - Introduction
Dean Mikkelsen
 
UNIT - III GIS DATA STRUCTURES (2).ppt
UNIT - III GIS DATA STRUCTURES (2).pptUNIT - III GIS DATA STRUCTURES (2).ppt
UNIT - III GIS DATA STRUCTURES (2).ppt
RamMishra65
 
BASIC CONCEPTS OF PHOTOGRAMMETRY
BASIC CONCEPTS OF PHOTOGRAMMETRYBASIC CONCEPTS OF PHOTOGRAMMETRY
BASIC CONCEPTS OF PHOTOGRAMMETRY
Namitha M R
 
GIS data analysis
GIS data analysisGIS data analysis
GIS data analysis
Arindam Sarkar
 
Remote Sensing ppt
Remote Sensing pptRemote Sensing ppt
Remote Sensing ppt
Ishtdeep Hora
 
Geoinformatics handbook
Geoinformatics handbookGeoinformatics handbook
Geoinformatics handbook
MOHAMMEDFAIZAN69
 
Geo referencing by Mashhood Arif
Geo referencing by Mashhood ArifGeo referencing by Mashhood Arif
Geo referencing by Mashhood Arif
KU Leuven
 
Components of gis
Components of gisComponents of gis
Components of gis
Pramoda Raj
 
Maps Ppt
Maps PptMaps Ppt
Maps Ppt
Donald Johnson
 
Basics to gis concepts unit i
Basics to gis concepts unit iBasics to gis concepts unit i
Basics to gis concepts unit i
H.M College of science and technology, Manjeri
 
Cartography
CartographyCartography
Cartography
Pramoda Raj
 
GIS fundamentals - vector
GIS fundamentals - vectorGIS fundamentals - vector
GIS fundamentals - vector
Hans van der Kwast
 
GIS data structure
GIS data structureGIS data structure
GIS data structure
Thana Chirapiwat
 
IMAGE INTERPRETATION TECHNIQUES of survey
IMAGE INTERPRETATION TECHNIQUES of surveyIMAGE INTERPRETATION TECHNIQUES of survey
IMAGE INTERPRETATION TECHNIQUES of survey
Karan Patel
 
6. Shapefiles in gis
6. Shapefiles in gis6. Shapefiles in gis
6. Shapefiles in gis
KU Leuven
 
Map Design and Symbology in GIS Environment
Map Design and Symbology in GIS EnvironmentMap Design and Symbology in GIS Environment
Map Design and Symbology in GIS Environment
Kaium Chowdhury
 
Symbology and Classifying data in ARC GIS
Symbology and Classifying data in ARC GISSymbology and Classifying data in ARC GIS
Symbology and Classifying data in ARC GIS
KU Leuven
 
DTM DEM Generation
DTM DEM GenerationDTM DEM Generation
DTM DEM Generation
Nurul Amirah Isa
 
Surveying geodesy ajith sir
Surveying   geodesy ajith sirSurveying   geodesy ajith sir
Surveying geodesy ajith sir
SHAMJITH KM
 

What's hot (20)

Geodesy, Map Projections - Introduction
Geodesy, Map Projections - IntroductionGeodesy, Map Projections - Introduction
Geodesy, Map Projections - Introduction
 
UNIT - III GIS DATA STRUCTURES (2).ppt
UNIT - III GIS DATA STRUCTURES (2).pptUNIT - III GIS DATA STRUCTURES (2).ppt
UNIT - III GIS DATA STRUCTURES (2).ppt
 
BASIC CONCEPTS OF PHOTOGRAMMETRY
BASIC CONCEPTS OF PHOTOGRAMMETRYBASIC CONCEPTS OF PHOTOGRAMMETRY
BASIC CONCEPTS OF PHOTOGRAMMETRY
 
GIS data analysis
GIS data analysisGIS data analysis
GIS data analysis
 
Remote Sensing ppt
Remote Sensing pptRemote Sensing ppt
Remote Sensing ppt
 
Geoinformatics handbook
Geoinformatics handbookGeoinformatics handbook
Geoinformatics handbook
 
Geo referencing by Mashhood Arif
Geo referencing by Mashhood ArifGeo referencing by Mashhood Arif
Geo referencing by Mashhood Arif
 
Components of gis
Components of gisComponents of gis
Components of gis
 
Maps Ppt
Maps PptMaps Ppt
Maps Ppt
 
Basics to gis concepts unit i
Basics to gis concepts unit iBasics to gis concepts unit i
Basics to gis concepts unit i
 
Cartography
CartographyCartography
Cartography
 
GIS fundamentals - vector
GIS fundamentals - vectorGIS fundamentals - vector
GIS fundamentals - vector
 
Vectors and Rasters
Vectors and RastersVectors and Rasters
Vectors and Rasters
 
GIS data structure
GIS data structureGIS data structure
GIS data structure
 
IMAGE INTERPRETATION TECHNIQUES of survey
IMAGE INTERPRETATION TECHNIQUES of surveyIMAGE INTERPRETATION TECHNIQUES of survey
IMAGE INTERPRETATION TECHNIQUES of survey
 
6. Shapefiles in gis
6. Shapefiles in gis6. Shapefiles in gis
6. Shapefiles in gis
 
Map Design and Symbology in GIS Environment
Map Design and Symbology in GIS EnvironmentMap Design and Symbology in GIS Environment
Map Design and Symbology in GIS Environment
 
Symbology and Classifying data in ARC GIS
Symbology and Classifying data in ARC GISSymbology and Classifying data in ARC GIS
Symbology and Classifying data in ARC GIS
 
DTM DEM Generation
DTM DEM GenerationDTM DEM Generation
DTM DEM Generation
 
Surveying geodesy ajith sir
Surveying   geodesy ajith sirSurveying   geodesy ajith sir
Surveying geodesy ajith sir
 

Similar to Python for GIS

บทความ Big Data จากบล็อก thanachart.org
บทความ Big Data จากบล็อก thanachart.orgบทความ Big Data จากบล็อก thanachart.org
บทความ Big Data จากบล็อก thanachart.org
IMC Institute
 
azure-app-jump-start-wAzure App Jumpstart using GitHub Codespaces and Azure D...
azure-app-jump-start-wAzure App Jumpstart using GitHub Codespaces and Azure D...azure-app-jump-start-wAzure App Jumpstart using GitHub Codespaces and Azure D...
azure-app-jump-start-wAzure App Jumpstart using GitHub Codespaces and Azure D...
Kumton Suttiraksiri
 
Intro to Azure OpenAI Service L100 (Thai Ver).pdf
Intro to Azure OpenAI Service L100 (Thai Ver).pdfIntro to Azure OpenAI Service L100 (Thai Ver).pdf
Intro to Azure OpenAI Service L100 (Thai Ver).pdf
Korkrid Akepanidtaworn
 
Big data 101
Big data 101Big data 101
Big data 101
Somkiat Puisungnoen
 
Python Programming for Lecturer_RUS_Nonthaburi 17may2019
Python Programming for Lecturer_RUS_Nonthaburi 17may2019Python Programming for Lecturer_RUS_Nonthaburi 17may2019
Python Programming for Lecturer_RUS_Nonthaburi 17may2019
Asst.Prof.Dr.Arnut Ruttanatirakul
 
โครงการอบรม Rpi โดย บริษัท หาดใหญ่โรบ็อท จำกัด
โครงการอบรม Rpi โดย บริษัท หาดใหญ่โรบ็อท จำกัดโครงการอบรม Rpi โดย บริษัท หาดใหญ่โรบ็อท จำกัด
โครงการอบรม Rpi โดย บริษัท หาดใหญ่โรบ็อท จำกัด
Webidea Petchtharat
 
UK Gas Consumption
UK Gas ConsumptionUK Gas Consumption
UK Gas Consumption
aekfin
 
The project schedule and budget
The project schedule and budgetThe project schedule and budget
The project schedule and budget
tumetr1
 
eMagazine "G-Box"
eMagazine "G-Box" eMagazine "G-Box"
eMagazine "G-Box" chom-manad
 
NECTEC E-magazine Vol.2
NECTEC E-magazine Vol.2NECTEC E-magazine Vol.2
NECTEC E-magazine Vol.2
NECTEC
 
Traceability platform concept
Traceability platform  conceptTraceability platform  concept
Traceability platform conceptPisuth paiboonrat
 
Traceability platform concept
Traceability platform  conceptTraceability platform  concept
Traceability platform conceptPisuth paiboonrat
 
Traceability platform concept
Traceability platform  conceptTraceability platform  concept
Traceability platform conceptPisuth paiboonrat
 
Data Science สำหรับผู้เริ่มต้น - WordCamp Bangkok 2017
Data Science สำหรับผู้เริ่มต้น - WordCamp Bangkok 2017Data Science สำหรับผู้เริ่มต้น - WordCamp Bangkok 2017
Data Science สำหรับผู้เริ่มต้น - WordCamp Bangkok 2017
woratana
 
การสอนครั้งที่ 2 intro ความรู้เบื้องต้นเกี่ยวกับคอมพิวเตอร์กราฟิก
การสอนครั้งที่ 2   intro ความรู้เบื้องต้นเกี่ยวกับคอมพิวเตอร์กราฟิกการสอนครั้งที่ 2   intro ความรู้เบื้องต้นเกี่ยวกับคอมพิวเตอร์กราฟิก
การสอนครั้งที่ 2 intro ความรู้เบื้องต้นเกี่ยวกับคอมพิวเตอร์กราฟิกjibbie23
 
แนวโน้มของเทคโนโลยี และ Cloud Computing
แนวโน้มของเทคโนโลยี และ Cloud Computingแนวโน้มของเทคโนโลยี และ Cloud Computing
แนวโน้มของเทคโนโลยี และ Cloud Computing
IMC Institute
 
20110816 oss4edu-nsru
20110816 oss4edu-nsru20110816 oss4edu-nsru
20110816 oss4edu-nsru
Boonkiat Chetchamnongnuch
 
Ogctaxmap
OgctaxmapOgctaxmap
Ogctaxmap
Ayutthaya GIS
 
Sketch up 8
Sketch up 8 Sketch up 8

Similar to Python for GIS (20)

WebGIS
WebGISWebGIS
WebGIS
 
บทความ Big Data จากบล็อก thanachart.org
บทความ Big Data จากบล็อก thanachart.orgบทความ Big Data จากบล็อก thanachart.org
บทความ Big Data จากบล็อก thanachart.org
 
azure-app-jump-start-wAzure App Jumpstart using GitHub Codespaces and Azure D...
azure-app-jump-start-wAzure App Jumpstart using GitHub Codespaces and Azure D...azure-app-jump-start-wAzure App Jumpstart using GitHub Codespaces and Azure D...
azure-app-jump-start-wAzure App Jumpstart using GitHub Codespaces and Azure D...
 
Intro to Azure OpenAI Service L100 (Thai Ver).pdf
Intro to Azure OpenAI Service L100 (Thai Ver).pdfIntro to Azure OpenAI Service L100 (Thai Ver).pdf
Intro to Azure OpenAI Service L100 (Thai Ver).pdf
 
Big data 101
Big data 101Big data 101
Big data 101
 
Python Programming for Lecturer_RUS_Nonthaburi 17may2019
Python Programming for Lecturer_RUS_Nonthaburi 17may2019Python Programming for Lecturer_RUS_Nonthaburi 17may2019
Python Programming for Lecturer_RUS_Nonthaburi 17may2019
 
โครงการอบรม Rpi โดย บริษัท หาดใหญ่โรบ็อท จำกัด
โครงการอบรม Rpi โดย บริษัท หาดใหญ่โรบ็อท จำกัดโครงการอบรม Rpi โดย บริษัท หาดใหญ่โรบ็อท จำกัด
โครงการอบรม Rpi โดย บริษัท หาดใหญ่โรบ็อท จำกัด
 
UK Gas Consumption
UK Gas ConsumptionUK Gas Consumption
UK Gas Consumption
 
The project schedule and budget
The project schedule and budgetThe project schedule and budget
The project schedule and budget
 
eMagazine "G-Box"
eMagazine "G-Box" eMagazine "G-Box"
eMagazine "G-Box"
 
NECTEC E-magazine Vol.2
NECTEC E-magazine Vol.2NECTEC E-magazine Vol.2
NECTEC E-magazine Vol.2
 
Traceability platform concept
Traceability platform  conceptTraceability platform  concept
Traceability platform concept
 
Traceability platform concept
Traceability platform  conceptTraceability platform  concept
Traceability platform concept
 
Traceability platform concept
Traceability platform  conceptTraceability platform  concept
Traceability platform concept
 
Data Science สำหรับผู้เริ่มต้น - WordCamp Bangkok 2017
Data Science สำหรับผู้เริ่มต้น - WordCamp Bangkok 2017Data Science สำหรับผู้เริ่มต้น - WordCamp Bangkok 2017
Data Science สำหรับผู้เริ่มต้น - WordCamp Bangkok 2017
 
การสอนครั้งที่ 2 intro ความรู้เบื้องต้นเกี่ยวกับคอมพิวเตอร์กราฟิก
การสอนครั้งที่ 2   intro ความรู้เบื้องต้นเกี่ยวกับคอมพิวเตอร์กราฟิกการสอนครั้งที่ 2   intro ความรู้เบื้องต้นเกี่ยวกับคอมพิวเตอร์กราฟิก
การสอนครั้งที่ 2 intro ความรู้เบื้องต้นเกี่ยวกับคอมพิวเตอร์กราฟิก
 
แนวโน้มของเทคโนโลยี และ Cloud Computing
แนวโน้มของเทคโนโลยี และ Cloud Computingแนวโน้มของเทคโนโลยี และ Cloud Computing
แนวโน้มของเทคโนโลยี และ Cloud Computing
 
20110816 oss4edu-nsru
20110816 oss4edu-nsru20110816 oss4edu-nsru
20110816 oss4edu-nsru
 
Ogctaxmap
OgctaxmapOgctaxmap
Ogctaxmap
 
Sketch up 8
Sketch up 8 Sketch up 8
Sketch up 8
 

More from Ayutthaya GIS

30879960 geospatial-system-on-cloud-computing
30879960 geospatial-system-on-cloud-computing30879960 geospatial-system-on-cloud-computing
30879960 geospatial-system-on-cloud-computingAyutthaya GIS
 
GeoSMSSensor
GeoSMSSensorGeoSMSSensor
GeoSMSSensor
Ayutthaya GIS
 
Geoserver 85
Geoserver 85Geoserver 85
Geoserver 85
Ayutthaya GIS
 
Chula Geoportal Emap
Chula Geoportal EmapChula Geoportal Emap
Chula Geoportal Emap
Ayutthaya GIS
 
geoweb2.0
geoweb2.0geoweb2.0
geoweb2.0
Ayutthaya GIS
 

More from Ayutthaya GIS (11)

Wps
WpsWps
Wps
 
Android report
Android reportAndroid report
Android report
 
30879960 geospatial-system-on-cloud-computing
30879960 geospatial-system-on-cloud-computing30879960 geospatial-system-on-cloud-computing
30879960 geospatial-system-on-cloud-computing
 
Concect postgis
Concect postgisConcect postgis
Concect postgis
 
Foss4g thai
Foss4g thaiFoss4g thai
Foss4g thai
 
GeoSMSSensor
GeoSMSSensorGeoSMSSensor
GeoSMSSensor
 
Geoserver 85
Geoserver 85Geoserver 85
Geoserver 85
 
Map
MapMap
Map
 
Ajax&Geoweb C
Ajax&Geoweb CAjax&Geoweb C
Ajax&Geoweb C
 
Chula Geoportal Emap
Chula Geoportal EmapChula Geoportal Emap
Chula Geoportal Emap
 
geoweb2.0
geoweb2.0geoweb2.0
geoweb2.0
 

Python for GIS

  • 1. Python for Open Source GIS OSGeo Thailand Meetup 5/2019 Mr. Chaipat Nengcomma Ayutthaya GIS Consultant. Part I : Introduction 2 What Can I Do With Python + Open Source GIS ?? ตัวอยางการนําไปใชของที่ Lab 3 Drone Mapping 4
  • 2. Drone Mapping Drone Processing Pipeline [Python Rastool , GDAL , OTB, PyODM ] Dataset [Image, GCPs] Geo Mapping (Ortho rectified Mosaic Image) DSM/DEM Point Cloud {LAZ} Ayutthaya GIS Consultant Co., Ltd. Drone Mapping Drone Mapping Deep Learning Pipeline Ortho Rectification Image Classification Report Object Detection Analysis AOI Training DSM Ayutthaya GIS Consultant Co., Ltd. Drone Mapping Ayutthaya GIS Consultant Co., Ltd.
  • 3. Land Cover Classification 9 Land Cover Classification ● Supervised Classification Multi-Sensor Data Integration Using Deep Learning ● ประมวลผลถายดาวเทียมแบบ Supervised Classification โดยการ พัฒนา complex model ที่วิเคราะหผลกับขอมูลขนาดใหญ จาก หลายแหลง แบบ Multi-Sensor มาทําการวิเคราะหรวมกัน เพื่อสราง ขอมูลผลลัพธการจําแนก ที่แมนยําและมีประสิทธิภาพขึ้น Mr. Chaipat @Ayutthaya GIS 10 Land Cover Classification Mr. Chaipat @Ayutthaya GIS 11 Land Cover Classification Mr. Chaipat @Ayutthaya GIS 12
  • 4. Land Cover Classification Mr. Chaipat @Ayutthaya GIS 13 Deep Neural Network Green Project Mr. Chaipat @Ayutthaya GIS 14 Green Project Mr. Chaipat @Ayutthaya GIS 15 Smart Farm 16
  • 5. Soil Quality Surface Temperature Rainfall Type of Rice Soil Moisture Deep Learning Report -crop yield estimation -Anomaly Detection 17 Ayutthaya GIS Consultant Co., Ltd. Water level Crop Yield Estimation Satellite Image Crop Yield Estimation Ayutthaya GIS Consultant Co., Ltd. Soil Moisture Surface Temperature Soil PH Plant Deep Learning Report -Crop health monitor -Anomaly Detection 19 Ayutthaya GIS Consultant Co., Ltd. xx Crop Health Monitor Satellite Image Crop Health Monitor Ayutthaya GIS Consultant Co., Ltd.
  • 6. Automatic Plant Watering System 21 APWS Mr. Chaipat @Ayutthaya GIS 22 System Control Anemometer Air Temperature Air Humidity Slope Deep RNN Report - Soil Moisture Index 23 Ayutthaya GIS Consultant Co., Ltd. xxx xxx APWS xxx xxx Nearest distance Soil Moisture{t+1} Prediction Soil Moisture 24 APWS Pump On Pump Off Mr. Chaipat @Ayutthaya GIS DS (Tn) <= 3 DS (Tn+x) > 8
  • 7. APWS - Raspbian - Python , Tensorflow + Keras , Scikit learn - Postgresql - Flask Introduction 26 Introduction ● Python เปนภาษาโปรแกรมคอมพิวเตอรระดับสูง มากความสามารถ รองรับการทํางานขามแพลตฟอรมระบบปฏิบัติการ, รองรับการทํางาน หลากหลายประเภท ● GIS คือระบบสารสนเทศเชิงพื้นที่ +การบริหารจัดการขอมูลตําแหนง ● Open Source GIS software คือ ซอฟตแวร พัฒนาระบบ GIS แบบ รหัสเปด Mr. Chaipat @Ayutthaya GIS 27 Introduction ● Open Source Geospatial Foundation (OSGEO) มูลนิธิ Geospatial Open Source เปนองคกรไมแสวงหาผลกําไร ● ภารกิจคือการสนับสนุนและสงเสริมการพัฒนาความรวมมือของ เทคโนโลยีและขอมูลภูมิสารสนเทศแบบเปด 28 Mr. Chaipat @Ayutthaya GIS
  • 8. Open Source GIS Desktop GIS QGIS, GRASS GIS Data Management API GDAL , OGR , Proj4 Spatial Database Postgresql+Postgis , Spatial lite (SQLite), GIS Server GeoServer , MapServer, Qgis Server Web Application Framework Openlayers, Leaflet 29 Mr. Chaipat @Ayutthaya GIS Open Source GIS 30 Mr. Chaipat @Ayutthaya GIS Python & GIS ● Python เปนภาษาคอมพิวเตอรที่เปน tools สําคัญในงานดานการวิเคราะห ขอมูลเชิงพื้นที่ โดยเฉพาะลักษณะ กระบวนการทํางานแบบ อัตโนมัติ ● รองรับดานการจัดการขอมูล , การประมวลผล การแสดงผล รวมไปถึงความ สามารถในการพัฒนา application ตางๆ ● ภาษาผสานใน GIS Software เชน QGIS , ArcGIS, GRASS ชวยเพิ่ม ประสิทธิภาพในการทํางาน 31 Mr. Chaipat @Ayutthaya GIS Python & GIS ● Python เปนเหมือนตัวเชื่อมประสาน การทํางานรวมกันระหวางนัก GIS กับ Developer ● มีการเติบโต และขยายของนักพัฒนา ทําใหมี opensource lib รองรับ จํานวนมาก สวนหนึ่งตอยอดจาก opensource gis เดิม รวมถึงการ พัฒนาโมเดลใหมๆในลักษณะ GIS programming stack 32 Mr. Chaipat @Ayutthaya GIS
  • 9. Python & GIS ● ขยายขีดความสามารถในการเขาถึงและวิเคราะหขอมูล spatail data ในระบบงานที่ซับซอน ● งานดาน Data science , ● นําขอมูลเชิงพื้นที่ มาสูกระบวนการพัฒนา AI (Machine Learning , Deep Learning) ● ธุรกิจ / บริการ ที่ตอยอดจากขอมูลเชิงพื้นที่ 33 Mr. Chaipat @Ayutthaya GIS Spatial Data science 34 Spatial Data science ● Data science กระบวนการทางวิทยาศาสตรเพื่อวิเคราะห เจาะ ลึก ทําความเขาใจ เพื่อสกัดนํามูลคาจากขอมูลขนาดใหญ ขอมูล ที่มีโครงสรางซับซอน ● Spatial Data = ขอมูลเชิงปริภูมิ / ขอมูลภูมิสารสนเทศ / ขอมูล เชิงพื้นที่ ● Key คือ ขอมูลที่อางอิงกับตําแหนงบนผิวโลก 35 Mr. Chaipat @Ayutthaya GIS Data science 36 Mr. Chaipat @Ayutthaya GIS
  • 10. Alí Santacruz ,amsantac.co 37 Spatial Data science Spatial Data Science and Applications 38 Spatial Data science 39 Mr. Chaipat @Ayutthaya GIS Data science 40 Mr. Chaipat @Ayutthaya GIS
  • 11. Data science 41 Machine Learning 42 Data science 43 Part II : Development 44
  • 12. Python Geospatial Development Stack 45 Python Geospatial Development Stack Layer Package Name Description URL Spatial Data IO gdal Interface to Geospatial data abstraction library https://pypi.python.org/pypi/GDAL/ (link is external) fiona API to OGR (Vector) layer of GDAL http://toblerity.org/fiona/ (link is external) rasterio Reading and writing geospatial raster data https://github.com/mapbox/rasterio (link is external) 46 Mr. Chaipat @Ayutthaya GIS Python Geospatial Development Stack Layer Package Name Description URL Geoprocessing shapely Deterministic spatial analysis http://toblerity.org/shapely rasterstats Summarizing rasters using vector geometries https://github.com/perrygeo/python-rasterstats geopandas Pandas-like spatial operations on geometric types http://geopandas.org pyproj PROJ4 Interface for cartographic transformations https://github.com/jswhit/pyproj 47 Mr. Chaipat @Ayutthaya GIS Python Geospatial Development Stack Layer Package Name Description URL Geo visualization basemap Plotting 2D data on maps https://github.com/matplotlib/basemap cartopy Cartographic tools http://scitools.org.uk/cartopy folium Visualization via interactive Leaflet maps https://github.com/python-visualization/folium Bokeh (geo) Interactive visualization library browsers https://github.com/bokeh datashader Big data visualization graphics pipeline https://github.com/bokeh/datashader 48 Mr. Chaipat @Ayutthaya GIS
  • 13. Python Geospatial Development Stack Layer Package Name Description URL Spatial Statistical Analysis PySAL Spatial data analysis http://pysal.org pykriging Geostatistics http://pykriging.com/ OSMnx + Networkx network analysis , OpenStreetMap Data Analysis https://osmnx.readthedocs.io/en/stable/ https://networkx.github.io/documentation/ networkx-1.10/overview.html 49 Mr. Chaipat @Ayutthaya GIS Python Geospatial Development Stack Layer Package Name Description URL Web & Data Service OWSlib Client programming interface to OGC web service https://geopython.github.io/OWSLib PyWPS OGC WPS Framework for geospatial data https://pywps.org/ MapProxy Open source proxy for geospatial data. , Tile cache & WMS server https://mapproxy.org/ 50 Mr. Chaipat @Ayutthaya GIS Python Geospatial Installation 51 Installation ● ติดตั้งผาน pip ไดเกือบทั้งหมด ● บาง lib อาจจะตองมีการ compile source code ● 99% รองรับการทํางานกับ Window OS รองรับ Anapip ● รองรับการทํางานบน Linux / Mac 52 Mr. Chaipat @Ayutthaya GIS
  • 14. Installation # Install shapely conda install -c conda-forge shapely # Install geopandas conda install -c conda-forge geopandas # Install cartopy conda install -c conda-forge cartopy # Install networkx conda install networkx # Install osmnx conda install -c conda-forge osmnx # Install statsmodels conda install statsmodels # Install folium conda install -c conda-forge folium # Install bokeh conda install bokeh # Install shapely pip install shapely # Install geopandas pip install geopandas # Install cartopy pip install cartopy # Install networkx pip install networkx # Install osmnx pip install osmnx # Install statsmodels pip install statsmodels # Install folium pip install folium # Install bokeh pip install bokeh 53 Installation - สามารถ import ตัว lib ไดแบบไมมี error - หรือ สามารถรัน print() ดูรายละเอียดของการติดตั้งและ package ได แปล วาพรอมจะทํางาน import geopandas import scipy import shapely import matplotlib.pyplot as plt import pysal import bokeh import cartopy import statsmodels 54 Mr. Chaipat @Ayutthaya GIS Google Colaboratory 55 Google Colaboratory - free Jupyter notebook environment - Support Python 2 , 3 - Linux OS - execute code, save and share code & result - access powerful computing resources {CPU/GPU/TPU} - Data storage : Google Drive 56 Mr. Chaipat @Ayutthaya GIS
  • 15. Google Colaboratory 57 Mr. Chaipat @Ayutthaya GIS Google Colaboratory https://colab.research.google.com/notebooks/basic_features_overview.ipynb https://colab.research.google.com 58 Google Colaboratory 59 Mr. Chaipat @Ayutthaya GIS Google Colaboratory 60 Mr. Chaipat @Ayutthaya GIS
  • 16. Google Colaboratory 61 Ayutthaya GIS Consultant Co., Ltd. Google Drive from google.colab import drive drive.mount('/content/gdrive/') data_dir = os.path.join('/content/gdrive', 'My Drive','colab_notebooks') os.listdir(data_dir) 62 Mr. Chaipat @Ayutthaya GIS Spatial Data Model 63 Spatial Data Model ● การสรางแบบจําลองขอมูลเชิงพื้นที่ในระบบสารสนเทศ ● Spatial Data Model a. Vector Data model b. Raster Data Model 64 Mr. Chaipat @Ayutthaya GIS
  • 17. Spatial Data Model 65 Mr. Chaipat @Ayutthaya GIS Spatial Data Model ● Vector Data Model คือ geometric objects รหัสเชิงเลข ที่ใชนิยาม ตัวแทนวัตถุในระบบคอมพิวเตอร ● Geometry Object โดยมีการระบุพิกัดตําแหนงอางอิง และ index เชื่อม โยงกับขอมูลบรรยายที่เกี่ยวของ ● สามารถแบง Geometry Object พื้นฐาน ไดแก Point , Line และ Polygon ● ยังสามารถแยกยอยตามระนาบทั้ง 2D และ 3D 66 Mr. Chaipat @Ayutthaya GIS Spatial Data Model 67 Spatial Data Model & GeoPandas ● Python มี module ในการจัดการขอมูล geometry หลายตัว ใน workshop นี้จะเรียนรูจักการจัดการดวย Geopandas ● GeoPandas เปน open source package สรางเพื่อการทํางานกับ ขอมูล geospatial ลักษณะของการผูกรวม ● โดยการประมวลผลดาน data model เบื้องหลังมี shapely ( GEOS C++ library) ดําเนินการ ● 68 Mr. Chaipat @Ayutthaya GIS
  • 18. Spatial Data Model & GeoPandas 69 Mr. Chaipat @Ayutthaya GIS Point ● “จุด” ตัวแทน ประกอบดวยตัวเลขพิกัด 2 มิติ หรือ 3 มิต ิบน space ● ทดลองทําการสราง point จากกลุมขอมูลพิกัด 2 มิติโดยใชคลาส Geoseries ● จากนั้นทําการสราง geometry object สําหรับ Geodataframe บน pandas โดยทําการระบุระบบพิกัดอางอิง(CRS) เปน EPSG:4326 70 Mr. Chaipat @Ayutthaya GIS Point 71 Mr. Chaipat @Ayutthaya GIS Point 72 Mr. Chaipat @Ayutthaya GIS
  • 19. Line ● “เสน” ตัวแทนประกอบดวย set ของจุดเชื่อมตอกัน ● ทําการสราง Linestring object จากกลุมขอมูลของ point แบบ 2 มิติ ซึ่ง point จะเปนตัวแทนของ node ที่อยูบน Line ที่สรางขึ้น 73 Mr. Chaipat @Ayutthaya GIS Line 74 Mr. Chaipat @Ayutthaya GIS Line 75 Polygon ● พื้นที่รูปปด ตัวแทนของรูปทรงปด ที่ประกอบดวย จุดอางอิง ตัวแทน ตําแหนง node และ edge ที่แนนอน ● ตัวอยาง ทําการสราง Polygon object จากกลุมขอมูลของ Point 2 มิติ ที่เปนตัวแทนของ node ของ polygon ● จากนั้นใช geoseries ในการสราง geometry object ประเภท polygon ขึ้นมาโดยจะไดรูปปด ที่มีทั้ง node และ edge สุดทายสามารถ นําไปใชคํานวณคุณสมบัติประกอบอื่นๆไดตอไป 76 Mr. Chaipat @Ayutthaya GIS
  • 20. Polygon 77 Mr. Chaipat @Ayutthaya GIS Polygon 78 Mr. Chaipat @Ayutthaya GIS Polygon ● พื้นที่รูปปดจะมีคุณสมบัติ เชน พื้นที่, เสนรอบรูป และจุดกึ่งกลาง ● ตัวอยาง ทําการคํานวณคุณสมบัติเรขาคณิตของ polygon พื้นฐาน ไดแก Area, BBOX , Centroid 79 Mr. Chaipat @Ayutthaya GIS Polygon 80 Mr. Chaipat @Ayutthaya GIS
  • 21. Spatial Data Management 81 Spatial Data Management ● GeoPandas อาน/เขียน และจัดการไฟล GIS format ผาน Fiona (OGR + Proj4) ● Plot หรือแสดงผล geometry ดวย descartes(เดการต) (matplotlib) ● Pandas จัดการขอมูล attribute data , table และ sql query ● GeoDataframe 82 Mr. Chaipat @Ayutthaya GIS Spatial Data format ● GeoPandas รองรับการทํางานกับ GIS Vector File เกือบทุกประเภท เชนเดียวกับ OGR ● รองรับประเภทหลักเชน Shapefile, GeoJSON, KML และ GPKG 83 Mr. Chaipat @Ayutthaya GIS Spatial Data Management ● ทําการเปดและอานไฟล province.shp จากโฟเดอร data ● ทดสอบผลการอานไฟลดวยการ แสดงขอมูลบน table ● แสดงขอมูล Geometry object แบบ WKT (polygon) พรอมขอมูลจาก database(.dbf) ● Plot แผนที่จาก ขอมูล geometry พรอมระบบพิกัด 84 Mr. Chaipat @Ayutthaya GIS
  • 22. Spatial Data Management 85 Spatial Reference System 86 Spatial Reference System(SRS) ● Aka coordinate reference system (CRS) ● การนิยามระบบพิกัดอางอิงของ Geometry model ในระบบที่ใชเปน ตัวแทนวัตถุบนพื้นโลก ● Map Projection = โมเดลการฉายผิวโลกทรงโคง 3D ใหกลายเปน แผนที่(Map) 2 มิติ 87 Mr. Chaipat @Ayutthaya GIS Spatial Reference System(SRS) ● ระบบพิกัดอางอิง (coordinate system) ของขอมูลเชิงพื้นที่ ● การระบุพิกัดตําแหนงอางอิงบนแผนที่ >Geographic coordinate system (latitude, longitude) >Universal Transverse Mercator (UTM) 88 Mr. Chaipat @Ayutthaya GIS
  • 23. Geographic coordinate system ● การระบุพิกัดตําแหนงอางอิงบนแผนที่แบบ latitude, longitude 89 Mr. Chaipat @Ayutthaya GIS Geographic coordinate system 90 Mr. Chaipat @Ayutthaya GIS Universal Transverse Mercator (UTM) ● การระบุพิกัดตําแหนงอางอิงบนแผนที่แบบ GRID ● เมืองไทยมีพิกัดตกบนกริด UTM โซน 47 และ 48 มีรหัสเลขชวง N, P และ Q ● ตัวอยาง 47P356482 91 Mr. Chaipat @Ayutthaya GIS พื้นหลักฐานอางอิง (Datum) ● ระบบหลักฐานที่ใชอางอิงในการกําหนดคาทางแนวดิ่งและแนวราบ ● เพื่อใชเปนจุดบังคับทางความสูงและควบคุมตําแหนงบนแผนที่ สําหรับอางอิงใน การหาตําแหนงบนพื้นผิวโลก ● Horizontal Datum > Local Datum : ไทยใช Indian Datum 1975 > Global Datum WGS 84 (World Geodetic System 1984)แ ● Vertical Datum :ไทยใช คาอางอิงจากระดับนํ้าทะเลปานกลาง ณ เกาะหลัก จังหวัดประจวบ 92 Mr. Chaipat @Ayutthaya GIS
  • 24. Universal Transverse Mercator (UTM) ● การระบุพิกัดตําแหนงอางอิงบนแผนที่แบบ GRID ● เมืองไทยมีพิกัด SRS ประเภท UTM ที่พบไดแก ● EPSG 32647 , ● EPSG 24047 ● EPSG 32648, ● EPSG 24048 93 Mr. Chaipat @Ayutthaya GIS EPSG:32647 WGS 84 / UTM zone 47N 94 EPSG:24047 Indian 1975 / UTM zone 47N 95 EPSG:32648 WGS 84 / UTM zone 48N 96
  • 25. EPSG:900913 Google Maps Global Mercator 97 Geocode 98 Geocode ● การแปลงจากชื่อ ที่อยู (address) ใหกลายเปน ระบบพิกัดบนโลก ● รวมถึงขอมูล IP address ● โดยมีบริการ(service) ในการแปลง ทําหนาที่คนหาที่อยูจากฐานขอมูล sptial database แลวคํานวณพิกัดตําแหนง สงกลับมายังปลายทาง ● เชน Google Geocoding API , OSM Map API, Bing เปนตน ● Python modules ไดแก Geopy, Geocoder , Geopandas 99 Mr. Chaipat @Ayutthaya GIS OGC Web Feature Service 100
  • 26. WFS - Open Geospatial Consortium (OGC) - Web feature service โปรโตคอลมาตรฐานของ OGC พัฒนาขึ้นเพื่อ บริการขอมูล spatial data - เชื่อมโยงการทํางานระหวางระบบ GIS แบบ interoperability ในการ เขาถึงขอมูลผาน webservice - ขาม platform ,ขาม software , ขาม data format - อางอิงเพิ่มเติม https://www.opengeospatial.org/standards/wfs 101 Mr. Chaipat @Ayutthaya GIS WFS 102 Mr. Chaipat @Ayutthaya GIS WFS 103 Mr. Chaipat @Ayutthaya GIS WFS 104 Mr. Chaipat @Ayutthaya GIS
  • 27. WFS - โปรโตคอลการทํางานเบื้องตนของ OGC WFS - ประกอบดวย 3 Operation หลักคือ 1.GetCapabilities 2.DescribeFeatureType 3.GetFeature 105 Mr. Chaipat @Ayutthaya GIS WFS - GetCapabilities - Operation เพื่อสงคํารองสืบคาไปยัง WFS server เพื่อตรวจสอบ สถานะและขอมูลที่ใหบริการ - http://localhost/geoserver/ows?service=WFS &version=1.0.0&request=GetCapabilities 106 Mr. Chaipat @Ayutthaya GIS WFS - GetCapabilities 107 WFS - DescribeFeatureType - Operation เพื่อสงคํารองสืบคาไปยัง WFS server เพื่อเขาถึงขอมูล รายละเอียดและคําอธิบายของขอมูลแตละ layer - http://localhost/geoserver/ows?service=WFS &version=1.0.0 &request=DescribeFeatureType &typename=geosolutions:Counties 108 Mr. Chaipat @Ayutthaya GIS
  • 28. WFS - DescribeFeatureType 109 WFS - GetFeature - Operation เพื่อสงคํารองสืบคาไปยัง WFS server เพื่อเขาถึงขอมูล Spatial data ที่ตองการ โดยการสืบคน ตองระบุพารามิเตอร สําคัญ เชน ชื่อชั้นขอมูล และสามารถกําหนด parameter เพิ่มเติมในการกรองเชน bbox, - ผลลัพธ ปกติจะเปน GML3 แตมีทางเลือกอื่นๆขึ้นกับ server เชน geojson , wkb เปนตน 110 Mr. Chaipat @Ayutthaya GIS WFS - GetFeature - Operation - http://localhost/geoserver/ows?service=WFS - &version=1.0.0 - &request=GetFeature - &typeName=geosolutions:Counties - &maxFeatures=50 - &outputFormat=GML3 111 Mr. Chaipat @Ayutthaya GIS WFS - GetFeature 112 Mr. Chaipat @Ayutthaya GIS
  • 29. WFS - Server WFS in thailand (gov) http://fgds-backend.ngis.go.th/geoserver/geonode/ows? http://gservices.gistda.or.th/geoserver/wfs http://mapservices.energy.go.th:80/geoserver/ows? 113 Spatial Data Analysis 114 Spatial Data Analysis ● การวิเคราหขอมูลเชิงพื้นที่ ประกอบดวย 1. Geoprocessing คือ การประมวลผล เพื่อสรางขอมูล geometry ใหมจากขอมูล geometry ตั้งตน และสวนการประมวลผล ระหวาง geometry เพื่อสรางผลลัพธใหม > function การแปลง geometry data และสรางผลลัพธขอมูล attribute ใหม > Buffer , Merge , Difference, Intersection, Union เปนตน > ศึกษาเพิ่มเติมจาก http://geopandas.org/reference.html ● 2. Spatial Relation คือความสัมพันธระหวาง geometry ตัวบงบอกคุณลักษณะ และคุณสมบัติขอมูล สําหรับการ วิเคราะห 115 Spatial Data Analysis - การวิเคราะหขอมูลเชิงพื้นที่ ยังรวมไปถึงการวิเคราะหเชิงลึกอื่นๆ - เชน Spatial temporal analysis, Terrain analysis, Surface Analysis: Spatial Interpolation หรือ spatial statistic analysis เปนตน 116 Mr. Chaipat @Ayutthaya GIS
  • 30. Geoprocessing saylordotorg.github.io 117 Spatial Query 118 Spatial Query ● กระบวนการสืบคนขอมูลเชิงตําแหนง ที่ใชเงื่อนไขเชิงตําแหนงในการวิเคราะห ขอมูลเพื่อใหไดผลลัพธตามตองการ ● นํา geometry data มารวมในการสรางเงื่อนไขเพื่อทําการวิเคราะห หรือสืบคน หาขอมูล จากฐานขอมูล ● คนหาดวยเงื่อนไข จาก spatial relation function ไดแก ● contains(), crosses(), .intersects(),overlaps(),touches(), disjoint(), within() 119 Mr. Chaipat @Ayutthaya GIS Spatial relation 120 Mr. Chaipat @Ayutthaya GIS
  • 31. Spatial Query 121 Mr. Chaipat @Ayutthaya GIS Thematic map 122 Thematic map ● การสรางแผนที่เฉพาะเรื่อง จากการกําหนดเงื่อนไข ในฐานขอมูล GIS ● นําผลลัพธจากการวิเคราะหขอมูล มาสรางเปนแผนที่เฉพาะทาง ● อธิบายเลาเรื่อง โดยกําหนด ลักษณะการแสดงผล สี สัญลักษณ ตามคา(value) ● จากเงื่อนไขบน logical operation และ spatial operation 123 Mr. Chaipat @Ayutthaya GIS Thematic map 124 Mr. Chaipat @Ayutthaya GIS
  • 32. Thematic map 125 Web Mapping Application ● การพัฒนาระบบบริการขอมูล GIS แบบออนไลน ผานอินเตอรเน็ต ● รองรับการแสดงผล และการสืบคนขอมูล ● Python มีหลา่ยโมดูลที่สามารถเลือกใชงานได ● ตัวอยางใช Geopandas + Bokeh ● นอกจากนี้ มีการเชื่อมโยงและผสานการแสดงผลขอมูลกับ Map service ทั้ง WMS, WMST 126 Mr. Chaipat @Ayutthaya GIS Web Mapping Application 127 Mr. Chaipat @Ayutthaya GIS Question ??? 128