Re: [postgis-users] PARTIALLY RESOLVED: Geography/geometry

2019-01-21 Thread Simon (SPDBA) Greener
I'll do some more checks to see if ogr2ogr really is the problem. Simon ⁣Sent from BlueMail ​ On 22 Jan. 2019, 15:22, at 15:22, Martin Davis wrote: >Perhaps log this as an OGR issue [1]? Probably need to bisect the >problem >a bit more though (e.g. reduce the input to a single failing polygon).

Re: [postgis-users] PARTIALLY RESOLVED: Geography/geometry

2019-01-21 Thread Martin Davis
Perhaps log this as an OGR issue [1]? Probably need to bisect the problem a bit more though (e.g. reduce the input to a single failing polygon). [1] https://github.com/OSGeo/gdal/issues On Mon, Jan 21, 2019 at 7:06 PM Simon Greener wrote: > I replaced the shapefile load script dropping ogr

[postgis-users] PARTIALLY RESOLVED: Geography/geometry

2019-01-21 Thread Simon Greener
I replaced the shapefile load script dropping ogr2ogr in favor of shp2pgshp. This appears to have given me clean multipolygons as nothing was reported by the following: select ST_ISValidReason(a.geog4326::geometry) from data.osm_county as a where ST_IsValidReason(a.geog4326::geometry) <> 'Va

Re: [postgis-users] Geography/geometry

2019-01-21 Thread Simon Greener
Thanks. I couldn't see how this would help as this is structural not mathematical. But I am trying to bring the parts back together. S On Tue, 22 Jan 2019 10:01:36 +1100, Martin Davis wrote: Could the problem be the use of the ogr2ogr option -nlt POLYGON ? Some of the input geometries are

Re: [postgis-users] Geography/geometry

2019-01-21 Thread Simon Greener
Try the ireland.sql file again. I used Paul's suggested SQL. S On Tue, 22 Jan 2019 09:39:25 +1100, Martin Davis wrote: Not much help, I'm afraid. I need the geometry in WKBHex. Not sure offhand how to get that out of PostGIS. Just post the WKT and let's see what that looks like. On Mon, J

Re: [postgis-users] Geography/geometry

2019-01-21 Thread Simon (SPDBA) Greener
I'm didn't load into geometry, I used ogr2ogr to load into geography. All work to date has been ok except now I want to aggregate union the polygon parts of bounties with multiple polygon parts. ST_Union is not geographic aware hence all the trouble. Using geometry as the load target does not a

Re: [postgis-users] Geography/geometry

2019-01-21 Thread Martin Davis
Could the problem be the use of the ogr2ogr option -nlt POLYGON ? Some of the input geometries are multipolygons, and it sounds like the way to handle this with ogr2ogr is to use GEOMETRY or PROMOTE_TO_MULTI [1][2] [1] https://www.gdal.org/ogr2ogr.html [2] https://gis.stackexchange.com/a/195223

Re: [postgis-users] Geography/geometry

2019-01-21 Thread Paul Ramsey
Just ’select geom’ will return the extended hexwkb (which we should have JTS support as a matter of convenience). If you need pure standard hex wkb, then select encode(st_asbinary(geom), ‘hex’) will do that P > On Jan 21, 2019, at 2:39 PM, Martin Davis wrote: > > Not much help, I'm afraid.

Re: [postgis-users] Geography/geometry

2019-01-21 Thread Paul Ramsey
> On Jan 21, 2019, at 1:46 PM, Simon Greener wrote: > > Thanks Paul. > > However, I get the same number of distinct st_isvalidreason results. Something is awry here, because I get only 'Valid Geometry’ as a validity check result… I loaded your shape file, I have 42 irish counties, I didn’t e

Re: [postgis-users] Geography/geometry

2019-01-21 Thread Martin Davis
Not much help, I'm afraid. I need the geometry in WKBHex. Not sure offhand how to get that out of PostGIS. Just post the WKT and let's see what that looks like. On Mon, Jan 21, 2019 at 1:52 PM Simon Greener wrote: > Try here for an example: > > https://www.dropbox.com/s/n234bc6i5hj7y4o/Irela

Re: [postgis-users] Geography/geometry

2019-01-21 Thread Simon Greener
Try here for an example: https://www.dropbox.com/s/n234bc6i5hj7y4o/Ireland.sql?dl=0___ postgis-users mailing list postgis-users@lists.osgeo.org https://lists.osgeo.org/mailman/listinfo/postgis-users

