/Applications/Postgres.app/Contents/Versions/9.4/bin
to your $PATHcreatedb mammals
psql -U you -d mammals -c 'CREATE EXTENSION postgis'
psql -U you -d mammals -c 'CREATE EXTENSION postgis_topology'
shp2pgsql -s 4326 -W "latin1" ~/Downloads/TERRESTRIAL_MAMMALS/TERRESTRIAL_MAMMALS.shp | psql -U you mammals
(this will take about a minute or two)psql -U you mammals
UPDATE terrestrial_mammals SET geom = ST_MakeValid(geom);
(Took about half an hour for me)CREATE TABLE grouped_families AS SELECT family_nam, ST_Union(geom) AS geom FROM terrestrial_mammals GROUP BY family_nam;
(takes ~ 30 seconds)VACUUM ANALYZE grouped_families;
CREATE TABLE grouped_species AS SELECT species_na, ST_Union(geom) AS geom FROM terrestrial_mammals GROUP BY species_na;
VACUUM ANALYZE grouped_species;
–create index sIndex on terrestrial_mammals USING gist (geom); create index ON terrestrial_mammals (family_nam); create index on terrestrial_mammals (species_na); You can also install PGAdminIII to more easily view the data.