comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Plotting 'continents' in object graphics...
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Plotting 'continents' in object graphics... [message #41348 is a reply to message #41249] Tue, 05 October 2004 08:19 Go to previous messageGo to previous message
AJ is currently offline  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.
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Optimisation in IDL?
Next Topic: Re: RESOLVE_ROUTINE in the .sav file

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 19:15:23 PDT 2025

Total time taken to generate the page: 0.00407 seconds