Package: graphene-gis
graphene-gisINSTALLATIONdjango==2.2is supported. Install thegraphene-giswith pip:$pipinstallgraphene-gisMake sure that you have appropriate driver to interact with postgis--psycopg2orpsycopg2-binary. The binary package is a practical choice for development and testing
but in production it is advised to use the package built from sources. More infohere.Add it to yourINSTALLED_APPSinsettings.py:INSTALLED_APPS=[...'graphene_gis',]USAGEHi, check this->geoqlproject out,
it demonstrates usage-- such as querying, mutations usingWKTandgeojson.
I will be adding more stuff soon such as containerization, interactive UI etc,
and more examples that showcases the library. This project provides an insight
into real-world usage of the library, do check it out.This extension can works out of the box withWKT, but if you want to useGeoJSONfor input while mutations, installrest_framework_gisalongside
it-- or check outgeoqlsample project.QUERYmodels.pyfromdjango.contrib.gis.dbimportmodelsclassPlace(models.Model):name=models.CharField(max_length=255)location=models.PointField()schema.pyfromgraphene_djangoimportDjangoObjectTypefromgraphene_gis.converterimportgis_converter# noqaclassPlaceType(DjangoObjectType):classMeta:model=PlaceclassQuery(graphene.ObjectType):place=graphene.Field(Place)defresolve_place(self,info):returnPlace(name="San Andreas",location="POINT(34.2 54.3)")schema=graphene.Schema(query=Query)Queryquery {
    place {
        name
        location
    }
}Query Output"place":{"name":"San Andreas","location":{"type":"Point","coordinates":[34.2,54.3]}}MUTATIONschema.pyclassPointModelType(graphene.ObjectType):location=graphene.Field(graphene.String,to=scalars.PointScalar())classCreatePointModelType(graphene.Mutation):point=graphene.Field(PointModelType)classArguments:location=graphene.Argument(scalars.PointScalar)defmutate(root,info,location):point=PointModelType(location=location)returnCreatePointModelType(point=point)Mutationmutation {
    createPoint (location: "POINT(3 5)") {
        point {
            location
        }
    }
}Mutation Output"createPoint":{"point":{"location":"{'type': 'Point', 'coordinates': [3.0, 5.0]}"}}EXTRA STUFFA JSON Converter, so if you're familiar withgraphene, you know that
it sendsJSONFieldas stringified JSON, but with a lot of data, you
dont want to parse it in the frontend, I know it goes against having a
static type, but if you're not modifying the data on the frontend, plus
you're usingtypescriptwhich enforces types anyway, it works like a
charm.And geojson containsJSONFieldlike properties section, and parsing
every node in the frontend is cumbersome if you have ~9000 entries, also
time consuming.Output without usingjson_converter{"data":{"vectors":[{"type":"Feature","properties":"{\"Name\": \"Blues\", \"area\": 0.0006971253332413299, \"bbox\": [74.59639001261124, 24.7077612714826, 74.61615129922414, 24.755648349214077], \"perimeter\": 0.15862406542812008}","geometry":{"type":"Polygon","coordinates":[...]}}]}}Now if you're working with GeoJSON, you're not working with just one vector,
you're probably working with thousands. Voilajson_converter!!! Now you can
plot it directly, if you store it in such a way! I won't go into how to structure
the model, but this is fairly accurate description ofGeoJSON, and anyone
familiar withdjangowill be able to reproduce it without issues.{"data":{"allVectors":[{"type":"Feature","properties":{"Name":"Blues","area":0.0006971253332413299,"bbox":[74.59639001261124,24.7077612714826,74.61615129922414,24.755648349214077],"perimeter":0.15862406542812008},"geometry":{"type":"Polygon","coordinates":[...]}}]}}AUTHORRishabh Mehtaeternal.blizzard23@gmail.comIf you have any issues or queries regarding acadbot, please don't
hesitate to email the@author. I have a lot of free time.I forget stuff, this section is for anyone who wants to build the package.$pythonsetup.pysdist
$twineuploaddist/*UPDATETargeting graphene-v3 update by March'22 ->MRInstall the pre-release using:Django 4.2 LTS support by May'23pip install graphene-gis==0.0.8b0LICENSEThis code falls under the MIT license which permits the reuse of the proprietary software provided that all copies of the licensed software include a copy of the MIT License terms and the copyright notice. Go crazy!