Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pharo-gis/shapes
Smalltalk package to read and view GIS data in ESRI shapefile format
https://github.com/pharo-gis/shapes
esri gis natural-earth-vector pharo pharo-smalltalk shapefile smalltalk
Last synced: 12 days ago
JSON representation
Smalltalk package to read and view GIS data in ESRI shapefile format
- Host: GitHub
- URL: https://github.com/pharo-gis/shapes
- Owner: pharo-GIS
- License: mit
- Created: 2015-03-03T20:00:15.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2024-02-25T17:41:37.000Z (12 months ago)
- Last Synced: 2024-09-25T21:41:14.314Z (5 months ago)
- Topics: esri, gis, natural-earth-vector, pharo, pharo-smalltalk, shapefile, smalltalk
- Language: Smalltalk
- Size: 121 KB
- Stars: 7
- Watchers: 4
- Forks: 1
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Description
Smalltalk package to read and view GIS data in ESRI Shapefile format, [originally written](http://www.squeaksource.com/shapes.html) by Hans Baveco and forked to work with Pharo.
# Installation
```smalltalk
EpMonitor disableDuring: [
Metacello new
onWarningLog;
repository: 'github://pharo-GIS/Shapes/repository';
baseline: 'Shapes';
load ].
```# Usage
You can try it with your own .shp files or download a [sample data set](https://github.com/nvkelso/natural-earth-vector/tree/v5.1.1/) from Natural Earth project using the following example:
```smalltalk
| shpE legend urlRoot urlESRIFilePrefix urlESRIFileShp urlPath response fileRef |" Download Shapefile resources "
urlRoot := 'https://github.com/nvkelso/natural-earth-vector/tree/v5.1.1/110m_cultural/'.
urlESRIFilePrefix := 'ne_110m_populated_places'.
urlESRIFileShp := urlESRIFilePrefix , '.shp'.
urlPath := urlRoot , urlESRIFilePrefix.#('.shx' '.dbf' '.shp' '.cpg' '.prj') do: [ : ext |
ZnClient new
url: (urlPath , ext) asZnUrl;
queryAt: 'raw' put: 'true';
numberOfRetries: 2;
enforceHttpSuccess: true;
downloadTo: urlESRIFilePrefix , ext;
get ]." Load and display it in Morphic "
shpE := ShapeEnsemble fromFile: urlESRIFileShp.
" List data fields "
shpE dataFields inspect.
" List all shape records "
shpE shapeRecords inspect.
" Set the current attribute "
shpE attribute: 'NAME'.legend := ColorLegend mapValuesToRandom: shpE valuesOfCurrentAttribute.
shpE legend: legend.shpE displayMorphic.
```If you already downloaded the files in your Pharo working directory:
```smalltalk
| urlESRIFilePrefix urlESRIFileShp shpE legend |
urlESRIFileShp := FileSystem workingDirectory / 'natural-earth-vector/10m_cultural/ne_10m_admin_0_countries.shp'.
shpE := ShapeEnsemble fromFile: urlESRIFileShp.
shpE attribute: 'CONTINENT'.
legend := ColorLegend mapValuesToRandom: shpE valuesOfCurrentAttribute.
shpE legend: legend.
shpE displayMorphic
```# Sample outputs
Follows some example outputs using different attributes for the NaturalEarth data set:
## CONTINENT

## SUBREGION

## REGION_UN

## NAME_LONG
