Skip to content

Instantly share code, notes, and snippets.

@SergeStinckwich
Last active January 11, 2017 09:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SergeStinckwich/d26af371b4fe0c7ff08d to your computer and use it in GitHub Desktop.
Save SergeStinckwich/d26af371b4fe0c7ff08d to your computer and use it in GitHub Desktop.
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