CGSHAPEPOINTFILE
The purpose of this program is to create a shapefile filled with multiple
individual points as entities.
Categories
Mapping, Utilities
Author
FANNING SOFTWARE CONSULTING::
David W. Fanning
1645 Sheely Drive
Fort Collins, CO 80526 USA
Phone: 970-221-0438
E-mail: [email protected]
Coyote's Guide to IDL Programming: http://www.idlcoyote.com
Params
xpts: in, required, type=vector
The X location of the input points. Presumed to be longitude values unless
the `MapCoord` keyword is used, in which case they are assumed to be in
projected meters values that will be converted to longitude values for
storage in the shapefile.
ypts: in, required, type=vector
The Y location of the input points. Presumed to be latitude values unless
the `MapCoord` keyword is used, in which case they are assumed to be in
projected meters values that will be converted to latitude values for
storage in the shapefile.
Keywords
append: in, optional, type=boolean, default=0
Set this keyword to append the points to a currently existing file. Otherwise,
a new file is created.
attributes: in, optional, type=structure
An array or scalar of "attribute" structures. If an array, it must be the same length as
in input data points. If not provided is will consist of the follow structure: {point:indexValue}.
If appending to a file, it must be defined in exactly the same way as the original file attributes.
filename: in, optional, type=string
The name of the shapefile. If not provided, the user will be asked to select a shape
file. If the file currently exists, it will be written over.
mapcoord: in, optional, type=object
A MapCoord object (e.g., cgMap) which will be used to convert the input points from
projected meter space to lat/lon space prior to saving the data in the shapefile.
Examples
Add two cities to a shapefile::
num = 2
x = FltArr(num)
y = FltArr(num)
attr = Replicate({namedStruct, state:"", city:""}, num)
x[0] = -104.87270
y[0] = 39.768040
attr[0] ={namedStruct, 'CO', 'DENVER'}
x[1] = -105.1
y[1] = 40.6
attr[1] ={nameStruct, 'CO', 'FORT COLLINS'}
cgShapePointFile, x, y, ATTRIBUTES=attr, FILENAME='test.shp'
Add two more cities to the same shapefile::
num = 2
x = FltArr(num)
y = FltArr(num)
attr = Replicate({namedStruct, state:"", city:""}, num)
x[0] = -122.7
y[0] = 45.5
attr[0] ={namedStruct, 'OR', 'Portland'}
x[1] = -122.3
y[1] = 47.6
attr[1] ={namedStruct, 'WA', 'Seattle'}
cgShapePointFile, x, y, ATTRIBUTES=attr, FILENAME='test.shp', /APPEND
View the file you just created::
cgShapeInfo, 'test.shp'
History
Modification History
Written by David W. Fanning, 23 August 2012.
Copyright
Copyright (c) 2012, Fanning Software Consulting, Inc.