Reputation: 6041
I would like to insert the polygon containing Europe in my PostGIS database.
I have the follwoing extremes points:
NW = NorthWest Border(lat=82.7021697 lon=-28.0371000)
NE = NorthEast Border(lat=82.7021697 lon=74.1357000)
SE = SouthEast Border(lat=33.8978000 lon=74.1357000)
SW = SouthWest Border(lat=33.8978000 lon=-28.0371000)
Is the following a valid polygon:
POLYGON((NWLon NWLat, NELon NELat, SELon SElat, SWLon SWLat, NWlon NWLat))
Is this a valid polygon?
I do see some polygon with the follwing format POLYGON((), ()) ? When are they used?
Why not a linestring?
Any help will be apreciated? This is getting me really confused.
Thanks
Upvotes: 3
Views: 3156
Reputation: 34408
This is a PostGIS polygon:
ST_GeomFromText('POLYGON((lon1 lat1, lon2 lat2, ... lonN latN))', SRID)
where SRID is the SRID of the geometry column you are interacting with and lonN, latN must equal lon1, lat1, ie, the ring must explicitly closed.
In plain Postgres, the geometry types include a polygon (ie, no projection data, no background GIS functions, not really to be used with longitude and latitude); the syntax for those polygons is:
insert into some_table (polygon_column) values ('(1,1),(2,2),(3,4),(1,1)');
You may also find this question: SQL query for point-in-polygon using PostgreSQL relevant.
Upvotes: 1