Last active
January 11, 2017 09:08
-
-
Save SergeStinckwich/d26af371b4fe0c7ff08d to your computer and use it in GitHub Desktop.
ESRI shapefiles rendering with Pharo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Need I to actualice something before running this code? ShapeEnsemble, ColorLegend, mapValuesToRandom and valuesOfCurrentAttribute and displayMorphic are in red.