[Thread Prev][Thread Next][Index]

Re: [ferret_users] india boundary



nitin patil a écrit :
Dear ferret users,
Did any one knows how to give a border to India country if we have to plot only India.
if possible can we  border states also?

Hi,

I have done this recently using kml files distributed
by the "Global Administrative Areas" website.

Please follow the different steps:

1) From http://www.gadm.org
Go in the Download section, select the country
and choose "Google Earth .kmz"

After the download, you can have a look to the kmz file
with googleearth of course.
Unzip the kmz file. You should obtain a kml file.

2) Convert the kml file to a text with
3 columns lon,lat,number (number is the
index representing the area) with the python
script attached.

3) Use the ferret plot.jnl script to validate and
save the polygons as a netcdf file.

Here is an example with India with the first
2 administratives levels.

$ unzip IND_adm1.kmz
$ ./convert_kml.py IND_adm1.kml > IND_adm1.dat
$ ferret
yes? go plot.jnl IND_adm1.dat IND_adm1.nc

Note: that when I try to do the same with IND_adm0.dat,
ferret restarts my X11 server !
The problem occurs at line
repeat/name=n/range=1:`numb[i=@max]` ( def sym n=`n` ; let lon1=if numb eq `n` then lon ; let lat1=if numb eq `n` then lat ; polygon/line/fill/o/nolab/lev=(1,200,1)/pal=thirty_by_levels.spk lon1,lat1,`n` ; PPL SHASET RESET )

But the method is still ok, just do not not blindly
use polygon command but rather plot/vs.
There may be a problem anyway.

Happy ferreting

Patrick

--
LSCE/IPSL, Laboratoire CEA-CNRS-UVSQ
Data Analysis and Visualization Engineer
ICMC - IPSL Climate Modelling Centre
--

#!/bin/env python

import sys
from xml.dom.minidom import parse

dom = parse(sys.argv[1])

name = dom.getElementsByTagName('Placemark')

n=1
for node in name :
	coords = node.getElementsByTagName('coordinates')
	for coord in coords :
		c=coord.firstChild.data
		d=c.split()
		print "-1E+34, -1E+34, -1E+34"
		for i in range(len(d)) :
			e=d[i].split(',')
			print "%s, %s, %s" %(e[0],e[1],n)
	n=n+1

GIF image

cancel data/all ; cancel var/all

!###################################################
def sym file=($01)

def sym nblines=`spawn("wc -l ($file) | cut -d' ' -f 1")`

DEFINE AXIS/X=1:($nblines):1 vec_len
DEFINE GRID/X=vec_len vec_grid
FILE/form=delimited/VAR=lon,lat,numb/G=vec_grid "($file)"

set variable/units="degrees_east" lon
set variable/units="degrees_north" lat

save/file="($02)"/clobber lon,lat,numb

!###################################################
cancel data/all ; cancel var/all

use "($02)"

ppl color 6,70,70,70
go margins_set 10 10 10 10
plot/vs/grat=(color=6,dash)/line/nolab lon,lat

repeat/name=n/range=1:`numb[i=@max]` ( def sym n=`n` ; let lon1=if numb eq `n` then lon ; let lat1=if numb eq `n` then lat ; polygon/line/fill/o/nolab/lev=(1,200,1)/pal=thirty_by_levels.spk lon1,lat1,`n` ; PPL SHASET RESET )   

say polygon/line/nolab/fill lon,lat,i[i=1:`lon[i=@NBD]`]




[Thread Prev][Thread Next][Index]
Contact Us
Dept of Commerce / NOAA / OAR / PMEL / Ferret

Privacy Policy | Disclaimer | Accessibility Statement