Saturday, April 30, 2011

Mapping the Disease Trends

Be The First To Comment
West Nile Virus (WNV) is the most widespread arbovirus (viruses that are transmitted by arthropods) in theworld. . During the period of 1996 -1999, the WNV became prevalent insouthern Romania, the Volga delta in southern Russia, and the northeastern United States. The spread of WNV covered the United States from coast to coast in four years, and by then it had 7 infected about one million Americans, killing about eight hundred.

Here I mapped the spatial trends of WNV virus in the United States of America.

Check website - http://globalmonitoring.sdstate.edu/eastweb/maps/wnv1999_2011/

Thursday, April 21, 2011

Add and Remove DOM Elements..

Be The First To Comment
Snippets for adding DOM elements dynamically to the defined DOM element.
Here, "mydiv2" is added dynamically as "mydiv"1's child.

    //Dynamically generate Div
    var newdiv = document.createElement('div');
    var divIdName ='mydiv2';
    newdiv.setAttribute('id',divIdName);
    newdiv.style.width = "565px";
    newdiv.style.height = "480px";
    newdiv.style.left = "0px";
    newdiv.style.top = "0px";
    newdiv.style.position = "absolute";
   newdiv.style.border = "1px solid #000";
    document.getElementById('mydiv1').appendChild(newdiv);

A good example by Dustin Diaz to remove DOM elements Dynamically.

removeElement JavaScript Function

function removeElement(divNum) {

  var d = document.getElementById('myDiv');

  var olddiv = document.getElementById(divNum);

  d.removeChild(olddiv);

}

Sunday, April 3, 2011

Detect Browser Type Using Javascript and Pass it into PHP variable

Be The First To Comment
<html>
<head>
<script type="text/javascript" language="javascript">
function DetectBrowser(){
// Browser Detection Javascript
// copyright 1 February 2003, by Stephen Chapman, Felgall Pty Ltd
// You have permission to copy and use this javascript provided that
// the content of the script is not changed in any way.
var agt=navigator.userAgent.toLowerCase();
if (agt.indexOf("opera") != -1) return 'Opera';
if (agt.indexOf("staroffice") != -1) return 'Star Office';
if (agt.indexOf("webtv") != -1) return 'WebTV';
if (agt.indexOf("beonex") != -1) return 'Beonex';
if (agt.indexOf("chimera") != -1) return 'Chimera';
if (agt.indexOf("netpositive") != -1) return 'NetPositive';
if (agt.indexOf("chrome") != -1) return 'Chrome';
if (agt.indexOf("firefox") != -1) return 'Firefox';
if (agt.indexOf("safari") != -1) return 'Safari';
if (agt.indexOf("skipstone") != -1) return 'SkipStone';
if (agt.indexOf("msie") != -1) return 'Internet Explorer';
if (agt.indexOf("netscape") != -1) return 'Netscape';
if (agt.indexOf("mozilla/5.0") != -1) return 'Mozilla';
if (agt.indexOf('\/') != -1) {
if (agt.substr(0,agt.indexOf('\/')) != 'mozilla') {
return navigator.userAgent.substr(0,agt.indexOf('\/'));}
else return 'Netscape';} else if (agt.indexOf(' ') != -1)
return navigator.userAgent.substr(0,agt.indexOf(' '));
else return navigator.userAgent;
}

</script>
</head>
<title>
</title>
<body>
<?php
$browser= "<scriptlanguage=javascript>document.write(DetectBrowser());</script>";
echo $browser;
?>
</body>
</html>
The php portion shows the example of "Passing Javascript variable into the PHP variable"

Sunday, March 27, 2011

A thought in the lazy day

Be The First To Comment
Being a geographer, I am so thrilled in my life. I got opportunities to feel nature from the bottom of my heart. I am also an engineer. I found geography is more interesting than engineering; however I love math, statistics, and scientific computing. I never afraid from math meantime, implementing math in geography is very fascinating job for me.
It’s a time to integrate technology with nature so don’t get late to be a geographer and experience ecstatic in your entire life.

Friday, March 18, 2011

How to get Color Brewer Ramp in ArcMap 10?

2 Comments

There are two ways to achieve this:

Method A steps:

