Happy !
hernan / Shapes
About Shapes
Description
Package forked from SqueakSource and SqueakMap to read and view GIS data in ESRI shapefile format (the format used by ESRI's ArcView program).
Adds classes representing ESRI shapefiles. Commonly used types are handled: Polygon, Polyline, Point and MultiPoint shapes. Shape data are read from files and simply kept as-is in ByteArrays in ShapeMap objects. For further processing of shape data, conversion into real objects (Polygon, Arc, Point, etc) might be handier.
Both the name.shp file and the index file (name.shx) are read. To get at the attributes of the shapes, the accompanying name.dbf file needs to be read. This repository includes a dbf-reader.
Installation
Gofer it
smalltalkhubUser: 'hernan' project: 'Shapes';
configuration;
loadStable
Example
| shpE legend url response zipArchive fileRef |
" Download zip file containing shp resources "
url := 'http://dl.dropboxusercontent.com/u/103833630/ne_110m_admin_0_countries.zip' asZnUrl.
(response := ZnEasy get: url ) isSuccess
ifFalse: [ self error: 'Cannot download file' ].
fileRef := FileSystem disk workingDirectory / url pathSegments last.
fileRef writeStreamDo: [ : stream | stream nextPutAll: response contents ].
zipArchive := ZipArchive new.
[ zipArchive
readFrom: fileRef fullName;
extractAllTo: FileSystem workingDirectory ]
ensure: [ zipArchive close ].
fileRef delete.
" Load and display it in Morphic "
shpE := ShapeEnsemble fromFile: 'ne_110m_admin_0_countries.shp'.
shpE attribute: 'CONTINENT'.
legend := ColorLegend mapValuesToRandom: shpE valuesOfCurrentAttribute.
shpE legend: legend.
shpE displayMorphic
