Re: ESRI shape file [message #72332 is a reply to message #25781] |
Mon, 30 August 2010 03:05   |
d.poreh
Messages: 406 Registered: October 2007
|
Senior Member |
|
|
On Aug 28, 4:31 am, Klemen <klemen.zak...@gmail.com> wrote:
> There is an example of creating a point shape file in Help as Max said
> (see below). Creating a polygon is sligtly more difficult; if you need
> such an example let me know.
> Cheers, Klemen
>
> PRO ex_shapefile_newfile
>
> ;Create the new shapefile and define the entity type to Point
> mynewshape=OBJ_NEW('IDLffShape', FILEPATH('cities.shp', $
> SUBDIR=['examples', 'data']), /UPDATE, ENTITY_TYPE=1)
>
> ;Set the attribute definitions for the new Shapefile
> mynewshape->AddAttribute, 'CITY_NAME', 7, 25, $
> PRECISION=0
> mynewshape->AddAttribute, 'STAT_NAME', 7, 25, $
> PRECISION=0
>
> ;Create structure for new entity
> entNew = {IDL_SHAPE_ENTITY}
>
> ; Define the values for the new entity
> entNew.SHAPE_TYPE = 1
> entNew.BOUNDS[0] = -104.87270
> entNew.BOUNDS[1] = 39.768040
> entNew.BOUNDS[2] = 0.00000000
> entNew.BOUNDS[3] = 0.00000000
> entNew.BOUNDS[4] = -104.87270
> entNew.BOUNDS[5] = 39.768040
> entNew.BOUNDS[6] = 0.00000000
> entNew.BOUNDS[7] = 0.00000000
> entNew.N_VERTICES = 1 ; take out of example, need as workaround
>
> ;Create structure for new attributes
> attrNew = mynewshape ->GetAttributes(/ATTRIBUTE_STRUCTURE)
>
> ;Define the values for the new attributes
> attrNew.ATTRIBUTE_0 = 'Denver'
> attrNew.ATTRIBUTE_1 = 'Colorado'
>
> ;Add the new entity to new shapefile
> mynewshape -> PutEntity, entNew
>
> ;Note that because this is a new shapefile, the index of
> ;the new entity is zero.
> entity_index=0
>
> ;Add the Colorado attributes to new shapefile.
> mynewshape -> SetAttributes, entity_index, attrNew
>
> ;Close the shapefile
> OBJ_DESTROY, mynewshape
>
> END
thanks. it works perfect.
Cheers,
Dave
@ Dear Klemen. Thanks I jut want to create a point point shape file.
|
|
|