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

Home » Public Forums » archive » Re: write array 2 *.shp file
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: write array 2 *.shp file [message #61673] Mon, 28 July 2008 10:58 Go to next message
d.poreh is currently offline  d.poreh
Messages: 406
Registered: October 2007
Senior Member
On 28 Jul., 10:48, David Fanning <n...@dfanning.com> wrote:
> d.po...@gmail.com writes:
>> My data is point and A is the coordinate array. I just want to put
>> this coordinate (lat&lon) in the shape file. In the help (?idlffshape)
>> as you can see it put the data in the BOUNDS fields.
>
> Let me see if I understand this. You want to put a single
> point in a shape file!? May I ask why? What would be the,
> uh, point of that?
>
> Cheers,
>
> David
> --
> David Fanning, Ph.D.
> Fanning Software Consulting, Inc.
> Coyote's Guide to IDL Programming:http://www.dfanning.com/
> Sepore ma de ni thui. ("Perhaps thou speakest truth.")

No i have an array like this:
A[lat,lon]. just want to put this coordinate in the shape file (maybe
1000 point(with lat&lon))
Cheers
Re: write array 2 *.shp file [message #61674 is a reply to message #61673] Mon, 28 July 2008 10:53 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
d.poreh@gmail.com writes:

> yes my data is point coordinate (entity type to be "Point")

Uh, huh. And you want ONE point in the file?

Cheers,

David


--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: write array 2 *.shp file [message #61675 is a reply to message #61674] Mon, 28 July 2008 10:52 Go to previous messageGo to next message
d.poreh is currently offline  d.poreh
Messages: 406
Registered: October 2007
Senior Member
On 28 Jul., 10:48, David Fanning <n...@dfanning.com> wrote:
> d.po...@gmail.com writes:
>> My data is point and A is the coordinate array. I just want to put
>> this coordinate (lat&lon) in the shape file. In the help (?idlffshape)
>> as you can see it put the data in the BOUNDS fields.
>
> Let me see if I understand this. You want to put a single
> point in a shape file!? May I ask why? What would be the,
> uh, point of that?
>
> Cheers,
>
> David
> --
> David Fanning, Ph.D.
> Fanning Software Consulting, Inc.
> Coyote's Guide to IDL Programming:http://www.dfanning.com/
> Sepore ma de ni thui. ("Perhaps thou speakest truth.")

yes my data is point coordinate (entity type to be "Point")
Cheers
Re: write array 2 *.shp file [message #61676 is a reply to message #61675] Mon, 28 July 2008 10:48 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
d.poreh@gmail.com writes:

> My data is point and A is the coordinate array. I just want to put
> this coordinate (lat&lon) in the shape file. In the help (?idlffshape)
> as you can see it put the data in the BOUNDS fields.

Let me see if I understand this. You want to put a single
point in a shape file!? May I ask why? What would be the,
uh, point of that?

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: write array 2 *.shp file [message #61677 is a reply to message #61676] Mon, 28 July 2008 10:46 Go to previous messageGo to next message
d.poreh is currently offline  d.poreh
Messages: 406
Registered: October 2007
Senior Member
On 28 Jul., 10:25, David Fanning <n...@dfanning.com> wrote:
> d.po...@gmail.com writes:
>>    ;Create structure for new entity
>
>> entnew=3Dreplicate({IDL_SHAPE_ENTITY},N[2])
>
>> for J=3D0,N[2]-1 do begin
>
>> ; Define the values for the new entity
>> entnew[j].SHAPE_TYPE =3D 1
>> entnew[j].ISHAPE =3D 1470
>> entnew[j].BOUNDS[0]=3D(A[0,j])
>> entnew[j].BOUNDS[1]=3D(A[1,j])
>> entnew[j].BOUNDS[2]=3D0.00000000
>> entnew[j].BOUNDS[4]=3D(A[0,j])
>> entnew[j].BOUNDS[5]=3D(A[1,j])
>> entnew[j].BOUNDS[6]=3D0.00000000
>> entnew[j].BOUNDS[7]=3D0.00000000
>> entnew[j].N_VERTICES =3D 1
>
>> attrNew =3D mynewshape ->GetAttributes(/ATTRIBUTE_STRUCTURE)
>> mynewshape -> PutEntity,entnew[j]
>
>> mynewshape -> SetAttributes, 0, attrNew
>> endfor
>> ;;;;;;;;;;;;;;;;;;;;;;;;;;
>> But still no result
>
> I don't think you are thinking this through all the way. :-)
>
> I can't tell what A is, but I would expect it to be a
> pointer array to polygons of various lengths. In other
> words, these are the shapes you are trying to put into
> the file. But, in any case, you are not even storing the
> vertices of *anything* in this file. In other words, at
> the very least you have to set:
>
>     entnew[j].VERTICES = a_polygon_of_some_sort
>
> You have nothing like that there. What do you have
> in A? Where are your polygons that you are trying
> to put into the shapefile? What do you think the
> BOUNDS fields should be set to? What values? What
> are you putting in there?
>
> Too may open questions here to expect much success yet.
>
> Cheers,
>
> David
>
> --
> David Fanning, Ph.D.
> Fanning Software Consulting, Inc.
> Coyote's Guide to IDL Programming:http://www.dfanning.com/
> Sepore ma de ni thui. ("Perhaps thou speakest truth.")- Zitierten Text ausblenden -
>
> - Zitierten Text anzeigen -

David
My data is point and A is the coordinate array. I just want to put
this coordinate (lat&lon) in the shape file. In the help (?idlffshape)
as you can see it put the data in the BOUNDS fields.
cheers
Re: write array 2 *.shp file [message #61681 is a reply to message #61677] Mon, 28 July 2008 10:25 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
d.poreh@gmail.com writes:

> ;Create structure for new entity
>
> entnew=3Dreplicate({IDL_SHAPE_ENTITY},N[2])
>
> for J=3D0,N[2]-1 do begin
>
>
> ; Define the values for the new entity
> entnew[j].SHAPE_TYPE =3D 1
> entnew[j].ISHAPE =3D 1470
> entnew[j].BOUNDS[0]=3D(A[0,j])
> entnew[j].BOUNDS[1]=3D(A[1,j])
> entnew[j].BOUNDS[2]=3D0.00000000
> entnew[j].BOUNDS[4]=3D(A[0,j])
> entnew[j].BOUNDS[5]=3D(A[1,j])
> entnew[j].BOUNDS[6]=3D0.00000000
> entnew[j].BOUNDS[7]=3D0.00000000
> entnew[j].N_VERTICES =3D 1
>
>
> attrNew =3D mynewshape ->GetAttributes(/ATTRIBUTE_STRUCTURE)
> mynewshape -> PutEntity,entnew[j]
>
> mynewshape -> SetAttributes, 0, attrNew
> endfor
> ;;;;;;;;;;;;;;;;;;;;;;;;;;
> But still no result

I don't think you are thinking this through all the way. :-)

I can't tell what A is, but I would expect it to be a
pointer array to polygons of various lengths. In other
words, these are the shapes you are trying to put into
the file. But, in any case, you are not even storing the
vertices of *anything* in this file. In other words, at
the very least you have to set:

entnew[j].VERTICES = a_polygon_of_some_sort

You have nothing like that there. What do you have
in A? Where are your polygons that you are trying
to put into the shapefile? What do you think the
BOUNDS fields should be set to? What values? What
are you putting in there?

Too may open questions here to expect much success yet.

Cheers,

David

--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: write array 2 *.shp file [message #61684 is a reply to message #61681] Mon, 28 July 2008 10:00 Go to previous messageGo to next message
d.poreh is currently offline  d.poreh
Messages: 406
Registered: October 2007
Senior Member
On 28 Jul., 07:13, David Fanning <n...@dfanning.com> wrote:
> David Fanning writes:
>> d.po...@gmail.com writes:
>
>>> Here is my code but  I have got just one point in the attribute table:
>>> =2E.......
>>> =2E........
>>> mynewshape=3DOBJ_NEW('IDLffShape',file,/UPDATE, ENTITY_TYPE=3D1)
>
>>> mynewshape->AddAttribute, 'lat', 7, 25, $
>>>    PRECISION=3D0
>>> mynewshape->AddAttribute, 'lon', 7, 25, $
>>>    PRECISION=3D0
>
>>> entNew =3D{IDL_SHAPE_ENTITY}
>>> for J=3D0,N-1 do begin
>>> entNew.SHAPE_TYPE =3D 1
>>> entNew.ISHAPE =3D fix(randomu(10)*10000)
>>> entNew.BOUNDS[0]=3D(A[0,j])
>>> entNew.BOUNDS[1]=3D( A [1,j])
>>> entNew.BOUNDS[2]=3D0.00000000
>>> entNew.BOUNDS[3]=3D0.00000000
>>> entNew.BOUNDS[4]=3D( A [0,j])
>>> entNew.BOUNDS[5]=3D( A [1,j])
>>> entNew.BOUNDS[6]=3D0.00000000
>>> entNew.BOUNDS[7]=3D0.00000000
>>> entNew.N_VERTICES =3D 1
>>> endfor
>
>>> attrNew =3D mynewshape ->GetAttributes(/ATTRIBUTE_STRUCTURE)
>
>>> mynewshape -> PutEntity,entNew
>>> mynewshape -> SetAttributes, 0, attrNew
>
>>> OBJ_DESTROY, mynewshape
>
>> I'm not surprised. I would try adding a loop if
>> you wanted to add others. :-)
>
> Oh, sorry. I didn't read closely enough. You do have
> a loop. But your entNew entity structure is not a part
> of it. It should be. You need to create a new entity
> each time through the loop, and you need to add it
> to the shapefile each time through the loop. Your problem
> is that your loop doesn't emcompass everything you need
> to do in the loop.
>
> You are making one entity and filling that up with different
> stuff over and over, before you save that single entity in
> your file. You want to make MULTIPLE entities and save
> those.
>
> Cheers,
>
> David
> --
> David Fanning, Ph.D.
> Fanning Software Consulting, Inc.
> Coyote's Guide to IDL Programming:http://www.dfanning.com/
> Sepore ma de ni thui. ("Perhaps thou speakest truth.")- Zitierten Text ausblenden -
>
> David
I put multiple structures like this:
……

;Create structure for new entity

entnew=replicate({IDL_SHAPE_ENTITY},N[2])

for J=0,N[2]-1 do begin


; Define the values for the new entity
entnew[j].SHAPE_TYPE = 1
entnew[j].ISHAPE = 1470
entnew[j].BOUNDS[0]=(A[0,j])
entnew[j].BOUNDS[1]=(A[1,j])
entnew[j].BOUNDS[2]=0.00000000
entnew[j].BOUNDS[4]=(A[0,j])
entnew[j].BOUNDS[5]=(A[1,j])
entnew[j].BOUNDS[6]=0.00000000
entnew[j].BOUNDS[7]=0.00000000
entnew[j].N_VERTICES = 1


attrNew = mynewshape ->GetAttributes(/ATTRIBUTE_STRUCTURE)
mynewshape -> PutEntity,entnew[j]

mynewshape -> SetAttributes, 0, attrNew
endfor
;;;;;;;;;;;;;;;;;;;;;;;;;;
But still no result
Cheers
Re: write array 2 *.shp file [message #61691 is a reply to message #61684] Mon, 28 July 2008 07:13 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
David Fanning writes:

> d.poreh@gmail.com writes:
>
>> Here is my code but I have got just one point in the attribute table:
>> =2E.......
>> =2E........
>> mynewshape=3DOBJ_NEW('IDLffShape',file,/UPDATE, ENTITY_TYPE=3D1)
>>
>> mynewshape->AddAttribute, 'lat', 7, 25, $
>> PRECISION=3D0
>> mynewshape->AddAttribute, 'lon', 7, 25, $
>> PRECISION=3D0
>>
>> entNew =3D{IDL_SHAPE_ENTITY}
>> for J=3D0,N-1 do begin
>> entNew.SHAPE_TYPE =3D 1
>> entNew.ISHAPE =3D fix(randomu(10)*10000)
>> entNew.BOUNDS[0]=3D(A[0,j])
>> entNew.BOUNDS[1]=3D( A [1,j])
>> entNew.BOUNDS[2]=3D0.00000000
>> entNew.BOUNDS[3]=3D0.00000000
>> entNew.BOUNDS[4]=3D( A [0,j])
>> entNew.BOUNDS[5]=3D( A [1,j])
>> entNew.BOUNDS[6]=3D0.00000000
>> entNew.BOUNDS[7]=3D0.00000000
>> entNew.N_VERTICES =3D 1
>> endfor
>>
>> attrNew =3D mynewshape ->GetAttributes(/ATTRIBUTE_STRUCTURE)
>>
>> mynewshape -> PutEntity,entNew
>> mynewshape -> SetAttributes, 0, attrNew
>>
>> OBJ_DESTROY, mynewshape
>
> I'm not surprised. I would try adding a loop if
> you wanted to add others. :-)

Oh, sorry. I didn't read closely enough. You do have
a loop. But your entNew entity structure is not a part
of it. It should be. You need to create a new entity
each time through the loop, and you need to add it
to the shapefile each time through the loop. Your problem
is that your loop doesn't emcompass everything you need
to do in the loop.

You are making one entity and filling that up with different
stuff over and over, before you save that single entity in
your file. You want to make MULTIPLE entities and save
those.

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: write array 2 *.shp file [message #61692 is a reply to message #61691] Mon, 28 July 2008 06:52 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
d.poreh@gmail.com writes:

> Here is my code but I have got just one point in the attribute table:
> =2E.......
> =2E........
> mynewshape=3DOBJ_NEW('IDLffShape',file,/UPDATE, ENTITY_TYPE=3D1)
>
> mynewshape->AddAttribute, 'lat', 7, 25, $
> PRECISION=3D0
> mynewshape->AddAttribute, 'lon', 7, 25, $
> PRECISION=3D0
>
> entNew =3D{IDL_SHAPE_ENTITY}
> for J=3D0,N-1 do begin
> entNew.SHAPE_TYPE =3D 1
> entNew.ISHAPE =3D fix(randomu(10)*10000)
> entNew.BOUNDS[0]=3D(A[0,j])
> entNew.BOUNDS[1]=3D( A [1,j])
> entNew.BOUNDS[2]=3D0.00000000
> entNew.BOUNDS[3]=3D0.00000000
> entNew.BOUNDS[4]=3D( A [0,j])
> entNew.BOUNDS[5]=3D( A [1,j])
> entNew.BOUNDS[6]=3D0.00000000
> entNew.BOUNDS[7]=3D0.00000000
> entNew.N_VERTICES =3D 1
> endfor
>
> attrNew =3D mynewshape ->GetAttributes(/ATTRIBUTE_STRUCTURE)
>
> mynewshape -> PutEntity,entNew
> mynewshape -> SetAttributes, 0, attrNew
>
> OBJ_DESTROY, mynewshape

I'm not surprised. I would try adding a loop if
you wanted to add others. :-)

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming (www.dfanning.com)
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: write array 2 *.shp file [message #61693 is a reply to message #61692] Mon, 28 July 2008 06:37 Go to previous messageGo to next message
d.poreh is currently offline  d.poreh
Messages: 406
Registered: October 2007
Senior Member
On 28 Jul., 06:13, David Fanning <n...@dfanning.com> wrote:
> d.po...@gmail.com writes:
>> I have some lat long data (UTM) and I want to write them to *.shp
>> file .
>> Help shows that how we can do this for 1 point but I want to write N
>> entities to that shape file (put an array to shape file). I put one
>> loop but no result  (I cant open it again) .
>
> I've always used the method outlined in the IDL help in a
> loop without problems. There must be something else wrong
> here.
>
> Cheers,
>
> David
> --
> David Fanning, Ph.D.
> Fanning Software Consulting, Inc.
> Coyote's Guide to IDL Programming:http://www.dfanning.com/
> Sepore ma de ni thui. ("Perhaps thou speakest truth.")

David
Here is my code but I have got just one point in the attribute table:
........
.........
mynewshape=OBJ_NEW('IDLffShape',file,/UPDATE, ENTITY_TYPE=1)

mynewshape->AddAttribute, 'lat', 7, 25, $
PRECISION=0
mynewshape->AddAttribute, 'lon', 7, 25, $
PRECISION=0

entNew ={IDL_SHAPE_ENTITY}
for J=0,N-1 do begin
entNew.SHAPE_TYPE = 1
entNew.ISHAPE = fix(randomu(10)*10000)
entNew.BOUNDS[0]=(A[0,j])
entNew.BOUNDS[1]=( A [1,j])
entNew.BOUNDS[2]=0.00000000
entNew.BOUNDS[3]=0.00000000
entNew.BOUNDS[4]=( A [0,j])
entNew.BOUNDS[5]=( A [1,j])
entNew.BOUNDS[6]=0.00000000
entNew.BOUNDS[7]=0.00000000
entNew.N_VERTICES = 1
endfor

attrNew = mynewshape ->GetAttributes(/ATTRIBUTE_STRUCTURE)

mynewshape -> PutEntity,entNew
mynewshape -> SetAttributes, 0, attrNew

OBJ_DESTROY, mynewshape

Cheers
Dave
Re: write array 2 *.shp file [message #61694 is a reply to message #61693] Mon, 28 July 2008 06:13 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
d.poreh@gmail.com writes:

> I have some lat long data (UTM) and I want to write them to *.shp
> file .
> Help shows that how we can do this for 1 point but I want to write N
> entities to that shape file (put an array to shape file). I put one
> loop but no result (I cant open it again) .

I've always used the method outlined in the IDL help in a
loop without problems. There must be something else wrong
here.

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: write array 2 *.shp file [message #61763 is a reply to message #61673] Mon, 28 July 2008 21:46 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
d.poreh@gmail.com writes:

> No i have an array like this:
> A[lat,lon]. just want to put this coordinate in the shape file (maybe
> 1000 point(with lat&lon))

Humm. Well, sorry for the delay getting back to you (out
of town company). If you are just putting points into your
file, then I guess, from what I read, your code should work.
I've never created a file with points before, so I can't help.
But I would say you have done it correctly.

What makes you think it doesn't work?

Cheers,

David

--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Finding the Top Two Most Common Coordinates in a Multi-Dimensional Array
Next Topic: Software Package Free! ... about our Free Software

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

Current Time: Thu Oct 09 09:22:03 PDT 2025

Total time taken to generate the page: 0.42294 seconds