_______สำหรับผู้ที่สนใจในงานด้าน Internet GIS หลายคนคงเคยคิดว่าจะทำอย่างไรดี จะให้ข้อมูลที่เป็น basemap อย่างเช่น ข้อมูลภาพดาวเทียม ภาพถ่ายทางอากาศ ทั่วทั้งพื้นที่ที่เราต้องการ เพราะว่าไฟล์ขนาดใหญ่มากจึงทำให้มีปัญหาในการต่อภาพ (mosaic) ดังนั้นผมจึงแนะนำอีกวิธีหนึ่งที่ง่ายในการทำโดยใช้ "Image mosaicking plugin" ของ GeoServer โดยการทำดังต่อไปนี้
1. เตรียมข้อมูลภาพที่ต้องการจะแสดงผล และจะเปิดข้อมูลนั้นด้วย QGIS :)
2. Copy Data ไปยัง dir ของ Geoserver
3. ทำการสร้าง Layers >> โดยใช้ ImageMosaic
4. ทำการ Publish
5. Click Layer Preview
Download Data Example : Click
Reference:http://docs.geoserver.org/latest/en/user/tutorials/image_mosaic_plugin/imagemosaic.html
วันพุธที่ 19 ตุลาคม พ.ศ. 2559
วันอังคารที่ 18 ตุลาคม พ.ศ. 2559
วิธีเรียก Service จาก ArcGIS Server โดยใช้โปรแกรม QGIS
_______หลายๆ คนเคยอยากที่จะต้องการเรียก service จาก arcgis server หรือ arcgis onine บนโปรแกรม QGIS ซึ่งเราก็สามารถทำได้ 2 วิธีโดยใช้ Python Console และอีกแบบก็จะใช้ GDAL/OGR ครับ
วิธีที่ 1 Python Console
1. In the QGIS Python console ไปที่ Plugins >> Python console
2. จากนั้นก็พิมพ์ qgis.utils.iface.addRasterLayer("http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer?f=json&pretty=true","esriLayer")
วิธีที่ 2 GDAL/OGR (gdal_translate)
1.ก็พิมพ์ลงใน terminal => gdal_translate "http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer?f=json&pretty=true" esriStreetLayer.xml -of WMS
2.จากนั้นจะได้ xml มาก็ให้ลากใส่ใน QGIS ได้เลยครับ
Reference : http://hub.qgis.org/wiki/quantum-gis/Arcgis_rest
วิธีที่ 1 Python Console
1. In the QGIS Python console ไปที่ Plugins >> Python console
2. จากนั้นก็พิมพ์ qgis.utils.iface.addRasterLayer("http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer?f=json&pretty=true","esriLayer")
วิธีที่ 2 GDAL/OGR (gdal_translate)
1.ก็พิมพ์ลงใน terminal => gdal_translate "http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer?f=json&pretty=true" esriStreetLayer.xml -of WMS
2.จากนั้นจะได้ xml มาก็ให้ลากใส่ใน QGIS ได้เลยครับ
Reference : http://hub.qgis.org/wiki/quantum-gis/Arcgis_rest
ป้ายกำกับ:
ArcGIS Online
,
ArcGIS rest
,
ArcGIS Server
,
Mapserver
,
Open Source GIS
,
plugin qgis
,
QGIS
,
Web Map Service
วันศุกร์ที่ 14 ตุลาคม พ.ศ. 2559
การแสดงข้อมูลแผนที่จาก PostGIS เป็น GeoJSON บน Leaflet
_______การแสดงข้อมูลแผนที่บน Leaflet นั้น ข้อมูลส่วนใหญ่จะอยู่ในรูปแบบ GeoJSON แต่ทีนี้ข้อมูลของผมเองนี้ดันอยู่ในรูปแบบของ Database ที่เป็นแบบ PostGIS ซึ่งข้อมูลจะเป็นลักษณะของตารางและเก็บค่า Geometry ไว้ อ้าวแล้วยังงี้จะต้องทำอย่างไรถึงจะแสดงบน Leaflet ได้หล่ะ ไม่ยากเลยครับเราเพียงแค่ใช้ PHP แปลงข้อมูลของเราให้อยู่ในรูปแบบ GeoJSON เท่านั้นเอง สามารถเข้าไปดูได้ที่ GitHub ของผมเองได้ครับ ไปดูกันเลยว่าทำอย่างไร
ตัวอย่างจาก GitHub ดัง URL ด้านล่าง
https://gist.github.com/sanchangon/24058c407ab051dc5f72fa5fdbadc0ac
1. ไฟล์ healthcenter.html ที่ใช้แสดงแผนที่
<html>
<!--
* Name: Leafletjs connect php-geojson through postgis spatial database
* Purpose: GIST@NU (www.cgistln.nu.ac.th)
* Date: 2016/10/13
* Author: Chingchai Humhong (chingchaih@nu.ac.th)
* Acknowledgement:
!-->
<head>
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.7.3/leaflet.css"/>
<script src="http://cdn.leafletjs.com/leaflet-0.7.3/leaflet.js"></script>
<script src="http://code.jquery.com/jquery-1.11.3.min.js"></script>
</head>
<body>
<div id="map" style="width: 100%; height: 800px;"></div>
<script type="text/javascript">
var map = L.map('map');
var OpenStreetMap_BlackAndWhite = L.tileLayer('http://{s}.tiles.wmflabs.org/bw-mapnik/{z}/{x}/{y}.png', {
maxZoom: 18,
attribution: '© <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>'
});
OpenStreetMap_BlackAndWhite.addTo(map);
map.setView([17.05, 100.25], 9);
function addDataToMap(data, map) {
var dataLayer = L.geoJson(data, {
onEachFeature: function(feature, layer) {
var popupText = "hospital name: " + feature.properties.name
+ "<br>hospital code: " + feature.properties.maincode;
//+ "<br><a href='" + feature.properties.url + "'>More info</a>";
layer.bindPopup(popupText); }
});
dataLayer.addTo(map);
}
$.getJSON("healthcenter.php", function(data) { addDataToMap(data,map); });
</script>
</body>
</html>
2. ไฟล์ healthcenter.php ที่ใช้ในการแปลงเป็น GeoJSON
<?php
//-------------------------------------------------------------
// * Name: PHP-PostGIS2GeoJSON
// * Purpose: GIST@NU (www.cgistln.nu.ac.th)
// * Date: 2016/10/13
// * Author: Chingchai Humhong (chingchaih@nu.ac.th)
// * Acknowledgement:
//-------------------------------------------------------------
// Database connection settings
define("PG_DB" , "database");
define("PG_HOST", "localhost");
define("PG_USER", "postgres");
define("PG_PORT", "port");
define("PG_PASS", "password");
define("TABLE", "table");
// Retrieve start point
// Connect to database
$con = pg_connect("dbname=".PG_DB." host=".PG_HOST." port=".PG_PORT." password=".PG_PASS." user=".PG_USER);
$sql = "select gid, provcode, maincode, bed, name, lat, lon, typecode, ST_AsGeoJSON(geom) AS geojson from ".TABLE." WHERE provcode = 65; ";
// Perform database query
$query = pg_query($con,$sql);
//echo $sql;
// Return route as GeoJSON
$geojson = array(
'type' => 'FeatureCollection',
'features' => array()
);
// Add geom to GeoJSON array
while($edge=pg_fetch_assoc($query)) {
$feature = array(
'type' => 'Feature',
'geometry' => json_decode($edge['geojson'], true),
'crs' => array(
'type' => 'EPSG',
'properties' => array('code' => '4326')
),
'properties' => array(
'gid' => $edge['gid'],
'provcode' => $edge['provcode'],
'maincode' => $edge['maincode'],
'bed' => $edge['bed'],
'name' => $edge['name'],
'lat' => $edge['lat'],
'lon' => $edge['lon'],
'typecode' => $edge['typecode']
)
);
// Add feature array to feature collection array
array_push($geojson['features'], $feature);
}
// Close database connection
pg_close($con);
// Return routing result
// header('Content-type: application/json',true);
echo json_encode($geojson);
?>
เขียนโดย: ชิงชัย หุมห้อง (14 ตุลาคม 2559)
Reference: https://github.com/sanchangon/leaflet-phpgeojson
ตัวอย่างจาก GitHub ดัง URL ด้านล่าง
https://gist.github.com/sanchangon/24058c407ab051dc5f72fa5fdbadc0ac
1. ไฟล์ healthcenter.html ที่ใช้แสดงแผนที่
<html>
<!--
* Name: Leafletjs connect php-geojson through postgis spatial database
* Purpose: GIST@NU (www.cgistln.nu.ac.th)
* Date: 2016/10/13
* Author: Chingchai Humhong (chingchaih@nu.ac.th)
* Acknowledgement:
!-->
<head>
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.7.3/leaflet.css"/>
<script src="http://cdn.leafletjs.com/leaflet-0.7.3/leaflet.js"></script>
<script src="http://code.jquery.com/jquery-1.11.3.min.js"></script>
</head>
<body>
<div id="map" style="width: 100%; height: 800px;"></div>
<script type="text/javascript">
var map = L.map('map');
var OpenStreetMap_BlackAndWhite = L.tileLayer('http://{s}.tiles.wmflabs.org/bw-mapnik/{z}/{x}/{y}.png', {
maxZoom: 18,
attribution: '© <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>'
});
OpenStreetMap_BlackAndWhite.addTo(map);
map.setView([17.05, 100.25], 9);
function addDataToMap(data, map) {
var dataLayer = L.geoJson(data, {
onEachFeature: function(feature, layer) {
var popupText = "hospital name: " + feature.properties.name
+ "<br>hospital code: " + feature.properties.maincode;
//+ "<br><a href='" + feature.properties.url + "'>More info</a>";
layer.bindPopup(popupText); }
});
dataLayer.addTo(map);
}
$.getJSON("healthcenter.php", function(data) { addDataToMap(data,map); });
</script>
</body>
</html>
2. ไฟล์ healthcenter.php ที่ใช้ในการแปลงเป็น GeoJSON
<?php
//-------------------------------------------------------------
// * Name: PHP-PostGIS2GeoJSON
// * Purpose: GIST@NU (www.cgistln.nu.ac.th)
// * Date: 2016/10/13
// * Author: Chingchai Humhong (chingchaih@nu.ac.th)
// * Acknowledgement:
//-------------------------------------------------------------
// Database connection settings
define("PG_DB" , "database");
define("PG_HOST", "localhost");
define("PG_USER", "postgres");
define("PG_PORT", "port");
define("PG_PASS", "password");
define("TABLE", "table");
// Retrieve start point
// Connect to database
$con = pg_connect("dbname=".PG_DB." host=".PG_HOST." port=".PG_PORT." password=".PG_PASS." user=".PG_USER);
$sql = "select gid, provcode, maincode, bed, name, lat, lon, typecode, ST_AsGeoJSON(geom) AS geojson from ".TABLE." WHERE provcode = 65; ";
// Perform database query
$query = pg_query($con,$sql);
//echo $sql;
// Return route as GeoJSON
$geojson = array(
'type' => 'FeatureCollection',
'features' => array()
);
// Add geom to GeoJSON array
while($edge=pg_fetch_assoc($query)) {
$feature = array(
'type' => 'Feature',
'geometry' => json_decode($edge['geojson'], true),
'crs' => array(
'type' => 'EPSG',
'properties' => array('code' => '4326')
),
'properties' => array(
'gid' => $edge['gid'],
'provcode' => $edge['provcode'],
'maincode' => $edge['maincode'],
'bed' => $edge['bed'],
'name' => $edge['name'],
'lat' => $edge['lat'],
'lon' => $edge['lon'],
'typecode' => $edge['typecode']
)
);
// Add feature array to feature collection array
array_push($geojson['features'], $feature);
}
// Close database connection
pg_close($con);
// Return routing result
// header('Content-type: application/json',true);
echo json_encode($geojson);
?>
เขียนโดย: ชิงชัย หุมห้อง (14 ตุลาคม 2559)
Reference: https://github.com/sanchangon/leaflet-phpgeojson
ซอฟต์แวร์รหัสเปิด (Open Source Software)
ซอฟต์แวร์รหัสเปิด (Open Source Software) เป็นซอฟต์แวร์ที่มีการเปิดเผยวิธีการทำงานให้ผู้อื่น (นอกเหนือจากผู้พัฒนาซอฟต์แวร์) ได้รับทราบ ทำให้ผู้ใช้งานสามารถเรียนรู้วิธีการทำงานของซอฟต์แวร์ และปรับปรุงแก้ไขได้ด้วยต้นเอง รวมถึงการเผยแพร่ซอร์ซโค้ดได้อย่างสะดวก ภายใต้ข้อตกลงกฎหมายหรือสัญญา ซอฟต์แวร์รหัสเปิดมีการพัฒนาตั้งแต่โปรแกรมอำนวยความสะดวกขนาดเล็กไปจนถึงระบบปฏิบัติการที่มีประสิทธิภาพสูง หลายโปรแกรมได้รับการพัฒนาจนมีคุณภาพสูงทั้งในด้านของประสิทธิภาพ และความน่าเชื่อถือจนได้รับความนิยมอย่างสูง และมีการนำไปประยุกต์ใช้งาน อย่างข้อดีที่สำคัญของซอฟต์แวร์รหัสเปิด คือ ความสามารถที่จะนำซอฟต์แวร์ไปใช้งาน การศึกษา แก้ไข และเผยแพร่ได้อย่างเสรี ทำให้คำว่า ซอฟต์แวร์รหัสเปิด ซอฟต์แวร์โอเพนซอร์ซ (การเขียนแบบทับศัพท์เป็นคำไทย) และซอฟต์แวร์เสรี นั้นมีความหมายในทางเดียวกันหรือสามารถใช้แทนกันได้ จากภาพที่ 6 ซึ่งผู้วิจัยได้ให้คำจำกัดความของซอฟต์แวร์เสรี (Freedom of Software) อยู่ 4 คำดังนี้
1. มีความเสรีในการใช้งาน (Freedom of use)
2. มีความเสรีในการแจกจ่าย (Freedom of redistribute)
3. มีความเสรีในการคัดลอก (Freedom of copy)
4. มีความเสรีในการดัดแปลง (Freedom of modify)
1. มีความเสรีในการใช้งาน (Freedom of use)
2. มีความเสรีในการแจกจ่าย (Freedom of redistribute)
3. มีความเสรีในการคัดลอก (Freedom of copy)
4. มีความเสรีในการดัดแปลง (Freedom of modify)
คำจำกัดความของซอฟต์แวร์เสรี (OSS)
(ดัดแปลงจาก Sanghee Shin, 2015)
เขียนโดย: ชิงชัย หุมห้อง (14 ตุลาคม 2559)
วันอังคารที่ 11 ตุลาคม พ.ศ. 2559
GRASS GIS: โปรแกรมที่รู้จักกันมากที่สุดของฟรีแวร์ทางด้านระบบสารสนเทศภูมิศาสตร์ (GIS)
ภาพตัวอย่าง
เขียนโดย: ชิงชัย หุมห้อง (11 ตุลาคม 2559)
Reference: https://grass.osgeo.org
สมัครสมาชิก:
บทความ
(
Atom
)
