Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re^3: Geo::Shapefile::Writer help

by tangent (Parson)
on Jan 28, 2016 at 20:31 UTC ( [id://1153925]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Geo::Shapefile::Writer help
in thread Geo::Shapefile::Writer help

If just one array of (x1,y1,x2,y2...) the easiest way would be to use List::Util
use List::Util qw(pairmap); my @coords = (86.925, 27.988, 86.5278, 27.744, 86.43, 27.365); my @pairs = pairmap { [ $a, $b ] } @coords; $shp_writer->add_shape( \@pairs, @attributes );

Replies are listed 'Best First'.
Re^4: Geo::Shapefile::Writer help
by kjslover (Initiate) on Jan 29, 2016 at 14:58 UTC

    tangent, thank you, that makes perfect sense. I have tried the following code and am now getting an error regarding "Can't use string ("0") as an ARRAY ref while "strict refs" in use at <path to writer.pm> line 141". I have tried adding the use strict; and declaring $x/$y/$dummy, but did not help.
    The following code is what I am using to try to get it to work:

    use Geo::Shapefile::Writer; use List::Util qw(pairmap); $shape = Geo::Shapefile::Writer->new("Temp", 'POLYGON', [COL1 => 'C', +10],); my @coords = (0, 0, 0, 1, 1, 1, 1, 0, 0, 0); my @pairs = pairmap { [ $a, $b ] } @coords; # Checking to make sure pairs look correct foreach $dummy (@pairs) { ($x, $y) = @$dummy; print "$x, $y\n"; } $shape->add_shape(\@pairs, {Col1 => "Dumb1"}); $shape->finalize();

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1153925]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (2)
As of 2024-04-19 01:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found