เปลี่ยน Google Drive เป็น Web Hosting

ครั้งนี้จะมาแนะนำการทำ Google Drive ให้เป็น Web Hosting เพืื่ือทดลอง ทำ web แบบง่าย

ก่อนอื่นต้องบอกว่าผมค่อนข้างใหม่มากๆ กับการเขียน website ก็กำลังพยายามเรียนรู้ตั้งแต่เริ่มต้น

มาถึงก็เจอยุคของ HTML 5 และ CSS3 แล้วแต่ผมไม่สับสนระหว่าง HTML 4 กับ HTML 5 หรอก เพราะ HTML 4 ผมไม่รู้เรื่องเลย 555

วิธีการก็คือ อันดับแรก ต้องมี Google Account  ใครไม่มีก็ไปสมัครซะ

file ที่รองรับ html, file ภาพ , CSS, javascript, หรือ client-side script นั่นแสดงว่าเราจะ public website ที่เป็นแบบ static ได้เท่านั้น

อันดับแรกก็เขียน html  CSS และ ภาพที่ใช้ Upload ไปไว้บน Google drive

2

อาจจะตั้งชื่อ Folder ว่า Public ก็ได้ แล้วทำให้ folder นี้ share โดย Click ขวา

3

เลือก share หรือแบ่งปัน เปลี่ยน สถานะเป็น สถานะทางเว๊บ (ภาษาอังกฤษ ไม่รู้ว่าใช้คำว่าอะไร ไปหาเอาเองนะครับ) เสร็จแล้วบันทึกซะ

4

เท่านี้ก็เรียบร้อยแล้วครับ

แล้ววิธีการเปิดดู Website ที่เราสร้างละทำยังไง

ให้เราใช้ link     https://googledrive.com/host/ นำหน้าตัวอักษรตัวเลขแปลกๆ มากมาย เช่น

https://googledrive.com/host/0B89NXH7oJmVVUW9Ld0pzS1E1SWc

“0B89NXH7oJmVVUW9Ld0pzS1E1SWc” เอามากจากไหน คือตอนที่เราเลือกคลิ๊กขวา share ทีj file html จะเห็น link ที่จะแบ่งปันตามรูป

5

ตรง link ที่จะแบ่งปันจะมี ตัวเลขตัวอักษรอยู่ เอา ตัวเลขหรือตัวอักษมาต่อท้าย https://googledrive.com/host/ซะ

ถ้าใคร upload ชื่อ file html เป็นชื่อ index.html แล้ว ถ้าเรียกจะแสดงผลเป็นหน้า website ได้เลย แต่ถ้าไม่ได้ตั้งชื่อ index.html

ก็ต้องระบุชื่อ file ด้วย เช่น https://googledrive.com/host/0B89NXH7oJmVVUW9Ld0pzS1E1SWc/test.html เป็นต้น

ส่วนการ link file html กับ CSS ใน html ถ้าใครเขียน CSS แบบ external จะมีบรรทัดนี้อยู่

<link href= ” https://googledrive.com/host/0B89NXH7oJmVVTEV2MDFqSUw0QTQ ” rel=”stylesheet” type=”text/css”>

ตรง href =”XXX” ให้ใส่ link ของ CSS เช่นเดียวกับตอนที่ดู link html

link ภาพก็เช่นเดียวกัน ให้ใช้ https://googledrive.com/host/ นำหน้า

เสร็จเรียบร้อยแล้ว อันนี้ Website ที่ผมทดลองทำ

https://googledrive.com/host/0B89NXH7oJmVVUW9Ld0pzS1E1SWc

ลองทำดูครับ ไม่ยาก ผมพึ่งเริ่มต้น ยังทำได้เลย

*** เคล็ดลับ***

1. เวลา upload file ถ้า website ใครมีภาพ ให้ upload ขึ้นไปก่อน แล้วเอา link มาใส่่ใน html หรือ css

2. เขียน css แบบ internal style sheet และ แบบ inline style สะดวกกว่า หาก website ไม่ใหญ่

อ้างอิง https://googledrive.com/host/A1B2C3D4E5F6G7H8J9 

Google Fusion Tables-Part II

ในตอนแรกเราได้เรียนรู้เกี่ยวกับการทำ import ข้อมูล excel ที่เป็นข้อมูล point เข้าไปใน Google Fusion Tables

และแสดงผลข้อมูล Point บนแผนที่ และ Share ให้ทุกคนได้ดูเรียบร้อยแล้ว

Part 2 นี้จะเป็นการนำเข้าข้อมูลที่เป็น Polygon ขั้นตอนแรก คือ ต้องเตรียม file ข้อมูลที่เป็นแบบ Polygon นามสกุล kml