Re: [postgis-users] Geography/geometry

2019-01-21 Thread Simon Greener
Thanks Paul. However, I get the same number of distinct st_isvalidreason results. Is there anything I can do with ogr2ogr when loading to help? Simon On Tue, 22 Jan 2019 08:34:02 +1100, Paul Ramsey wrote: +proj=gnom +lat_0=53.35 +lon_0=-6.26 +x_0=0 +y_0=0 +ellps=WGS84 +units=m +no_defs

Re: [postgis-users] Geography/geometry

2019-01-21 Thread Paul Ramsey
> On Jan 21, 2019, at 1:28 PM, Simon Greener wrote: > > I can't find a suitable gnomic srid for PostGIS. > You’re going to want one centred on Ireland, not the pole, and I think maybe it’s wanting a geodetic basis, try this: +proj=gnom +lat_0=53.35 +lon_0=-6.26 +x_0=0 +y_0=0 +ellps=WGS84 +

Re: [postgis-users] Geography/geometry

2019-01-21 Thread Martin Davis
Can you post the WKB of one of the failing geometries, from the loaded data? It's best to look at the exact input causing the problem. On a side note, I did notice that when the polygons were merged (using JTS, which works fine), there is only one very small hole in the result [1]. It seems to c

Re: [postgis-users] Geography/geometry

2019-01-21 Thread Simon Greener
Paul, I can't find a suitable gnomic srid for PostGIS. I have tried this: INSERT INTO spatial_ref_sys (srid, proj4text) VALUES (55000, '+proj=gnom +lat_0=90 +lon_0=-7.646288'); but I get this when I use ST_Transform. UPDATE data.osm_county SET geom55000 = ST_Transform(geog4326::geometry,5500

Re: [postgis-users] Geography/geometry

2019-01-21 Thread Paul Ramsey
Not really sure that’s the answer… I’d much rather see work on geodetic edges in GEOS P > On Jan 21, 2019, at 1:20 PM, Darafei Komяpa Praliaskouski > wrote: > > If someone is willing, there is an old Geography Overlays patch that needs > lots of love: https://github.com/postgis/postgis/pull/

Re: [postgis-users] Geography/geometry

2019-01-21 Thread Komяpa
If someone is willing, there is an old Geography Overlays patch that needs lots of love: https://github.com/postgis/postgis/pull/191 On Tue, Jan 22, 2019 at 12:13 AM Paul Ramsey wrote: > > > > On Jan 21, 2019, at 1:00 PM, Simon Greener > wrote: > > > > When a geography is casted to geometry for

Re: [postgis-users] Geography/geometry

2019-01-21 Thread Paul Ramsey
> On Jan 21, 2019, at 1:00 PM, Simon Greener wrote: > > When a geography is casted to geometry for use in the aggregate form of > ST_Union (or other commands such as ST_Within) is the processing done > assuming the data is projected even when geodetic? All processing of geometry make cartesi

Re: [postgis-users] Geography/geometry

2019-01-21 Thread Simon Greener
The shapefile (from OSM) can be accessed here: https://www.dropbox.com/s/jbptp3ycmc8cqzi/gis_osm_county_a_free_1.rar?dl=0 The command used to load is: ogr2ogr -overwrite -progress -skipfailures -a_srs "EPSG:4326" ^ -f "PostgreSQL" PG:"dbname='gisdb' host='localhost' port='5432' user='postgre

Re: [postgis-users] Geography/geometry

2019-01-21 Thread Martin Davis
Simon, can you post one (or more) of the geographies which are being reported as invalid when you run *select distinct st_isvalidreason(a.geog4326::geometry) *? It's certainly possible for reprojection to introduce invalidities, due to geodesic/straight line issue. I'm actually surprised this d

Re: [postgis-users] Geography/geometry

2019-01-21 Thread Paul Ramsey
If it’s just Ireland, transform to a good Irish projection after casting to geometry. For maximum awsomeness, transform to gnomonic, in which great circles are represented as straight lines… then even all the introduced points will be at the correct geographic locations. Works for smaller areas,

Re: [postgis-users] Geography/geometry

2019-01-21 Thread Birgit Laggner
Hi Simon, I assume, you are trying to get this all done in one query, right? Did you try to throw ST_MakeValid into the mix? Like: ST_Transform(ST_Union(ST_MakeValid(ST_Transform(a.geog4326::geometry, 3857))), 4326)::geography Regards, Birgit Von: "Simon Greener" An: "PostGIS Users D