Plotting 'continents' in object graphics... [message #41124] |
Thu, 30 September 2004 10:45  |
george
Messages: 22 Registered: August 1996
|
Junior Member |
|
|
Hi there,
I am plotting data on a sphere - using the 'Orb' object - and i want
to add the continents boundaries - just like the 'continents' command
in direct graphics. Only there isn't a continents command for
objects. Has anyone done this / know how to do it ?
Cheers in advance...
George.
|
|
|
|
|
|
|
Re: Plotting 'continents' in object graphics... [message #41259 is a reply to message #41124] |
Mon, 04 October 2004 13:35   |
Mark Hadfield
Messages: 783 Registered: May 1995
|
Senior Member |
|
|
Rick Towler wrote:
>
> Come on people! If there is one thing we have learned is that you can
> do just about anything in OG if you are willing to waste the time :)
>
> Someone with some mapping skills could whip up a set of verts and
> connectivity given the many coastline databases on the web. It just
> needs to be done once and it has probably been done already. Anybody
> care to share?
I have some code to pull coastline data from the GSHHS dataset:
http://www.ngdc.noaa.gov/mgg/shorelines/gshhs.html
The routine accepts a pair of longitudes and latitudes defining a
rectangular area, then pulls out all coastline segments intersecting
(and maybe surrounding) this rectangle, tessellates them and clips them.
This is not done once and for all, it's done every time the routine is
called (but it does save the results in a temporary file and re-use that
if possible).
It works very nicely for my needs, but I mostly draw maps of the
Southwest Pacific. It would not work so well for maps of small regions
of large continents, because if you want to draw a map of, say, the
northern tip of Denmark at high resolution, you first have to read &
tessellate all of Eurasia!
I could publish my routines if there's any interest...
--
Mark Hadfield "Ka puwaha te tai nei, Hoea tatou"
m.hadfield@niwa.co.nz
National Institute for Water and Atmospheric Research (NIWA)
|
|
|
|
|
Re: Plotting 'continents' in object graphics... [message #41265 is a reply to message #41124] |
Mon, 04 October 2004 10:40   |
Rick Towler
Messages: 821 Registered: August 1998
|
Senior Member |
|
|
George Millward wrote:
> I am plotting data on a sphere - using the 'Orb' object - and i want
> to add the continents boundaries - just like the 'continents' command
> in direct graphics. Only there isn't a continents command for
> objects. Has anyone done this / know how to do it ?
Randall Skelton wrote:
> I don't believe it is possible. I know it was on my feature request
> list that I sent them back in the IDL 5.x days...
Come on people! If there is one thing we have learned is that you can
do just about anything in OG if you are willing to waste the time :)
Someone with some mapping skills could whip up a set of verts and
connectivity given the many coastline databases on the web. It just
needs to be done once and it has probably been done already. Anybody
care to share?
Lacking said mapping skills, I chose to look for some canned geometry.
A while back I created a .dxf file from some continents geometry I
found. The file contains polygon meshes of the continents, not quite
the outlines you were looking for but it is a quick solution.
You can use it with my DXF model object which makes it a bit easier to
play with dxf files. Note that the object only handles polyline and
polygon DXF primitives (which are all I care about) but could easily be
extended if need be. For the continents, you'll have to set the colors
of the primitives manually since there is no color information in the
DXF file. Use the GetPrimitive method to get the obj references.
IDL> orb=obj_new('orb', color=[180,180,250], radius=0.99)
% Compiled module: ORB__DEFINE.
IDL> continents=obj_new('rhtgrdxfmodel','continents.dxf', $
alpha_channel=0.3)
% Compiled module: LINKEDLIST__DEFINE.
% Loaded DLM: DXF.
IDL> orb->add, continents
IDL> orb->add, continents
IDL> xobjview, orb
The DXF file is here:
http://www.acoustics.washington.edu/~towler/programs/contine nts.zip
The RHTgrDXFModel object is here:
http://www.acoustics.washington.edu/~towler/programs/rhtgrdx fmodel__define.pro
You'll need David's linkedlist__define.pro available from his website
http://www.dfanning.com.
-Rick
|
|
|
|
Re: Plotting 'continents' in object graphics... [message #41270 is a reply to message #41124] |
Mon, 04 October 2004 04:26   |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
George Millward writes:
> I am plotting data on a sphere - using the 'Orb' object - and i want
> to add the continents boundaries - just like the 'continents' command
> in direct graphics. Only there isn't a continents command for
> objects. Has anyone done this / know how to do it ?
I believe I know "how" do to it. You are going to have
to use a shapefile of a continent, or perhaps all the countries
of the world. I've seen it done (I think) with a world countries
shapefile, although I couldn't tell you where to find it.
(Or maybe what I saw was on a flat representation of an orthogonal
map projection, I can't remember.) Anyway, I think this might
be your only option. RSI offers little or no help with shapefiles,
generally, so you are pretty much on your own. Good luck!
Let us know how you solve this little problem. I *lot* of
people want to know. :-)
Cheers,
David
--
David W. Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http:/www.dfanning.com/
Phone: 970-221-0438, IDL Book Orders: 1-888-461-0155
|
|
|
|
Re: Plotting 'continents' in object graphics... [message #41344 is a reply to message #41254] |
Tue, 05 October 2004 17:17   |
Rick Towler
Messages: 821 Registered: August 1998
|
Senior Member |
|
|
Randall Skelton wrote:
> While not explicitly listed, the dxf dlm does not seem to exist for OS
> X. It didn't work in 5.6 or 6.0 either. Rick, could you just dump the
> variables to continents.sav?
Hi Randall,
I modified RHTgrDXFModel to export/import data to/from IDL .sav files.
I have been kicking around ideas to store scene graphs so this gave me a
chance to test the simplest of ideas. Below is a link to the updated
RHTgrDXFModel object as well. You should be able to use it, or use the
code from it, to easily create a IDLgrPolygon object from the .sav file.
IDL> m=obj_new('rhtgrdxfmodel')
IDL> m->importfromsav, 'dxf_continents.sav'
IDL> xobjview, m
IDL> obj_destroy, m
I've implemented code to properly handle colors (as I understand them)
but it is untested since all of my .dxf files don't contain interesting
color data.
Also below is a link to a .sav file which contains the continents.dxf
data. The data is stored in a pointer array "dxfdata" (The
continents.dxf file contained only one entity so the pointer array is
one element in size.) Dereferencing the pointers will return a
structure with the following fields:
IDL> restore, 'dxf_continents.sav'
IDL> help, *dxfdata[0], /structure
** Structure <1b99c98>, 7 tags, len=370960, data len=370951, refs=1:
IDLTYPE STRING 'IDLGRPOLYGON'
DXFTYPE INT 9
DXFBLOCK STRING ''
DXFLAYER STRING 'earth'
DATA DOUBLE Array[3, 7572]
POLYS LONG Array[47296]
COLOR BYTE 0
http://acoustics.washington.edu/~towler/programs/rhtgrdxfmod el__define.pro
http://acoustics.washington.edu/~towler/programs/dxf_contine nts.sav
Cheers!
-Rick
|
|
|
Re: Plotting 'continents' in object graphics... [message #41348 is a reply to message #41249] |
Tue, 05 October 2004 08:19   |
AJ
Messages: 5 Registered: April 2003
|
Junior Member |
|
|
You could use the iTools to visualize this. Open a new iMap and then just
open the file using File/Open. The complete high resolution country
boundaries will be drawn, which might take a while. Now you can
interactivelly adjust all kinds of properties of the different country
visualizations and try different projections and limits.
Alternativelly you might adjust parameters through code or even read in the
file automatically through code. The code below gives some techniques...
should be run in IDL 6.1 and works with the world Shape file found at
http://aprsworld.net/gisdata/world/.
Cheers,
-AJ
++++++++++++++++++++++
Pro iReadShapeFile
; Open an empty iMap
iMap, MAP_PROJECTION='Stereographic', LIMIT = [40,-5,60,25]
; Get a reference to the iTool
idTool = itgetcurrent(Tool = oT)
; Get the File open operation
idFileOpen = oT -> FindIdentifiers('*File/Open', /operations)
; Cancel out the user interface
s = oT -> DoSetProperty(idFileOpen, 'SHOW_EXECUTION_UI', 0)
; Select the file interactivelly....
file = dialog_pickfile(Title = 'Select Shape-file', $
Filter = '*.shp')
; .... or specify the file here
;file = 'C:\Temp\world.shp'
;; What properties do we have? Reported to log window
itPropertyReport, oT, idFileOpen, /value
; Set some properties
s = oT -> DoSetProperty(idFileOpen, 'FILENAMES', file)
; ... and do the action
s = oT -> DoAction(idFileOpen)
; Set back user interface
s = oT -> DoSetProperty(idFileOpen, 'SHOW_EXECUTION_UI', 1)
oT -> ErrorMessage, 'This is Stereographic projection!'
;;Loop to find countries:
;; Get all countries first
idCountries = oT->FindIdentifiers('*shape*', /VISUALIZATIONS)
oT -> ErrorMessage, "Let's color some countries!"
for i=0,n_elements(idCountries)-1 do begin
oCountry = oT->GetByIdentifier(idCountries[i])
success = oCountry->GetPropertyByIdentifier('NAME', name)
IF ~success THEN BEGIN
PRINT, 'No name found'
CONTINUE
ENDIF
Case 1 of
STRCMP(name, 'berlin',5,/fold_case) : $
success = oT->DoSetProperty(idCountries[i], 'FILL_COLOR',
[255,175,30])
STRCMP(name, 'london',5,/fold_case) : $
success = oT->DoSetProperty(idCountries[i], 'FILL_COLOR', [0,255,0])
STRCMP(name, 'amsterdam',5,/fold_case) : $
success = oT->DoSetProperty(idCountries[i], 'FILL_COLOR',
[0,128,255])
STRCMP(name, 'rome',4,/fold_case) : $
success = oT->DoSetProperty(idCountries[i], 'FILL_COLOR',
[128,70,210])
STRCMP(name, 'paris',5,/fold_case) : $
success = oT->DoSetProperty(idCountries[i], 'FILL_COLOR', [0,0,255])
ELSE : success = 0
ENDCASE
if success then begin
; Set background fill on for this country
s = oT->DoSetProperty(idCountries[i], 'FILL_BACKGROUND', 'True')
oT->CommitActions ;do each time so tool keeps refreshing
endif
endfor
oT -> ErrorMessage, 'And now we want to change projection.....'
; Find the old grid.... should be deleted
idGrid = oT -> FindIdentifiers('*Map Grid', /Visualization)
oGrid = oT -> GetByIdentifier(idGrid)
oGrid -> Select
idDelete = oT -> FindIdentifiers('*Delete', /Operations)
s = oT -> DoAction(idDelete)
;; Change the Projection and limits
;; Get the Map Projection Operations
idProj = oT -> FindIdentifiers('*Map Projection', /Operations)
;; What properties do we have? Reported to log window
itPropertyReport, oT, idProj, /value
;; Cancel out the User Interface for the projection action
oProj = oT->GetByIdentifier(idProj)
oProj->GetProperty, SHOW_EXECUTION_UI=init_val
oProj->SetProperty, SHOW_EXECUTION_UI=0
s = oT -> DoSetProperty(idProj, 'LATITUDE_MIN', 30)
s = oT -> DoSetProperty(idProj, 'LATITUDE_MAX', 70)
s = oT -> DoSetProperty(idProj, 'LONGITUDE_MIN', -20)
s = oT -> DoSetProperty(idProj, 'LONGITUDE_MAX', 40)
s = oT -> DoSetProperty(idProj, 'PROJECTION', 12)
oT -> CommitActions
; Execute the action
success = oT -> DoAction(idProj)
;; Insert new Grid
idInsertGrid = oT -> FindIdentifiers('*Grid', /Operations)
s = oT -> DoAction(idInsertGrid)
; Set back user interface usage.....
oProj->SetProperty, SHOW_EXECUTION_UI=init_val
oT -> ErrorMessage, 'Now we have an Interrupted Goodes projection!'
END
"Christopher Lee" <cl@127.0.0.1> wrote in message
news:20041005.122210.1960709859.25188@buckley.atm.ox.ac.uk.. .
> In article <MPG.1bcae23d7ca75d06989694@news.frii.com>, "David Fanning"
> <david@dfanning.com> wrote:
>
>
> There are shapefile formatted world map data at
>
> http://aprsworld.net/gisdata/world/
>
> IDl has a Shapefile object. How you go from shapefile to continent
> outline is ....a problem for the student. The IDL examples in IDLffShape
> do work sometimes (hint: /UPDATE is wrong if the file is read only)
>
> Chris.
|
|
|
Re: Plotting 'continents' in object graphics... [message #41410 is a reply to message #41124] |
Mon, 25 October 2004 03:40  |
AJ
Messages: 5 Registered: April 2003
|
Junior Member |
|
|
Noop, no idea. I just used these data as it was suggested by a previous
post.
"Andrew Cool" <andrew.cool@dsto.defence.gov.au> wrote in message
news:c6d70400.0410191422.5d40e23e@posting.google.com...
> "AJ" <a@nothing.com> wrote in message
news:<4162c4d2$0$21263$6c56d894@diablo.nl.easynet.net>...
>> You could use the iTools to visualize this. Open a new iMap and then
just
>> open the file using File/Open. The complete high resolution country
>> boundaries will be drawn, which might take a while. Now you can
>> interactivelly adjust all kinds of properties of the different country
>> visualizations and try different projections and limits.
>>
>> Alternativelly you might adjust parameters through code or even read in
the
>> file automatically through code. The code below gives some techniques...
>> should be run in IDL 6.1 and works with the world Shape file found at
>> http://aprsworld.net/gisdata/world/.
>>
>
> Hi AJ,
>
> I've found that the world.shp file from
> http://aprsworld.net/gisdata/world/
> tends to bust iMap in certain situations, whereas the cntry02.shp file
> that
> comes with the IDL distribution,
> C:\RSI\IDL61\resource\maps\shape\cntry02.shp,
> works OK. Apart from the gisdata file being 2MB larger, do you know
> what the difference between the two files is?
>
>
> Andrew
> DSTO, Adelaide, South Australia
|
|
|
Re: Plotting 'continents' in object graphics... [message #41445 is a reply to message #41348] |
Tue, 19 October 2004 15:22  |
andrew.cool
Messages: 47 Registered: July 2003
|
Member |
|
|
"AJ" <a@nothing.com> wrote in message news:<4162c4d2$0$21263$6c56d894@diablo.nl.easynet.net>...
> You could use the iTools to visualize this. Open a new iMap and then just
> open the file using File/Open. The complete high resolution country
> boundaries will be drawn, which might take a while. Now you can
> interactivelly adjust all kinds of properties of the different country
> visualizations and try different projections and limits.
>
> Alternativelly you might adjust parameters through code or even read in the
> file automatically through code. The code below gives some techniques...
> should be run in IDL 6.1 and works with the world Shape file found at
> http://aprsworld.net/gisdata/world/.
>
Hi AJ,
I've found that the world.shp file from
http://aprsworld.net/gisdata/world/
tends to bust iMap in certain situations, whereas the cntry02.shp file
that
comes with the IDL distribution,
C:\RSI\IDL61\resource\maps\shape\cntry02.shp,
works OK. Apart from the gisdata file being 2MB larger, do you know
what the difference between the two files is?
Andrew
DSTO, Adelaide, South Australia
|
|
|