1. Download Color Brewer Color Ramp Style Set from http://arcscripts.esri.com/details.asp?dbid=14403

2. Unzip it.

3. Open the Layer properties and click on ‘Symbology’ tab in ‘ArcMap 10’.

4. Double click on one of the color symbol beneath ‘Symbol’ that gives you a ‘Symbol Selector’ window.

5. Click “Style References..”

6. Click “Add Style to List..” and add ‘ColorBrewer.style’ that is obtained from setp 2.

7. If you made it correctly it should be listed in the ‘Style References’.

8. Select ‘ColorBrewer.style’ and make it default.

9. Close the layer properties once and open it again, you will see newly generated color ramp.


Method B steps:

1. You have to pick each color ramp value manually from http://colorbrewer2.org/ .

2. Open the Layer properties and click on ‘Symbology’ tab in ‘ArcMap 10’.

3. Double click on one of the color symbol beneath ‘Symbol’ that gives you a ‘Symbol Selector’ window.

4. Click on ‘Edit Symbol’.

5. Click on Color box inside ‘Simple Fill’ area.

6. Click on “More Colors” which gives you Color Selector.

7. Choose RGB from Drop down box located in the top right.

8. Then, update values that come from Colorbrewer.

Voila Cheers!!!!!

I would like to recommend ‘Method A, because it is faster than Method B. (Does the same work but time consuming)

The author of color brewer, Cynthiya Brewer also published a book Designing better Maps in ArcGIS.



Tuesday, February 22, 2011

Iframe busy inidcating spinning bar.

Be The First To Comment
I got one solution on delving the internet

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
<html>
<head>
<title>Iframe Loading Notice - Demo</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
#holder, #holder iframe {
position:relative;
width:500px;
height:400px
}
#loading {
height:50px;
width:125px;
padding:1ex;
position:absolute;
top:50%;
left:50%;
margin-top:-25px;
margin-left:-63px;
display:none;
border:2px groove gray;
background-color:#cccccc;
color:#333333;
}
</style>
<script type="text/javascript">
var loadit=function(){
var f=document.getElementById('myframe'), l=document.getElementById('loading').style;
l.display='block';
if(f.onload==null){
f.onload=function(){l.display='none'};
if(window.attachEvent)
f.attachEvent('onload', f.onload);
}
return true;
}

</script>
</head>
<body>
<div id="holder">
<iframe id="myframe" name="myframe" src="about:blank" scrolling="auto" frameborder="1"></iframe>
<div id="loading">Loading . . .</div>
</div>
<a href="http://www.google.com/" target="myframe" onclick="return loadit();">Google</a><br>
<a href="http://www.dynamicdrive.com/" target="myframe" onclick="return loadit();">Dynamic Drive</a>
</body>
</html>


Thank you for the original post(http://www.dynamicdrive.com/forums/showthread.php?t=22759).

And I modified this according to my need as below:

<style type="text/css">
#holder, #holder iframe {
position:relative;
width:500px;
height:400px
}
#loading {
<!--height:50px;
width:125px;
padding:1ex;
position:absolute;
top:50%;
left:50%;
margin-top:-25px;
margin-left:-63px; -->
display:none;
<!--border:2px groove gray;
background-color:#cccccc;
color:#333333; -->
}
</style>
<script type="text/javascript">
var loadit=function(){
var f=document.getElementById('iframemap'), l=document.getElementById('loading').style;
l.display='block';
if(f.onload==null){
f.onload=function(){l.display='none'};
if(window.attachEvent)
f.attachEvent('onload', f.onload);
}
return true;
}
</script>

And what you need is spinning.gif image.


<div id="holder">
          <iframe name="iframemap" id="iframemap" width="550" height="450"></iframe>
          <div id="loading"> <img src="images/busy.gif"></div>
          </div>


Cheers !!

Friday, February 18, 2011

Convert PHP array into Javascript array

Be The First To Comment
I got a chance to write a script that converts php array into javascript  array.
Here it is..
<?php
  $phparray= array(1,2,3,4,5);
?>

<script type="text/javascript" language="javascript">
    var mydata = new Array (
    <?php
      for ($i = 0; ($i < count($phparray)); $i++) {
        if ($i > 0) {
          echo ",\n";
        }
        echo "    \"";
        echo $phparray[$i];
        echo "\"";
      }
     
    ?>
    );
