Skip to content

Commit

Permalink
DISTPG-570 Updated postgis docs (#411)
Browse files Browse the repository at this point in the history
modified:   docs/solutions/postgis-deploy.md
	modified:   docs/solutions/postgis-testing.md
	modified:   mkdocs-base.yml
  • Loading branch information
nastena1606 authored Jul 3, 2023
1 parent 463804d commit 67b618d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 11 deletions.
21 changes: 14 additions & 7 deletions docs/solutions/postgis-deploy.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ The following document provides guidelines how to install PostGIS and how to run
## Preconditions

1. We assume that you have the basic knowledge of spatial data, GIS (Geographical Information System) and of shapefiles.
2. You need to acquire spatial data. For the following examples, we'll use the same [data set](https://s3.amazonaws.com/s3.cleverelephant.ca/postgis-workshop-2020.zip) as is used in [PostGIS tutorial](http://postgis.net/workshops/postgis-intro/).
2. For uploading the spatial data and querying the database, we use the same [data set](https://s3.amazonaws.com/s3.cleverelephant.ca/postgis-workshop-2020.zip) as is used in [PostGIS tutorial](http://postgis.net/workshops/postgis-intro/).


## Install PostGIS

1. Enable Percona repository.
1. Enable Percona repository

As other components of Percona Distribution for PostgreSQL, PostGIS is available from Percona repositories. Use the [`percona-release`](https://docs.percona.com/percona-software-repositories/installing.html) repository management tool to enable the repository.

Expand Down Expand Up @@ -93,17 +94,17 @@ The following document provides guidelines how to install PostGIS and how to run
FROM pg_available_extensions WHERE name LIKE 'postgis%' or name LIKE 'address%';
```

3. Create a database and a schema to store your data. A schema is a container that logically segments objects (tables, functions, views, and so on) for better management. Run the following commands from the `psql` terminal:
3. Create a database and a schema for this database to store your data. A schema is a container that logically segments objects (tables, functions, views, and so on) for better management. Run the following commands from the `psql` terminal:

```sql
CREATE database nyc;
\c nyc;
CREATE SCHEMA gis;
```

4. To make PostGIS functions and operations work, you need to enable the `postgis` extension. From the `psql` terminal, switch to the database you created and run the following command:
4. To make PostGIS functions and operations work, you need to enable the `postgis` extension. Make sure you are connected to the database you created earlier and run the following command:

```sql
\c nyc;
CREATE EXTENSION postgis;
```

Expand All @@ -118,14 +119,20 @@ The following document provides guidelines how to install PostGIS and how to run
```{.sql .no-copy}
postgis_full_version
-----------------------------------------------------------------------------------------------------------------------------------------------------------------
POSTGIS="3.3.3dev 0" [EXTENSION] PGSQL="140" GEOS="3.10.2-CAPI-1.16.0" PROJ="8.2.1" LIBXML="2.9.13" LIBJSON="0.15" LIBPROTOBUF="1.3.3" WAGYU="0.5.0 (Internal)"
POSTGIS="3.3.3" [EXTENSION] PGSQL="140" GEOS="3.10.2-CAPI-1.16.0" PROJ="8.2.1" LIBXML="2.9.13" LIBJSON="0.15" LIBPROTOBUF="1.3.3" WAGYU="0.5.0 (Internal)"
```

## Upload spatial data to PostgreSQL

PostGIS provides the `shp2pgsql` command line utility that converts the binary data from shapefiles into the series of SQL commands and loads them into the database.

1. From the folder where the `.shp` files are located, execute the following command and replace the `dbname` value with the name of your database:
1. For testing purposes, download the sample data set:

```{.bash data-prompt="$"}
$ curl -LO https://s3.amazonaws.com/s3.cleverelephant.ca/postgis-workshop-2020.zip
```

2. Unzip the archive and from the folder where the `.shp` files are located, execute the following command and replace the `dbname` value with the name of your database:

```{.bash data-prompt="$"}
shp2pgsql \
Expand Down
6 changes: 3 additions & 3 deletions docs/solutions/postgis-testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ population
To get the answer we will use the `ST_Area` function that returns the areas of polygons.

```sql
SELECT ST_Area(geom) / 1000
SELECT ST_Area(geom) / 1000000
FROM nyc_neighborhoods
WHERE name = 'Central Park';
```
Expand All @@ -33,11 +33,11 @@ Output:
```{.sql .no-copy}
st_area
--------------------
3519.8365965413293
3.5198365965413293
(1 row)
```

By default, the output is given in square meters. To get the value in square kilometers, divide it by 1000.
By default, the output is given in square meters. To get the value in square kilometers, divide it by 1 000 000.

## *How long is Columbus Circle?*

Expand Down
2 changes: 1 addition & 1 deletion mkdocs-base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ nav:
- Overview: solutions/postgis.md
- Deployment: solutions/postgis-deploy.md
- Query spatial data: solutions/postgis-testing.md
# - Upgrade spatial database: solutions/postgis-upgrade.md
- Upgrade spatial database: solutions/postgis-upgrade.md
- LDAP authentication:
- ldap.md
- Uninstall: uninstalling.md
Expand Down

0 comments on commit 67b618d

Please sign in to comment.