Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
ESRI shapefiles rendering with Pharo
| shpE legend url response zipArchive fileRef |
Gofer new
url: 'http://smalltalkhub.com/mc/hernan/Shapes/main';
package: 'ConfigurationOfShapes';
load.
((Smalltalk at: #ConfigurationOfShapes) project version: '1.2') load.
" 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
@offray
Copy link

offray commented Oct 1, 2014

Need I to actualice something before running this code? ShapeEnsemble, ColorLegend, mapValuesToRandom and valuesOfCurrentAttribute and displayMorphic are in red.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment