|
From: <efr...@me...> - 2007-12-11 22:57:49
|
Arlindo,
> Efren,
>
> I am back from vacation. I read quickly the ESRI white paper that
> describes the shapefile format. What an awkward format! SVG appears a
> much more elegant approach to vector graphics. In any event, here are
> my thoughts on how to produce shapefiles from within GrADS:
>
> 0) I would produce shapefiles associated with 2D lat-lon "naked
> plots", that is, those without maps, frames or fonts. Anything else
> may not make much sense. (Since GrADS draws its own characters, fonts
> could encoded as polylines but they would be deformed if a map
> transformation is later applied.)
>
> 1) GrADS vector graphics includes both POLYLINES and POLYGON type of
> shapes. Since one can only have one type of shape per shapefile, a
> given image (say contour lines on top of shaded contours) would have 2
> separate shapefiles associated with it: one with POLYGONS, another
> with POLYLINE objects, for a total of 6 files if you factor in the
> .shp, .shx and .dbx subfiles. This is ugly.
>
> 2) There is an annoying requirement on the enconding of polygons: one
> must order the vertices so that the "inside" is to the right of the
> path, something that should have been handled by the renderer. I
> believe cairo provides functions to determine whether a point is
> inside or outside a closed path, so I may be able to use it.
>
> 3) Each polygon object would have a single part so as to avoid dealing
> with similar vertex ordering issues.
>
> 4) Now, each POLYLINE or POLYGON object will have a color associated
> with it. I am hoping one could save the (r,g,b) values in the
> associated .dbx file, but I am not sure what are the conventions for
> encoding this.
>
> 5) In the case of shaded contours, I am not sure how to encode the
> color bar (mapping of (r,g,b) into field values).
>
When you create the shape, assign attributes like so:
my $shapefile = new Geo::Shapelib {
Name => "path to shapefile",
Shapetype => POINT,
FieldNames => ['ID','Red','Green','Blue',],
FieldTypes => ['Integer','Integer','Integer','Integer',],
};
and assign values like this:
push @{$shapefile->{Shapes}},{ Vertices => [[$x,$y,0,0]] };
push @{$shapefile->{ShapeRecords}},[$ID,$Red,$Green,$Blue];
> With all these caveats, would GrADS produced shapefiles still be of
> any interest? I believe Brian has looked into this as well, I'm cc'ing
> him as he may not be subscribed to this list.
>
Absolutely! Let me know where I can help. Thanks.
> Brian: for reference, here is the thread:
>
>
http://sourceforge.net/mailarchive/forum.php?thread_name=77fcd6b20711251803j746a965j689063db5d6e4da8%40mail.gmail.com&forum_name=opengrads-devel
>
> Arlindo
>
> --
> Arlindo da Silva
> da...@al...
>
----------------------------------------------------------------------
This is a PRIVATE message. If you are not the intended recipient,
please delete without copying and kindly advise us by e-mail of the
mistake in delivery.
|