Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
ESRI shapefiles rendering with Pharo
| shpE legend url response zipArchive fileRef |
Gofer new
url: '';
package: 'ConfigurationOfShapes';
((Smalltalk at: #ConfigurationOfShapes) project version: '1.2') load.
" Download zip file containing shp resources "
url := '' 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.
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