ผมทดลองใช้ file จาก http://flood.gistda.or.th ซึ่งเป็น Website ที่ให้บริการข้อมูลเกี่ยวกับน้ำท่วมของประเทศไทย จัดทำโดย GISTDA

ขั้นตอนแรก Log in เข้า Google Account เลือกที่ Drive เลือก Create > Fution Tables เลือก Import ข้อมูล ให้เลือกข้อมูลที่เป็นนามสกุล kml เลือก file แล้ว Open  > Next ต่อไป

12

 

 

 

สามารถใส่รายละเอียดต่างๆ ได้ หรือ ข้ามไปก่อนค่อยไปใส่ตอนหลังก็ได้ ใส่ข้อมูลเรียบร้อยแล้ว > Finish

 

2.5

 

 

เมื่อ Import ข้อมูลเข้ามาเรียบร้อยแล้ว ลอง เลือกที่ Tab Map of Geometry ดูจะเห็นข้อมูล Polygon

3

 

ทดลองเปลี่ยนสี ฺBorder, Background ได้ โดยไปที่ Chang Map Style

5

 

สามารถใส่สี แบบ Gradient ได้ แต่ต้องมี ข้อมูลใน field ที่เป็นจำนวน

6

 

เสร็จเรียบร้อยก็ Click Share ให้คนอื่นได้เข้ามาดู

7

 

เป็นอย่างไรบ้าง คงจะไม่ยากเกินไป สามารถนำไปประยุกต์ใช้กันได้นะครับ

 

AR (Augmented Reality)

นั่งนึกถึง Video นึง ของ Google ที่ให้ดูพิกัดสนามบอลแต่ไม่ใช่สนามบอลแบบรูปถ่ายแต่เป็น Video ที่ Drape ซ้อนอยู่บนภาพ Google map

