Re: ESRI shape file [message #88863 is a reply to message #72340] |
Sun, 29 June 2014 14:43   |
ca11h
Messages: 3 Registered: June 2014
|
Junior Member |
|
|
Hi Klemen! I know this post is years old but I'm a student helping one of the researchers out at my school as he's hired me to do some IDL work...and well I've landed here searching for help.
If you get this I'd appreciate that polygon shapefile example you mentioned. I have a binary mask with many polygons and I need to turn it into a shapefile, and there's absolutely no resources helping me out online, save for possibly this post. If you could post that example or give me any advice at all I'd really appreciate it!
On Saturday, August 28, 2010 7:31:17 AM UTC-4, Klemen 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
|
|
|