Documentation ¶
Overview ¶
Package shapefile reads ESRI Shapefiles.
Index ¶
- func NoData(x float64) bool
- func TrimTrailingZeros(data []byte) []byte
- type CPG
- type DBF
- type DBFFieldDescriptor
- type DBFHeader
- type DBFMemo
- type DBFRecord
- type PRJ
- type ReadDBFOptions
- type ReadSHPOptions
- type ReadShapefileOptions
- type SHP
- type SHPRecord
- type SHX
- type SHXRecord
- type SHxHeader
- type Scanner
- func NewScanner(readers map[string]io.ReadCloser, sizes map[string]int64, ...) (*Scanner, error)
- func NewScannerFromBasename(basename string, options *ReadShapefileOptions) (*Scanner, error)
- func NewScannerFromZipFile(name string, options *ReadShapefileOptions) (*Scanner, error)
- func NewScannerFromZipReader(zipReader *zip.Reader, options *ReadShapefileOptions) (*Scanner, error)
- func (s *Scanner) Charset() string
- func (s *Scanner) Close() error
- func (s *Scanner) DBFFieldDescriptors() []*DBFFieldDescriptor
- func (s *Scanner) DBFHeader() *DBFHeader
- func (s *Scanner) Discard(n int) (int, error)
- func (s *Scanner) Error() error
- func (s *Scanner) EstimatedRecords() int64
- func (s *Scanner) Next() bool
- func (s *Scanner) Projection() string
- func (s *Scanner) SHPHeader() *SHxHeader
- func (s *Scanner) SHxHeader() *SHxHeader
- func (s *Scanner) Scan() (recordSHP *SHPRecord, recordSHX *SHXRecord, recordDBF DBFRecord)
- func (s *Scanner) ScannedRecords() int64
- type ScannerDBF
- type ScannerSHP
- type ScannerSHX
- type ShapeType
- type Shapefile
- func Read(basename string, options *ReadShapefileOptions) (*Shapefile, error)
- func ReadFS(fsys fs.FS, basename string, options *ReadShapefileOptions) (*Shapefile, error)
- func ReadScanner(scanner *Scanner) (*Shapefile, error)
- func ReadZipFile(name string, options *ReadShapefileOptions) (*Shapefile, error)
- func ReadZipReader(zipReader *zip.Reader, options *ReadShapefileOptions) (*Shapefile, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func TrimTrailingZeros ¶
TrimTrailingZeros trims any trailing zero bytes from data.
Types ¶
type CPG ¶
type CPG struct {
Charset string
}
CPG a CPG is a .cpg file.
type DBF ¶
type DBF struct { DBFHeader FieldDescriptors []*DBFFieldDescriptor Records [][]any }
A DBF is a dBase III PLUS table.
See http://web.archive.org/web/20150323061445/http://ulisse.elettra.trieste.it/services/doc/dbase/DBFstruct.htm. See https://www.clicketyclick.dk/databases/xbase/format/dbf.html.
func ReadDBFZipFile ¶
func ReadDBFZipFile(zipFile *zip.File, options *ReadDBFOptions) (*DBF, error)
ReadDBFZipFile reads a DBF from a *zip.File.
type DBFFieldDescriptor ¶
type DBFFieldDescriptor struct { Name string Type byte Length int DecimalCount int WorkAreaID byte SetFields byte }
A DBFFieldDescriptor describes a DBF field.
func (*DBFFieldDescriptor) ParseRecord ¶
ParseRecord parses a record from data.
type DBFHeader ¶
type DBFHeader struct { Version int Memo bool DBT bool LastUpdate time.Time Records int HeaderSize int RecordSize int }
A DBFHeader is a DBF header.
func ParseDBFHeader ¶
func ParseDBFHeader(data []byte, options *ReadDBFOptions) (*DBFHeader, error)
ParseDBFHeader parses a DBFHeader from data.
type PRJ ¶
type PRJ struct {
Projection string
}
A PRJ is a .prj file.
type ReadDBFOptions ¶
ReadDBFOptions are options to ReadDBF.
type ReadSHPOptions ¶
ReadSHPOptions are options for ReadSHP.
type ReadShapefileOptions ¶
type ReadShapefileOptions struct { DBF *ReadDBFOptions SHP *ReadSHPOptions }
ReadShapefileOptions are options to ReadFS.
type SHP ¶
A SHP is a .shp file.
func ReadSHPZipFile ¶
func ReadSHPZipFile(zipFile *zip.File, options *ReadSHPOptions) (*SHP, error)
ReadSHPZipFile reads a *SHP from a *zip.File.
type SHPRecord ¶
type SHPRecord struct { Number int ContentLength int ShapeType ShapeType Bounds *geom.Bounds Geom geom.T }
A SHPRecord is a record in a SHP file.
func ReadSHPRecord ¶
func ReadSHPRecord(r io.Reader, options *ReadSHPOptions) (*SHPRecord, error)
ReadSHPRecord reads the next *SHPRecord from r.
type SHXRecord ¶
An SHXRecord is a record in a SHX.
func ParseSHXRecord ¶
ParseSHXRecord parses a SHXRecord from data.
type SHxHeader ¶
type SHxHeader struct { ShapeType ShapeType Bounds *geom.Bounds }
A SHxHeader is header of a .shp or .shx file.
type Scanner ¶
type Scanner struct {
// contains filtered or unexported fields
}
Scanner ...
func NewScanner ¶
func NewScanner( readers map[string]io.ReadCloser, sizes map[string]int64, options *ReadShapefileOptions, ) (*Scanner, error)
NewScanner Create a new scanner.
func NewScannerFromBasename ¶
func NewScannerFromBasename(basename string, options *ReadShapefileOptions) (*Scanner, error)
NewScannerFromBasename reads files based of Basename and create a scanner.
func NewScannerFromZipFile ¶
func NewScannerFromZipFile(name string, options *ReadShapefileOptions) (*Scanner, error)
NewScannerFromZipFile reads a .zip file and create a scanner.
func NewScannerFromZipReader ¶
func NewScannerFromZipReader(zipReader *zip.Reader, options *ReadShapefileOptions) (*Scanner, error)
NewScannerFromZipReader reads a *zip.Reader and create a scanner.
func (*Scanner) DBFFieldDescriptors ¶
func (s *Scanner) DBFFieldDescriptors() []*DBFFieldDescriptor
func (*Scanner) EstimatedRecords ¶
func (*Scanner) Projection ¶
func (*Scanner) ScannedRecords ¶
type ScannerDBF ¶
type ScannerDBF struct {
// contains filtered or unexported fields
}
func NewScannerDBF ¶
func NewScannerDBF(reader io.ReadCloser, options *ReadDBFOptions) (*ScannerDBF, error)
func (*ScannerDBF) FieldDescriptors ¶
func (s *ScannerDBF) FieldDescriptors() []*DBFFieldDescriptor
func (*ScannerDBF) Scan ¶
func (s *ScannerDBF) Scan() (DBFRecord, error)
type ScannerSHP ¶
type ScannerSHP struct {
// contains filtered or unexported fields
}
func NewScannerSHP ¶
func NewScannerSHP(reader io.ReadCloser, size int64, options *ReadSHPOptions) (*ScannerSHP, error)
func (*ScannerSHP) Scan ¶
func (s *ScannerSHP) Scan() (*SHPRecord, error)
type ScannerSHX ¶
type ScannerSHX struct {
// contains filtered or unexported fields
}
func NewScannerSHX ¶
func NewScannerSHX(reader io.ReadCloser, size int64) (*ScannerSHX, error)
func (*ScannerSHX) Scan ¶
func (s *ScannerSHX) Scan() (*SHXRecord, error)
type ShapeType ¶
type ShapeType uint
A ShapeType is a shape type.
const ( ShapeTypeNull ShapeType = 0 ShapeTypePoint ShapeType = 1 ShapeTypePolyLine ShapeType = 3 ShapeTypePolygon ShapeType = 5 ShapeTypeMultiPoint ShapeType = 8 ShapeTypePointZ ShapeType = 11 ShapeTypePolyLineZ ShapeType = 13 ShapeTypePolygonZ ShapeType = 15 ShapeTypeMultiPointZ ShapeType = 18 ShapeTypePointM ShapeType = 21 ShapeTypePolyLineM ShapeType = 23 ShapeTypePolygonM ShapeType = 25 ShapeTypeMultiPointM ShapeType = 28 ShapeTypeMultiPatch ShapeType = 31 )
Shape types.
type Shapefile ¶
A Shapefile is an ESRI Shapefile.
func Read ¶
func Read(basename string, options *ReadShapefileOptions) (*Shapefile, error)
Read reads a Shapefile from basename.
func ReadScanner ¶
ReadScanner read a scanner and create a shapefile.
func ReadZipFile ¶
func ReadZipFile(name string, options *ReadShapefileOptions) (*Shapefile, error)
ReadZipFile reads a Shapefile from a .zip file.
func ReadZipReader ¶
func ReadZipReader(zipReader *zip.Reader, options *ReadShapefileOptions) (*Shapefile, error)
ReadZipReader reads a Shapefile from a *zip.Reader.
func (*Shapefile) NumRecords ¶
NumRecords returns the number of records in s.