</script>

Wednesday, November 10, 2010

R Environment and PostgreSQL

Be The First To Comment
# Install PostgreSQL 8.4 - 32 bit and install pgJDBC Driver, OLEDB Driver from Stack Builder..........
# Install R 2.11.1 -32 bit
# Open R interface..

library(rJava)
library(DBI)
library(RJDBC)
library(RpgSQL)

.jinit(classpath=NULL,parameters=getOption("-Xmx4000m"),silent=FALSE,force.init=TRUE)
con <- dbConnect(pgSQL(), user = "username", password = "password", dbname = "db_name",host="hostname")
result<-dbGetQuery(con, 'select blah1, blah2 from "tbl_blh"')

str(result)

result

Cheers !!!

Automatically Generate KML Files from CSV file

Be The First To Comment
# Import System Modules

import sys, string, os, csv

# Enter the input and output file names here

inputFileName="PROJECT.csv"
outputFileName="PROJ.kml"

inFile=open(inputFileName)
outFile=open(outputFileName,'a')

# Enter the total number of records here
numobs = 12

header =""+"\n"+\
""+"\n"+\
""+"\n"+\
"Spatial Distribution of Students "+"\n"

# Read in the stand attributes file one line at a time

outFile.write(str(header))

for obs in range(numobs):
readline=inFile.readline()

# Select the variables
currow=readline.split(",")
student=currow[0]
year=currow[1]
rslat=currow[2]
rslong=currow[3]
advisor=currow[4]
studyarea=currow[5]

