Package: pypika-gis
PyPika GISThis library contains SpatialTypes functions for extendingPyPikawith GIS.Table of ContentsPyPika GISTable of ContentsInstallExamplesPostGISMSSQLSpatialAvailable functionsDevelopmentDependenciesSetupTestsPublishCreditsInstallpipinstallpypika-gisExamplesPostGISfrompypikaimportQuery,Tablefrompypika_gis.spatialtypesimportpostgisassttable=Table('table')query=Query.from_(table).select(table.id,st.AsGeoJSON(table.geom))print(str(query))# SELECT "id",ST_AsGeoJSON('geom') FROM "table"query=Query.from_(table).select('id').where(st.Intersects(table.geom,st.SetSRID(st.MakePoint(10,5),4326)))print(str(query))# SELECT "id" FROM "table" WHERE ST_Intersects('geom',ST_SRID(ST_MakePoint(10,5),4326))MSSQLSpatialfrompypikaimportQuery,Tablefrompypika_gis.spatialtypesimportmssqlassttable=Table('table')query=Query.from_(table).select(table.id,st.AsText(table.geom))print(str(query))# SELECT "id",geom.STAsText() FROM "table"query=Query.from_(table).select(table.id).where(st.Intersects(table.geom,st.GeomFromText('POINT(10 10)',4326)))print(str(query))# SELECT "id" FROM "table" WHERE geom.STIntersects(geometry::STGeomFromText('POINT(10 10)',4326))Available functionspypika-gisPostGISMSSQLSpatialAreaST_AreaSTAreaAsBinaryST_AsBinarySTAsBinaryAsGeoJSONST_AsGeoJSON❌AsMVTST_AsMVT❌AsTextST_AsTextSTAsTextBoundaryST_BoundarySTBoundaryBufferST_BufferSTBufferCentroidST_CentroidSTCentroidClosestPointST_ClosestPoint❌ContainsST_ContainsSTContainsConvexHullST_ConvexHullSTConvexHullCoveredByST_CoveredBy❌CoversST_Covers❌CrossesST_CrossesSTCrossesCurveN❌STCurveNCurveToLineST_CurveToLineSTCurveToLineDifferenceST_DifferenceSTDifferenceDimensionST_DimensionSTDimensionDisjointST_DisjointSTDisjointDistanceST_DistanceSTDistanceDWithinST_DWithin❌EndPointST_EndPointSTEndPointEnvelopeST_EnvelopeSTEnvelopeEqualsST_EqualsSTEqualsExteriorRingST_ExteriorRingSTExteriorRingExtentST_Extent❌GeoHashST_GeoHash❌GeometryNST_GeometryNSTGeometryNGeometryTypeST_GeometryTypeSTGeometryTypeGeogFromGeoJSONST_GeogFromGeoJSON❌GeogFromTextST_GeogFromTextSTGeomFromTextGeogFromWKBST_GeogFromWKBSTGeomFromWKBGeogPointST_GeogPoint❌GeogPointFromGeoHashST_GeogPointFromGeoHash❌GeomFromGeoJSONST_GeomFromGeoJSON❌InteriorRingNST_InteriorRingNSTInteriorRingNIntersectionST_IntersectionSTIntersectionIntersectsST_IntersectsSTIntersectsIsCollectionST_IsCollection❌IsClosedST_IsClosedSTIsClosedIsEmptyST_IsEmptySTIsEmptyIsRingST_IsRingSTIsRingIsSimpleST_IsSimpleSTIsSimpleIsValidST_IsValidSTIsValidLengthST_LengthSTLengthMakeLineST_MakeLine❌MakePointST_MakePoint❌MakePolygonST_MakePolygon❌NumCurves❌STNumCurvesNumGeometries❌STNumGeometriesNumInteriorRing❌STNumInteriorRingNumPoints❌STNumPointsOverlapsST_OverlapsSTOverlapsPerimeterST_Perimeter❌PointST_PointPointPointNST_PointNSTPointNPointOnSurfaceST_PointOnSurfaceSTPointOnSurfaceRelateST_RelateSTRelateSetSRIDST_SetSRID❌SRID❌STSrid[^1]StartPointST_StartPointSTStartPointSymDifference❌STSymDifferenceTouchesST_TouchesSTTouchesUnionST_UnionSTUnionWithinST_WithinSTWithinXST_XSTX[^1]YST_YSTY[^1]ZST_Z❌[^1]: In MSSQL this is technically a method of the geography/geometry class, and returns a pypikaFieldinstead of aFunction.DevelopmentDependenciesPythonpoetrySetuppoetryinstall
poetryrunpre-commitinstallTestsFull tests and coveragepoetryrunpytestPublishpoetrybuild
poetrypublishCreditspypika-gis is based onPyPika. Check their page for further query buider instructions, examples and more details about PyPika core.