Classic ARC/INFO Functions in PostGIS: Define Projection and Project
- artlembo
- 59 minutes ago
- 2 min read
If you've worked with ARC/INFO (or any GIS really), you often have to make a determination about the coordinate system of your data: if you want to reproject the data into another coordinate system, you use PROJECT, but if you want to simply overwrite the coordinate system of a layer, you would use DEFINE PROJECTION. PostGIS allows you to do both commands rather easily. So today, I'll show you both of them. I often find that I need to do these commands a lot, especially when I bring in a new layer. So, I'm sure I'll be revisiting this blog post many times to refresh my memory.
Define Projection
Remember, the Define Projection in ArcGIS simply renames the projection information. It does not change the data. PostGIS does this by using the ST_SetSRID function.
The states table is defined with EPSG: 2769. That's the California Zone 4. Viewing the geometry in PGAdmin 4 looks like this:

Let's pretend for a moment that the coordinate system was never assigned to the layer. So, we'd issue this query to simply set the coordinate system to EPSG 2769. No coordinate values are changed. We're simply assigning a coordinate system to the layer.
In the above query, we are altering the states layer, and specifically, altering the geometry column called geometry. We have to tell PostGIS what the geometry type is (point, line, polygon, multipolygon, etc.), and the new coordinate system. In this case, I am using the EPSG code for the new coordinate system. We have to enter it twice: once for the geometry itself, and once for where we are setting the SRID value.
Project
The Project command actually changes the underlying coordinates. That is, it changes the data.
Here again, just like ST_SetSRID, we are altering the parks table and the parks geometry field (geom). But now, instead of using ST_SetSRID, we are using ST_Transform. Now, you'll see the layer is reprojected into the WGS 84 system:

Don't forget, we've changed the actual coordinate numbers. The map is now changed. So, if you want to go back to the original coordinates, you'll have to issue another ST_Tranform.
if you want to learn more about spatial SQL in Postgres/PostGIS, you can order my book How do I do that in PostGIS: Illustrating classic GIS tasks.