outFile.write(""+"\n"+\
""+student+""+"\n"+\
""+"Location: "+studyarea +","+"Thesis Year: "+year+","+"Thesis Advisor: "+advisor +""+"\n"+\
""+"\n"+\
""+rslong+","+rslat+"13"+""+"\n"+\
"
"+"\n"+\
"
"+"\n")
#print studentInfo
#outFile.write(str(studentInfo))

footer="
"+"\n"+\
"
"

outFile.write(str(footer))

inFile.close()
outFile.close()

Tuesday, June 1, 2010

Getting MODIS Image Automatically From FTP in Python

7 Comments
# This is a Python script that automatically downloads historical
# MODIS data from the LP DAAC FTP site
# This version should work for all of the tiled datasets
# It is currently hard-coded to downloaded specific MODIS tiles for
# the northern Great Plains & upper midwest

# Initailly historical date for Data transfer must be set on "lpdacc.txt".



import os, ftplib,sys,string


# Login information for accessing the LP DAAC FTP site
Hostname = "e4ftl01u.ecs.nasa.gov"
Username = "anonymous"
Password = "@anonymous"

# Get user inputs
# Base directory for the MODIS data

# Basedir = input("Enter the LP DAAC directory containing the dataset you want to download:")
Basedir="MOLT/MOD11A2.005"
print "The LP DAAC directory containing the dataset you want to download" +str(Basedir)


# Local directory for data storage
#Hdfdir = input("Enter the local directory where you want to store the hdf files:")
Hdfdir=r"H:\MODIS_LST_NDVI\MOD11A2\\"
print "The local directory where you want to store the hdf files" +str(Hdfdir)


# Empty lists for the collector functions
Dirlist = []
Filelist = []

mylog=open(r"H:\MODIS_LST_NDVI\MOD11A2\mylog.txt",'w',)

# Assigning Global ariables
i=0
k=0
flag=0

try:

# Define helper functions that are used to read files/subdirectories from the
# ftp site and store them as lists
def collector(line = ''):
global Dirlist
Dirlist.append(line)

def collector2(line = ''):
global Filelist
Filelist.append(line)



# Open ftp connection
ftp = ftplib.FTP(Hostname,Username,Password)

# Go to the directory containing the dataset of interest
ftp.cwd(Basedir)

# Involke the LIST ftp function, calling the collector function to store the
# results to Dirlist in list format
ftp.retrlines("LIST", collector)

# Get Directory listing only (Without including the sub directories)
mainDirlist=[]
myDirlist=[]
ftp.dir(mainDirlist.append)
myDirlist=mainDirlist[1:]
# parsing the Directory list
dirInfo=""


for mainDir in myDirlist:
#parsing the directory name only[2002.12.03]
mainDirname= mainDir[37:47]
dd=mainDirname[8:10]
mm=mainDirname[5:7]
yyyy=mainDirname[0:4]
#Extracging yyyy mm dd to compare with log file information
dirInfo=str(yyyy)+str(mm)+str(dd)
print mainDirname
print dirInfo

# Read the log file to retrive the information of latest downloaded data
logFileread=open(r"H:\MODIS_LST_NDVI\MOD11A2\lpdaac.txt",'r')
logFileread.seek(0)
logInfo=int(logFileread.read())
logFileread.close()

print"Local Drive Recent Log Dir # "+str(logInfo)
mylog.write("Local Drive Recent Log Dir # "+str(logInfo)+'\n')

# Coparing the logfile(already downloaded data) with recent datas in the ftp
if(int(logInfo) print "current path -->"+str(ftp.pwd())
if(flag==1): # if flag matches the criteria reset the counters
ftp.cwd("..")
k=0
flag=0
Filelist = []

# List all the files in the subdirectory
path=str(mainDirname)
ftp.cwd(path)
print "New path -->"+str(ftp.pwd())
# Filelist = ftp.dir()
##FTP Directory bhitra chire pni file ma chire ko chhina
ftp.retrlines("LIST", collector2)
#ftp.retrlines("LIST")
# Download data from the MODIS tiles that we are interested in
for Currow2 in Filelist:
Splitrow2 = Currow2.split()
Permissions = Splitrow2[0]

# Skip over the jpeg browse images - some of these cause problems
if Permissions[0:3] == "-rw":
Directories = Splitrow2[1]
Group = Splitrow2[2]
Size = Splitrow2[3]
Month = Splitrow2[4]
Date = Splitrow2[5]
Time = Splitrow2[6]
Filename = Splitrow2[7]
mylog.write(Filename)
LocalFile = Hdfdir + Filename
Splitfname = Filename.split(".")
# Split the header file name into its various components
Splitfname = Filename.split(".")
Mdataset = Splitfname[0]
Maqdate = Splitfname[1]
Mlocation = Splitfname[2]
Mprocdate = Splitfname[3]
Mext1 = Splitfname[4]
Mext2 = Splitfname[5]


# Pull out the horizontal and vertical tile numbers
Htile = Mlocation[1:3]
Vtile = Mlocation[4:6]


# Only retrieve data for the three tiles covering the NGP/Upper Midwest
if (((Htile == "09") & (Vtile == "04"))|((Htile == "10") & (Vtile == "04"))|((Htile == "11") & (Vtile == "04"))|((Htile == "12") & (Vtile == "04"))|((Htile == "09") & (Vtile == "05"))|((Htile == "10") & (Vtile == "05"))|((Htile == "11") & (Vtile == "05"))):
# Retrieve the hdf and xml files and place them in the local directory

ftp.retrbinary("RETR " + Filename, open(LocalFile, "wb").write)

# Write download information in the log file
logFwrite=open(r"H:\MODIS_LST_NDVI\MOD11A2\lpdaac.txt",'w')
logFwrite.seek(0)
logFwrite.write(dirInfo)
logFwrite.close()

k=k+1
if(k==14): # value of k should be no of tiles*2[for *.hdf and *.hdf.xml ]
flag=1

else:
print i
i=i+1
print "loginfor-->"+str(logInfo)
print "dirInfor-->"+str(dirInfo)
print "Dirname-->"+str(mainDirname)
print "Filename-->"+str(Filename)
mylog.write("loginfor-->"+str(logInfo)+'\n')
mylog.write("dirInfor-->"+str(dirInfo)+'\n')
mylog.write("Dirname-->"+str(mainDirname)+'\n')
mylog.write("Filename-->"+str(Filename)+'\n')



else:
print "Already downloaded in our local drive" +str(mainDirname)
mylog.write( "Already downloaded in our local drive" +str(mainDirname)+'\n')



finally:
ftp.quit()
ftp.close()
print "Closing FTP"
mylog.write("Closing FTP")
mylog.close()
 

© 2011 GIS and Remote Sensing Tools, Tips and more .. ToS | Privacy Policy | Sitemap

About Me