Geo::Shapefile::Writer - simple pureperl shapefile writer
version 0.004
my $shp_writer = Geo::Shapefile::Writer->new( 'summits', 'POINT', [ name => 'C', 100 ], [ elevation => 'N', 8, 0 ], ); $shp_writer->add_shape( [86.925278, 27.988056], 'Everest', 8848 ); $shp_writer->add_shape( [42.436944, 43.353056], { name => 'Elbrus', elevation => 5642 } ); $shp_writer->finalize();
Geo::Shapelib is cool, but not portable.
So here is an alternative, if you need just simple shp export.
my $shp_writer = Geo::Shapefile::Writer->new( $name, $type, @attr_descriptions );
Create object and 3 associated files.
Possible types: POINT, POLYLINE, POLYGON (more to be implemented).
Possible attribute description formats:
* scalar - just field name * arrayref - [ $name, $type, $length, $decimals ] * hashref - { name => $name, type => 'N', length => 8, decimals => 0 } - CAM::DBF-compatible
Default C(64) will be used if field is not completely described
$shp_writer->add_shape( $shape, @attributes );
$shape depends on file type:
* point: [$x,$y] * polyline or polygon: [ [[$x0,$y0], ...], \@part2, ... ]
Attributes are array or arrayref: [$val1, $val2, ...] or hashref: { $name1 => $val1, ...}
$shp_writer->finalize();
Update global fields, close files
liosha <liosha@cpan.org>
This software is copyright (c) 2012 by liosha.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Geo::Shapefile::Writer, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Geo::Shapefile::Writer
CPAN shell
perl -MCPAN -e shell install Geo::Shapefile::Writer
For more information on module installation, please visit the detailed CPAN module installation guide.