ทำให้คิดถึงกล้อง CCTV ของ กทม.และ โครงการเครือข่ายตาจราจร (http://hermes.traffy.in.th/i/) ว่าน่าจะเอามาภาพเหล่านั้นมา Drape ลงบน Google map  ได้ ซึ่งจะทำให้ทราบได้ว่าขอบเขตของกล้องที่ถ่ายภาพได้แต่ละตัวมีพื้นที่ แค่ไหน ครอบคลุมพื้นที่ไหน พื้นที่ไหนขาดกล้องพื้นที่ไหนมีกล้องเยอะ ทางภาครัฐจะได้หามาเสริม อันนี้เป็นเรื่องทฤษฎีที่คิดว่าน่าจะทำได้ (ผมฝีมือยังไม่ถึง ใครทำได้ช่วยบอกด้วย)  search google ไปเรื่อยๆ ก็มาเจอเรื่อง AR ตอนแรกก็งงๆ ว่าคืออะไร ลองอ่านดูสัก 2-3 Website ก็พอจะจับได้ว่า เทคโนโลยี AR คืออะไร เราคงเห็นมันมาประมาณ 4-5 ปี แล้วแต่ตอนนั้นยังไม่รู้ว่าคืออะไร อย่างเช่นพวก เกมส์ ใน Wii เป็นต้น มาดูคำแปล AR กัน

A: Augmented แปลว่า เพิ่มเติม แต่งเติม

R: Reality แปลว่า สภาพความเป็นจริง

รวมกันก็คงเป็น สภาพความเป็นจริงที่ถูกแต่งเติม เสริมแต่ง, การผสมผสานสภาพความเป็นจริงกับโลกเสมือนเข้าด้วยกัน

ส่วนประกอบหลักๆ ของ AR คือ

1. ตัว Marker กำหนดตำแหน่งของวัตถุ
2. กล้อง webcam , มือถือ, GPS, หรือตัวจับ sensor อื่นๆ
3. ส่วนแสดงผล อาจเป็นจอภาพทางคอมพิวเตอร์ หรือมือถือ หรืออื่นๆ
4. ส่วนประมวลผลเพื่อสร้าง object 3D เช่น software

ไปหาอ่านต่อเอง

ทดสอบเล่น AR กับ Google

ไปที่ http://www.arsights.com

ที่เมนู Download ให้

-Download ARSights for Window สำหรับ PC ตอนนี้ Version 1.5

– Print ARSights Printable Maker ออกมา

– เตรียมกล้อง Webcam ไว้ด้วย

วิธีการใช้งานคือ ให้เปิดหน้าแรกของ website arsgihts จะเห็น

google map ที่หน้าแรก ให้ลองเลื่อนหา point ของ model 3 มิติ เลือกที่ View 3D Model

 

มันจะให้ Download file นามสกุล .arsight จากนั้นเอามาเปิด กับ Software ARSights

ดูตัวอย่างใน Video http://youtu.be/_Sir9Gtc_Cw

https://www.facebook.com/photo.php?v=527661587294681

ใน Website arsight เราสามารถสมัครชิก แล้ว upload Model ของเราเองได้

หรือไป Download จาก 3D warehourse ก็ได้ มี video สอนการใช้งาน

ไปทดลองเล่นกันดูนะครับ

Batch File

FOR

Windows NT 4/2000/XP Syntax

บันทึกช่วยจำ

FOR %variable IN (set) DO command [command-parameters]
%~i expands %i removing any surrounding quotes (“)
%~fi expands %i to a fully qualified path name
%~di expands %i to a drive letter only
%~pi expands %i to a path only
%~ni expands %i to a file name only
%~xi expands %i to a file extension only
%~si expanded path contains short names only
%~ai expands %i to file attributes of file
%~ti expands %i to date/time of file
%~zi expands %i to size of file
%~$PATH:i searches the directories listed in the PATH environment variable and expands %i to the fully qualified name of the first one found.
If the environment variable name is not defined or the file is not found by the search, then this modifier expands to the empty string

The modifiers can be combined to get compound results:

%~dpi expands %i to a drive letter and path only
%~nxi expands %i to a file name and extension only
%~fsi expands %i to a full path name with short names only
%~dp$PATH:i searches the directories listed in the PATH environment variable for %i and expands to the drive letter and path of the first one found.
%~ftzai expands %i to a DIR like output line

 

http://www.robvanderwoude.com/for.php

http://www.robvanderwoude.com/ntfor.php

FOR loops

Basic syntax:

FOR %A IN (list) DO command [ parameters ]
list is a list of any elements, separated by either spaces, comma’s or semicolons.
command can be any internal or external command, batch file or even – in OS/2 and NT – a list of commands
parameters contains the command line parameters for command.
In this example, command will be executed once for every element in list, using parameters if specified.
A special type of parameter (or even command) is %A, which will be substituded by each element from list consecutively.

Full syntax

MS-DOS and PC-DOS
(incl. Win95’s MS-DOS 7.*)
as specified under basic syntax, plus VFAT/FAT32 long file name handling with LFNFOR in MS-DOS 7.*
OS/2 Warp as specified under basic syntax, though unlike in DOS, you may use redirection and conditional execution in the command string specified after DO
Windows NT 4/2000/XP as specified under basic syntax, plus many new options

 

Notes

1. %A vs. %%A
%A is for use on command lines only.
In all examples and syntax lines shown %A should be substituted with %%A when used in batch files.
2. %a vs. %A
The A in %A may be replaced by any character, either upper case or lower case, except numbers. Note, however, that variables ar case sensitive, so be consistent:
FOR %A IN (1 2 3) DO ECHO %a
will not work.
FOR %? IN (1 2 3) DO ECHO %?
on the other hand, will.
3. Nesting FOR commands
In DOS (COMMAND.COM), nesting FOR commands is not possible.
However, by using a second command processor you may still be able to nest them:
FOR %A IN (1 2 3) DO COMMAND /C FOR %B IN (A B C) DO ECHO %A%B
Note that you cannot replace COMMAND /C with CALL

In NT (CMD.EXE) nesting is possible.
Note that to nest FOR loops, each loop requires its own variable; i.e.
FOR %A IN (1 2) DO FOR %A IN (A B) DO ECHO %A
will lead to undesired results:
A
B
A
B

FOR %A IN (1 2) DO FOR %B IN (A B) DO ECHO %A%B
will work as planned, and display:
1A
1B
2A
2B

4. Commands in list
list may not only contain a list of parameters, it may even contain a list of commands that can be executed consecitively with the same parameters. a.k.a.command may also be %A:
DIR > tempfile.txt
FOR %A IN (TYPE DEL) DO %A tempfile.txt

This FOR loop will first type the temporary file and then delete it.
5. list delimiters
The “elements” in list can be delimited (separated) by spaces, tabs, commas or semicolons.
As of MS-DOS 7, doublequoted strings are treated as a single element, wether they contain delimiters or not.

In NT, it is possible to define your own delimiters with FOR /F.

6. Forward slashes in list
If list starts with a forward slash, COMMAND.COM (except MS-DOS 7) will split the string in list into its first character following the forward slash and the remainder of the string.
This is demonstrated in the interactive FOR examples
7. Conditional manipulation of variables in command
The following does not work:
FOR %%A IN (1 2 3) DO IF "%VAR%"=="" SET VAR=%%A
sets VAR to 3, not 1
The %VAR% in the comparison (IF “%VAR%”==””) is interpreted immediately, and thus empty, and then the FOR loop is started.
From the FOR loop’s point of view, the command issued was:
FOR %%A IN (1 2 3) DO IF ""=="" SET VAR=%%A
The following construction can be used as a workaround:
FOR %%A IN (1 2 3) DO CALL TEST2.BAT %%A
If TEST2.BAT looks like this:
IF "%VAR%"=="" SET VAR=%1
then VAR is set to 1
In NT a CALL to a subroutine could be used instead.
8. Jump using GOTO in command
FOR %%A IN (1 2 3) DO GOTO=%%A
:1
ECHO 1
GOTO End
:2
ECHO 2
GOTO End
:3
ECHO 3
:End

will display different results for different command interpreters:

  • CMD.EXE (NT and OS/2) will jump to label 1
  • COMMAND.COM (DOS) will jump to label 1, then 2, then 3, without executing any of the following commands, and then execute the ECHO 3 and following commands

FOR

Windows NT 4/2000/XP Syntax

 

Note: The parts of this text that are displayed in magenta are valid for Windows 2000 and XP only

Runs a specified command for each file in a set of files.

FOR %variable IN (set) DO command [command-parameters]
%variable Specifies a replaceable parameter.
(set) Specifies a set of one or more files. Wildcards may be used.
command Specifies the command to carry out for each file.
command-parameters Specifies parameters or switches for the specified command.

To use the FOR command in a batch program, specify %%variable instead of %variable
Variable names are case sensitive, so %i is different from %I.

If Command Extensions are enabled, the following additional forms of the FOR command are supported:

FOR /D %variable IN (set) DO command [command-parameters]

If set contains wildcards, then specifies to match against directory names instead of file names.

FOR /R [[drive:]path] %variable IN (set) DO command [command-parameters]

Walks the directory tree rooted at [drive:]path, executing the FOR statement in each directory of the tree.
If no directory specification is specified after /R then the current directory is assumed.
If set is just a single period (.) character then it will just enumerate the directory tree.

FOR /L %variable IN (start,step,end) DO command [command-parameters]

The set is a sequence of numbers from start to end, by step amount.
So (1,1,5) would generate the sequence 1 2 3 4 5 and (5,-1,1) would generate the sequence (5 4 3 2 1)

Note: If step equals 0, and end is greater than or equal to start, then the loop will continue forever:

FOR /L %A IN (0,0,0) DO command [command-parameters]

This is the batch equivalent of Do Forever (continuous) loops in “real” scripting languages.

FOR /F [“options“] %variable IN (filenameset) DO command [command-parameters]
FOR /F [“options“] %variable IN (“string“) DO command [command-parameters]
FOR /F [“options“] %variable IN (‘command‘) DO command [command-parameters]

or, if usebackq option present:

FOR /F [“options“] %variable IN (filenameset) DO command [command-parameters]
FOR /F [“options“] %variable IN (‘string‘) DO command [command-parameters]
FOR /F [“options“] %variable IN (`command`) DO command [command-parameters]

filenameset is one or more file names.
Each file is opened, read and processed before going on to the next file in filenameset.
Processing consists of reading in the file, breaking it up into individual lines of text and then parsing each line into zero or more tokens. The body of the for loop is then called with the variable value(s) set to the found token string(s).
By default, /F passes the first blank separated token from each line of each file.
Blank lines are skipped.
You can override the default parsing behavior by specifying the optional “options” parameter. This is a quoted string which contains one or more keywords to specify different parsing parameters.
The keywords are:

eol=c specifies an end of line comment character (just one).

Note: The default eol character is the semicolon (;).
That is why FOR /F loops skip lines starting with semicolons unless a different eol character is specified (try "eol=").
skip=n specifies the number of lines to skip at the beginning of the file.
delims=xxx specifies a delimeter set. This replaces the default delimiter set of space and tab.
tokens=x,y,m-n specifies which tokens from each line are to be passed to the for body for each iteration.
This will cause additional variable names to be allocated.
The m-n form is a range, specifying the mth through the nth tokens.
If the last character in the tokens= string is an asterisk, then an additional variable is allocated and receives the remaining text on the line after the last token parsed.
usebackq specifies that the new semantics are in force, where a back quoted string is executed as a command and a single quoted string is a literal string command and allows the use of double quotes to quote file names in filenameset.

Some examples might help:

FOR /F “eol=; tokens=2,3* delims=, ” %i in (myfile.txt) do @echo %i %j %k

would parse each line in myfile.txt, ignoring lines that begin with a semicolon, passing the 2nd and 3rd token from each line to the for body, with tokens delimited by commas and/or spaces.
Notice the for body statements reference %i to get the 2nd token, %j to get the 3rd token, and %k to get all remaining tokens after the 3rd.
For file names that contain spaces, you need to quote the filenames with double quotes.
In order to use double quotes in this manner, you also need to use the usebackq option, otherwise the double quotes will be interpreted as defining a literal string to parse.

%i is explicitly declared in the for statement and the %j and %k are implicitly declared via the tokens= option.
You can specify up to 26 tokens via the tokens= line, provided it does not cause an attempt to declare a variable higher than the letter ‘z’.
Remember, FOR variable names are global, and you can’t have more than 26 (NT 4) or 52 (Windows 2000/XP) total active at any one time.

You can also use the FOR /F parsing logic on an immediate string, by making the filenameset between the parenthesis a quoted string. It will be treated as a single line of input from a file and parsed.

Finally, you can use the FOR /F command to parse the output of a command. You do this by making the filenameset between the parenthesis a single quoted (NT 4) or back quoted (Windows 2000/XP) string. It will be treated as a command line, which is passed to a child CMD.EXE and the output is captured into memory and parsed as if it was a file.
So the following examples:

FOR /F “delims==” %i IN (‘set’) DO @echo %i
FOR /F “usebackq delims==” %i IN (`set`) DO @echo %i

would enumerate the environment variable names in the current environment.

In addition, substitution of FOR variable references has been enhanced.
You can now use the following optional syntax:

%~i expands %i removing any surrounding quotes (“)
%~fi expands %i to a fully qualified path name
%~di expands %i to a drive letter only
%~pi expands %i to a path only
%~ni expands %i to a file name only
%~xi expands %i to a file extension only
%~si expanded path contains short names only
%~ai expands %i to file attributes of file
%~ti expands %i to date/time of file
%~zi expands %i to size of file
%~$PATH:i searches the directories listed in the PATH environment variable and expands %i to the fully qualified name of the first one found.
If the environment variable name is not defined or the file is not found by the search, then this modifier expands to the empty string

The modifiers can be combined to get compound results:

%~dpi expands %i to a drive letter and path only
%~nxi expands %i to a file name and extension only
%~fsi expands %i to a full path name with short names only
%~dp$PATH:i searches the directories listed in the PATH environment variable for %i and expands to the drive letter and path of the first one found.
%~ftzai expands %i to a DIR like output line

 

 

แก้ปัญหาลบขอบดำของภาพดาวเทียม

เคยเจอไหมเมื่อเราเอาข้อมุลภาพจากดาวเทียม rgb มาเปิดแล้วมีขอบดำ

1

ถ้าไม่ต้องการให้ภาพแสดงขอบดำทำยังไง? สมมติใน Arcgis เลือก Properties ที่ display background value set ค่า rgb = 0,0,0 เป็น nocolor ผลลัพธ์เป็นไง ภาพขอบดำหายไป แต่ถ้าบังเอิญในบริเวณในเนื้อภาพมีค่า rgb = 0,0,0 เหมือนกัน ภาพก็กลายเป็นรูโหว่

2

ทางแก้ทำไง? มี software มาแนะนำ คือ gdal คำสั่ง nearblack ใน Fwtools จะเป็น gdal version เก่า ให้ไปหา gdal version ใหม่มาซะ ไปdownload Osgeo4W มาใช้ก็ได้

ใส่คำสั่งนี้ไป

nearblack –of GTiff –color 0,0,0 –near 0 –nb 0 –setalpha –setmask –o output.tif input.tif

input ใช้ภาพของ You เลย output ตั้งเอาเอง

รอแป๊บนึงเรียบร้อย  เสร็จแล้วลองเอาเปิดใน Arcgis ดูอีกครั้ง เลือก Properties จะมี channel alpha เพิ่มมาให้ ติ๊กถูกที่ channel alpha และเลือก band 4ที่สร้างเพิ่มขึ้นมาใหม่ รอดูผลลัพธ์เอาเอง จบ

3

แถมหากมีภาพเป็นกุรุส ใช้คำสั่งวนลูปใส่คำสั่งนี้ไป

For %i in (*.tif) do nearblack –of GTiff –color 0,0,0 –near 0 –nb 0 –setalpha –setmask –o %~ni_alpha.tif %i

4

คำสั่งเดียวคีย์เสร็จไปนั่งหาอะไรกินได้เลย

ค่อยมาเพิ่มเรื่อง band alpha เอาไปทำไรต่อได้บ้าง