Documentation ¶
Overview ¶
Package carto is a Go language map drawing library
Index ¶
- func Degrees2meters(lon, lat float64) (x, y float64)
- func DrawShapes(f io.Writer, strokeColor, fillColor []color.NRGBA, ...) error
- func GetGoogleTileBounds(zoom, x, y int) (N, S, E, W float64)
- type Canvas
- type ColorMap
- func (c *ColorMap) AddArray(data []float64)
- func (c *ColorMap) AddArrayServer(datachan chan []float64, finished chan int)
- func (c *ColorMap) AddGeoJSON(g *GeoJSON, propertyName string)
- func (c *ColorMap) AddMap(data map[string]float64)
- func (cm *ColorMap) GetColor(v float64) color.NRGBA
- func (c *ColorMap) Legend(canvas *draw.Canvas, label string) (err error)
- func (c *ColorMap) Set()
- type ColorMapType
- type Colorlist
- type Crs
- type CrsProps
- type DefaultLegendCanvas
- type GeoJSON
- type GeoJSONfeature
- type MapData
- type RasterMap
- type UnsupportedGeometryError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Degrees2meters ¶
convert from long/lat to google mercator (or EPSG:4326 to EPSG:900913)
func DrawShapes ¶
func DrawShapes(f io.Writer, strokeColor, fillColor []color.NRGBA, linewidth, markersize vg.Length, shapes ...geom.Geom) error
Convenience function for making a simple map.
func GetGoogleTileBounds ¶
Types ¶
type Canvas ¶
type Canvas struct { draw.Canvas Bounds *geom.Bounds // geographic boundaries of map Polygon geom.Polygon // contains filtered or unexported fields }
Canvas is a canvas for drawing maps.
func (*Canvas) Coordinates ¶
Coordinates transforms geographic coordinates to coordinates on the canvas.
func (*Canvas) DrawVector ¶
func (m *Canvas) DrawVector(g geom.Geom, fillColor color.NRGBA, lineStyle draw.LineStyle, markerGlyph draw.GlyphStyle) error
Draw a vector on a raster map when given the geometry, stroke and fill colors, the width of the bounding line, and the markerGlyph, which specifies the shape of the marker (only used for point shapes).
type ColorMap ¶
type ColorMap struct { draw.Canvas Type ColorMapType CutPercentile float64 // Percentile at which discontinuity occurs for "LinCutoff" type. NumDivisions int // "Number of tick marks on legend. LegendWidth vg.Length // width of legend in inches LegendHeight vg.Length // height of legend in inches LineWidth vg.Length // width of lines in legend in points FontSize vg.Length // font size in points. GradientLineWidth vg.Length // Width of lines that make up legend gradient Font string // Name of the font to use in legend FontColor color.Color EdgeColor color.Color // Color for legend outline BackgroundColor color.Color ColorScheme Colorlist // contains filtered or unexported fields }
func (*ColorMap) AddArrayServer ¶
func (*ColorMap) AddGeoJSON ¶
type ColorMapType ¶
type ColorMapType int
const ( Linear ColorMapType = iota // Linear color gradient LinCutoff // linear with a discontinuity at a percentile )
type Colorlist ¶
var ( // optimized olors from http://www.cs.unm.edu/~kmorel/documents/ColorMaps/index.html // Originally the 255 values were 221's Optimized Colorlist = Colorlist{ []float64{-1., -0.9375, -0.875, -0.8125, -0.75, -0.6875, -0.625, -0.5625, -0.5, -0.4375, -0.375, -0.3125, -0.25, -0.1875, -0.125, -0.0625, 0., 0.0625, 0.125, 0.1875, 0.25, 0.3125, 0.375, 0.4375, 0.5, 0.5625, 0.625, 0.6875, 0.75, 0.8125, 0.875, 0.9375, 1.}, []float64{59., 68, 77, 87, 98, 108, 119, 130, 141, 152, 163, 174, 184, 194, 204, 213, 255, 229, 236, 241, 245, 247, 247, 247, 244, 241, 236, 229, 222, 213, 203, 192, 180}, []float64{76., 90, 104, 117, 130, 142, 154, 165, 176, 185, 194, 201, 208, 213, 217, 219, 255, 216, 211, 204, 196, 187, 177, 166, 154, 141, 127, 112, 96, 80, 62, 40, 4}, []float64{192., 204, 215, 225, 234, 241, 247, 251, 254, 255, 255, 253, 249, 244, 238, 230, 255, 209, 197, 185, 173, 160, 148, 135, 123, 111, 99, 88, 77, 66, 56, 47, 38}, color.NRGBA{70., 6, 16, 255}, color.NRGBA{27., 34, 85, 255}} OptimizedGrey Colorlist = Colorlist{ []float64{-1., -0.9375, -0.875, -0.8125, -0.75, -0.6875, -0.625, -0.5625, -0.5, -0.4375, -0.375, -0.3125, -0.25, -0.1875, -0.125, -0.0625, 0., 0.0625, 0.125, 0.1875, 0.25, 0.3125, 0.375, 0.4375, 0.5, 0.5625, 0.625, 0.6875, 0.75, 0.8125, 0.875, 0.9375, 1.}, []float64{59., 68, 77, 87, 98, 108, 119, 130, 141, 152, 163, 174, 184, 194, 204, 213, 221, 229, 236, 241, 245, 247, 247, 247, 244, 241, 236, 229, 222, 213, 203, 192, 180}, []float64{76., 90, 104, 117, 130, 142, 154, 165, 176, 185, 194, 201, 208, 213, 217, 219, 221, 216, 211, 204, 196, 187, 177, 166, 154, 141, 127, 112, 96, 80, 62, 40, 4}, []float64{192., 204, 215, 225, 234, 241, 247, 251, 254, 255, 255, 253, 249, 244, 238, 230, 221, 209, 197, 185, 173, 160, 148, 135, 123, 111, 99, 88, 77, 66, 56, 47, 38}, color.NRGBA{70., 6, 16, 255}, color.NRGBA{27., 34, 85, 255}} Jet Colorlist = Colorlist{ []float64{-1, -0.866666666666667, -0.733333333333333, -0.6, -0.466666666666667, -0.333333333333333, -0.2, -0.0666666666666668, 0.0666666666666665, 0.2, 0.333333333333333, 0.466666666666666, 0.6, 0.733333333333333, 0.866666666666666, 1}, []float64{0, 0, 0, 0, 0, 0, 66, 132, 189, 255, 255, 255, 255, 255, 189, 132}, []float64{0, 0, 66, 132, 189, 255, 255, 255, 255, 255, 189, 132, 66, 0, 0, 0}, []float64{189, 255, 255, 255, 255, 255, 189, 132, 66, 0, 0, 0, 0, 0, 0, 0}, color.NRGBA{249., 15, 225, 255}, color.NRGBA{154., 0, 171, 255}} JetPosOnly Colorlist = Colorlist{ []float64{-1, 0, 0.0666666666666667, 0.133333333333333, 0.2, 0.266666666666667, 0.333333333333333, 0.4, 0.466666666666667, 0.533333333333333, 0.6, 0.666666666666667, 0.733333333333333, 0.8, 0.866666666666667, 0.933333333333333, 1}, []float64{0, 0, 0, 0, 0, 0, 0, 66, 132, 189, 255, 255, 255, 255, 255, 189, 132}, []float64{0, 0, 0, 66, 132, 189, 255, 255, 255, 255, 255, 189, 132, 66, 0, 0, 0}, []float64{189, 189, 255, 255, 255, 255, 255, 189, 132, 66, 0, 0, 0, 0, 0, 0, 0}, color.NRGBA{249., 15, 225, 255}, color.NRGBA{154., 0, 171, 255}} )
type CrsProps ¶
type CrsProps struct {
Name string `json:"name"`
}
Coordinate reference system properties.
type DefaultLegendCanvas ¶
DefaultLegendCanvas is a default canvas for drawing legends.
func NewDefaultLegendCanvas ¶
func NewDefaultLegendCanvas() *DefaultLegendCanvas
type GeoJSON ¶
type GeoJSON struct { Type string `json:"type"` CRS Crs `json:"crs"` Features []*GeoJSONfeature `json:"features"` }
func (*GeoJSON) GetProperty ¶
type GeoJSONfeature ¶
type MapData ¶
type MapData struct { Cmap *ColorMap Shapes []geom.Geom Data []float64 DrawEdges bool draw.LineStyle }
func NewMapData ¶
func NewMapData(numShapes int, Type ColorMapType) *MapData
type RasterMap ¶
func NewCanvasFromRaster ¶
func NewCanvasFromRaster(S, W, dy, dx float64, ny, nx int, data []float64, cmap *ColorMap, flipVertical, flipHorizontal bool) *RasterMap
Make a new raster map from raster data. It is assumed that the outer axis in the data is the Y-axis (north-south) and the inner axis is the X-axis (west-east) (i.e., len(data)==nx*ny && val[j,i] = data[j*nx+i]).
func NewRasterMap ¶
type UnsupportedGeometryError ¶
func (UnsupportedGeometryError) Error ¶
func (e UnsupportedGeometryError) Error() string